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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { FC } from 'react'
import { useFieldArray, useFormContext } from 'react-hook-form'
import { Button } from '@tmk/ui-kit'
import PlusIcon from '@/shared/assets/icons/common/plus.svg'
import { getAppendContractBody, TransportBlock } from '@/entities/accounting-object'
import { useTranslate } from '@/shared/lib'
export interface AcceptanceTransportationBlockProps {
name: string
}
export const AcceptanceTransportationBlock: FC<AcceptanceTransportationBlockProps> = ({ name }) => {
const { control } = useFormContext()
const { t } = useTranslate(['accounting-object', 'common'])
const { fields, append, remove } = useFieldArray({
control,
name,
})
return (
<div className='flex flex-col gap-y-2.5 w-full bg-gray-secondary p-4 rounded-base'>
<div className='flex items-center gap-x-2.5'>
<h2>{t('Transport_vehicle')}</h2>
<Button variant='border-icon' onClick={() => append(getAppendContractBody())}>
<PlusIcon className='stroke-currentColor' />
</Button>
</div>
<div className='flex flex-col gap-y-2.5'>
{fields.map((item, index) => (
<TransportBlock key={item.id} parentName={`${name}.${index}.`} remove={() => remove(index)} />
))}
</div>
</div>
)
}
|