import { t } from "@lingui/macro" import { ActionIcon, Center, Divider, Indicator, Popover, TextInput } from "@mantine/core" import { useForm } from "@mantine/form" import { search } from "app/slices/entries" import { changeReadingMode, changeReadingOrder } from "app/slices/user" import { useAppDispatch, useAppSelector } from "app/store" import { ActionButton } from "components/ActionButtton" import { ButtonToolbar } from "components/ButtonToolbar" import { Loader } from "components/Loader" import { useEffect } from "react" import { TbArrowDown, TbArrowUp, TbEye, TbEyeOff, TbRefresh, TbSearch, TbUser, TbX } from "react-icons/tb" import { MarkAllAsReadButton } from "./MarkAllAsReadButton" import { ProfileMenu } from "./ProfileMenu" import { RefreshMenu } from "./RefreshMenu" function HeaderDivider() { return } const iconSize = 18 export function Header() { const settings = useAppSelector(state => state.user.settings) const profile = useAppSelector(state => state.user.profile) const searchFromStore = useAppSelector(state => state.entries.search) const dispatch = useAppDispatch() const searchForm = useForm<{ search: string }>({ validate: { search: value => (value.length > 0 && value.length < 3 ? t`Search requires at least 3 characters` : null), }, }) const { setValues } = searchForm useEffect(() => { setValues({ search: searchFromStore, }) }, [setValues, searchFromStore]) if (!settings) return return (
} label={t`Refresh`} />} /> : } label={settings.readingMode === "all" ? t`All` : t`Unread`} onClick={() => dispatch(changeReadingMode(settings.readingMode === "all" ? "unread" : "all"))} /> : } label={settings.readingOrder === "asc" ? t`Asc` : t`Desc`} onClick={() => dispatch(changeReadingOrder(settings.readingOrder === "asc" ? "desc" : "asc"))} /> } label={t`Search`} />
dispatch(search(values.search)))}> } rightSection={ searchFromStore && dispatch(search(""))}> } autoFocus />
} label={profile?.name} />} />
) }