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 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x | import { FC } from 'react'
import { PERMISSION_EDIT_PIPE_PRICE, RoleProvider } from '@/features/rolevik'
import { FormBlockWrapper, NumericInput } from '@/shared/ui'
import { Controller, useFormContext } from 'react-hook-form'
import { RadioGroup } from '@tmk/ui-kit'
import { SelectWithQuery, useTranslate } from '@/shared/lib'
import { useCurrencies } from '@/entities/currency'
import { normalizeSelectOptionsFromEnum } from '@/shared/helpers'
import { LockPriceEnum } from '@/entities/pipe'
import cn from 'classnames'
export interface PriceBlockProps {
className?: string
}
export const PriceBlock: FC<PriceBlockProps> = ({ className }) => {
const { t } = useTranslate(['accounting-object'])
const { control } = useFormContext()
return (
<RoleProvider availablePermissions={[PERMISSION_EDIT_PIPE_PRICE]}>
<FormBlockWrapper
className={cn('col-span-2', className)}
childrenClassName='grid grid-cols-5 items-center gap-x-2.5'
>
<Controller
control={control}
render={({ field, fieldState: { error } }) => (
<NumericInput
allowNegative={false}
label={t('Price without VAT')}
error={error}
decimalScale={2}
className='col-span-2'
{...field}
/>
)}
name='price'
/>
<Controller
name='priceCurrency'
control={control}
render={({ field, fieldState: { error } }) => (
<SelectWithQuery
label={t('common:Ed.ed')}
useQuery={useCurrencies}
error={error}
labelKey='symbol'
className='col-span-1'
isApplySingleOption
{...field}
/>
)}
/>
<Controller
name='lockPrice'
control={control}
render={({ field, fieldState: { error } }) => (
<div>
<RadioGroup
className='col-span-1 flex items-center gap-x-2.5 mt-5 min-w-[220px]'
options={normalizeSelectOptionsFromEnum(LockPriceEnum, t, { translatePrefix: 'per_' })}
{...field}
/>
{error && <span className='text-left text-red text-main-regular'>{error.message}</span>}
</div>
)}
/>
</FormBlockWrapper>
</RoleProvider>
)
}
|