import { Alert, Button, Group, MultiSelect, Progress, Stack, Title, } from "@mantine/core"; import { DatePickerInput } from "@mantine/dates"; import type { FC } from "react"; import { useTranslation } from "react-i18next"; import { LedgerEntryRow, type OperationCategory, operationCategories, } from "@/entities/broker-operation"; import { StateView } from "@/shared/ui"; import type { AccountOperationsPageViewModel } from "../AccountOperationsPage.vm"; type AccountOperationsPageLoadedProps = Extract< AccountOperationsPageViewModel, { state: "loaded" } >; const operationCategorySet = new Set(operationCategories); function fromMultiSelectValue(value: string[]) { return value.filter((item): item is OperationCategory => operationCategorySet.has(item), ); } const AccountOperationsPageLoaded: FC = ( props, ) => { const { canApply, draftCategories, draftFrom, draftTo, hasNext, hasPrevious, items, onApply, onDraftCategoriesChange, onDraftFromChange, onDraftToChange, onNext, onPrevious, onReset, } = props; const { t } = useTranslation(); const categoryData = operationCategories.map((category) => ({ value: category, label: t(`ledger.category.${category}`), })); return ( {t("ledger.title")} {props.refreshing ? ( ) : null} {props.refreshError ? ( {t("accounts.refreshError")} ) : null} { onDraftFromChange(from); onDraftToChange(to); }} valueFormat="DD.MM.YYYY" popoverProps={{ returnFocus: true, middlewares: { shift: { crossAxis: true } }, }} /> onDraftCategoriesChange(fromMultiSelectValue(value)) } clearable clearButtonProps={{ "aria-label": t("ledger.clearPeriod") }} /> {items.length ? ( items.map((operation) => ( )) ) : ( )} {hasNext || hasPrevious ? ( ) : null} ); }; export { AccountOperationsPageLoaded };