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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 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 2x 2x 2x 2x 2x | import { TFunction } from '@/shared/@types'
import { normalizeSelectOptionsFromEnum } from '@/shared/helpers'
import {
tasksAssignedForAtom,
tasksDescriptionAtom,
TaskStatusEnum,
tasksTitleAtom,
tasksWarehouseContractAtom,
tasksWarehouseAtom,
tasksStatusAtom,
tasksCreatedByAtom,
} from '@/entities/task'
import { DEFAULT_DATE_FORMAT, TableFilterAtom, TableFilterQuery } from '@tmk/ui-kit'
import { useWarehousesCollection } from '@/entities/warehouse'
import { Contract, useContracts } from '@/entities/contract'
import dayjs from 'dayjs'
import { TableFilterItem } from '@/widgets/table'
import { useUsersCollection } from '@/entities/user'
export const getTaskBaseFilters = (t: TFunction): TableFilterItem[] => [
{
label: t('accounting-object:title'),
type: 'input',
name: 'title',
atom: tasksTitleAtom as TableFilterAtom,
},
{
label: t('accounting-object:description'),
type: 'input',
name: 'description',
atom: tasksDescriptionAtom as TableFilterAtom,
},
{
label: t('accounting-object:status'),
type: 'select',
name: 'tasksStatus',
atom: tasksStatusAtom as TableFilterAtom,
options: normalizeSelectOptionsFromEnum(TaskStatusEnum, t, {
translatePrefix: 'accounting-object:',
}),
},
]
export const getTaskFilters = (t: TFunction, isViewerManager: boolean) => {
const managerFilters: TableFilterItem[] = [
{
label: t('accounting-object:Warehouse'),
atom: tasksWarehouseAtom as TableFilterAtom,
name: 'warehouse',
type: 'selectSearch',
useQuery: useWarehousesCollection as TableFilterQuery,
labelKey: 'name',
},
{
label: t('accounting-object:Contract'),
atom: tasksWarehouseContractAtom as TableFilterAtom,
name: 'warehouseContract',
type: 'selectSearch',
useQuery: useContracts as TableFilterQuery,
transformLabel: entity =>
`${(entity as Contract).number} ${t('from')} ${dayjs((entity as Contract).date).format(DEFAULT_DATE_FORMAT)}`,
},
{
label: t('accounting-object:assignedFor'),
atom: tasksAssignedForAtom as TableFilterAtom,
name: 'user',
type: 'selectSearch',
useQuery: useUsersCollection as TableFilterQuery,
labelKey: 'displayName',
},
]
const molFilters: TableFilterItem[] = [
{
label: t('accounting-object:createdBy'),
atom: tasksCreatedByAtom as TableFilterAtom,
name: 'user',
type: 'selectSearch',
useQuery: useUsersCollection as TableFilterQuery,
labelKey: 'displayName',
},
]
return [...getTaskBaseFilters(t), ...(isViewerManager ? managerFilters : molFilters)]
}
|