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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x | import { AccountingType, AffiliationType } from '@/entities/accounting-object'
import { normalizeSelectOptions, normalizeSelectOptionsFromEnum } from '@/shared/helpers'
import { SelectWithQuery, useTranslate } from '@/shared/lib'
import { Controller, useFormContext } from 'react-hook-form'
import { usePackagesCollection } from '@/entities/package'
import { FormBlockWrapper } from '@/shared/ui'
import { Datepicker, Select } from '@tmk/ui-kit'
import { FC } from 'react'
import { usePreserveLubricantCollection } from '@/entities/preservation-lubricant'
import { PipeStateEnum, PipeStatusEnum } from '@/entities/pipe'
export const VariableCharacteristicsPassportForm: FC = () => {
const { t } = useTranslate(['accounting-object'])
const { control, watch, getValues } = useFormContext()
const { data: packages } = usePackagesCollection()
const packageValue = getValues('package')?.['@id']
return (
<div className='bg-white w-full px-5 py-4 flex flex-col gap-y-2.5'>
<h2 className='text-black'>{t('Variable Characteristics')}</h2>
<FormBlockWrapper childrenClassName='grid grid-cols-4 gap-2.5'>
<Controller
name='accountingObject.type'
control={control}
render={({ field, fieldState: { error } }) => (
<Select
label={t('Object_type') + ' *'}
options={normalizeSelectOptionsFromEnum(AccountingType, t)}
className='col-span-1'
t={t}
inputProps={{
error,
}}
disabled
{...field}
/>
)}
/>
<Controller
name='status'
control={control}
render={({ field, fieldState: { error } }) => (
<Select
label={t('status') + ' *'}
options={normalizeSelectOptionsFromEnum(PipeStatusEnum, t)}
className='col-span-1'
t={t}
inputProps={{
error,
}}
disabled
{...field}
/>
)}
/>
<Controller
name='state'
control={control}
render={({ field, fieldState: { error } }) => (
<Select
label={t('state') + ' *'}
options={normalizeSelectOptionsFromEnum(PipeStateEnum, t)}
className='col-span-1'
t={t}
inputProps={{
error,
}}
{...field}
/>
)}
/>
<Controller
name='affiliation'
control={control}
render={({ field, fieldState: { error } }) => (
<Select
{...field}
label={t('affiliation') + ' *'}
t={t}
inputProps={{
error,
}}
options={normalizeSelectOptionsFromEnum(AffiliationType, t, {
translatePrefix: 'affiliation_',
})}
className='col-span-1'
/>
)}
/>
<Select
label={t('Package_number')}
options={normalizeSelectOptions(packages?.['hydra:member'], {
labelKey: 'number',
valueKey: '@id',
})}
t={t}
value={packageValue}
name='package_value'
disabled={!!packages?.['hydra:member']?.length}
/>
<Controller
name='preservationLubricant'
control={control}
render={({ field, fieldState: { error } }) => (
<SelectWithQuery
label={t('preservationLubricant')}
useQuery={usePreserveLubricantCollection}
error={error}
className='col-span-1'
withOptionAddition
source='preservation_lubricants'
{...field}
/>
)}
/>
<Controller
render={({ field, fieldState: { error } }) => (
<Datepicker
inputProps={{
label: t('preservationLubricantDate'),
error,
}}
disabled={!watch('preservationLubricant')}
className='col-span-1'
{...field}
/>
)}
control={control}
name='preservationLubricantDate'
/>
</FormBlockWrapper>
</div>
)
}
|