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 | 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 2x 2x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 2x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 4x 4x 4x | import { FC } from 'react'
import { FormBlockWrapper } from '@/shared/ui'
import { Controller, useFormContext } from 'react-hook-form'
import { Datepicker } from '@tmk/ui-kit'
import { SelectWithQuery, useTranslate } from '@/shared/lib'
import { useWarehousesCollection } from '@/entities/warehouse'
import { useContractsWarehouses } from '@/entities/warehouse-contract'
import dayjs from 'dayjs'
import { DEFAULT_DATE_FORMAT } from '@/shared/config'
export const InventoryContractBlock: FC = () => {
const { t } = useTranslate(['accounting-object', 'common'])
const { control, watch } = useFormContext()
return (
<FormBlockWrapper childrenClassName='grid grid-cols-8 gap-2.5'>
<Controller
name='date'
control={control}
render={({ field, fieldState: { error } }) => (
<Datepicker
inputProps={{
label: t('Operation date') + ' *',
error,
}}
className='col-span-2'
{...field}
/>
)}
/>
<Controller
name='warehouse'
control={control}
render={({ field, fieldState: { error } }) => (
<SelectWithQuery
label={t('Warehouse') + ' *'}
useQuery={useWarehousesCollection}
error={error}
className='col-span-2'
{...field}
/>
)}
/>
<Controller
name='warehouseContract'
control={control}
render={({ field, fieldState: { error } }) => (
<SelectWithQuery
label={t('Contract (number and date)') + ' *'}
useQuery={useContractsWarehouses}
error={error}
disabled={!watch('warehouse')}
transformLabel={contract =>
`${contract?.contract?.number} ${t('common:from')} ${dayjs(contract.contract?.date).format(
DEFAULT_DATE_FORMAT
)}`
}
dependentEntityType='filter'
dependentEntities={{
warehouse: watch('warehouse') as string,
}}
className='col-span-2'
disableIfEmptyDependentEntities={false}
{...field}
/>
)}
/>
</FormBlockWrapper>
)
}
|