Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import {
ACCOUNTING_OBJECTS_FILTERS_PAGE,
getAccountingObjectOperations,
isLoadingExcelExportAtom,
OperationsBlock,
OperationType,
selectedAccountingObjectsForOperation,
selectedOperationType,
selectedPackagesAtom,
useNormalizedAccountingObjectFilters,
} from '@/entities/accounting-object'
import { useTranslate } from '@/shared/lib'
import { useRouter } from 'next/router'
import { Button } from '@tmk/ui-kit'
import { FC } from 'react'
import { validateObjectsForOperations } from '@/features/validator'
import { useAtom, useAtomValue } from 'jotai'
import { useUpdateAtom } from 'jotai/utils'
export const AccountingObjectHeaderContent: FC = () => {
const { t } = useTranslate(['common', 'accounting-object'])
const router = useRouter()
const selectedAccountingObjects = useAtomValue(selectedPackagesAtom)
const [isLoadingExport, setIsLoadingExport] = useAtom(isLoadingExcelExportAtom)
const setAccountingObjectsForOperation = useUpdateAtom(selectedAccountingObjectsForOperation)
const setSelectedOperation = useUpdateAtom(selectedOperationType)
const onClickHandler = (operation: OperationType) => {
setSelectedOperation(operation)
}
const filters = useNormalizedAccountingObjectFilters()
const operations = getAccountingObjectOperations(
t,
router,
selectedAccountingObjects,
setAccountingObjectsForOperation,
onClickHandler,
filters,
isLoadingExport,
setIsLoadingExport
)
return (
<div className='flex items-center gap-5'>
<OperationsBlock
onClickHandler={onClickHandler}
operations={operations}
validateObjectsForOperations={validateObjectsForOperations}
isLoadingExport={isLoadingExport}
setIsLoadingExport={setIsLoadingExport}
/>
<Button
onClick={() => {
const currentUrl = window.location.href
const filters = currentUrl.split('?')[1]
const params = new URLSearchParams(filters)
params.delete('page')
router.push({
pathname: ACCOUNTING_OBJECTS_FILTERS_PAGE,
query: params.toString(),
})
}}
>
<h2>{t('Filters')}</h2>
</Button>
</div>
)
}
|