fix build
This commit is contained in:
parent
7fb706cdaf
commit
45494483a0
40
apps/web/Components/Calculation/builders/build-switch.tsx
Normal file
40
apps/web/Components/Calculation/builders/build-switch.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
import type { Elements } from '../config/map/values';
|
||||
import { useStoreValue } from './hooks';
|
||||
import { useStatus } from '@/stores/calculation/statuses/hooks';
|
||||
import { useValidation } from '@/stores/calculation/validation/hooks';
|
||||
import type { Values } from '@/stores/calculation/values/types';
|
||||
import type { SwitchChangeEventHandler } from 'antd/lib/switch';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import type { ComponentType } from 'react';
|
||||
import { Form } from 'ui/elements';
|
||||
|
||||
type BuilderProps = {
|
||||
elementName: Elements;
|
||||
valueName: Values;
|
||||
};
|
||||
|
||||
export function buildSwitch<T>(
|
||||
Component: ComponentType<T>,
|
||||
{ elementName, valueName }: BuilderProps
|
||||
) {
|
||||
return observer((props: T) => {
|
||||
const [value, setValue] = useStoreValue(valueName);
|
||||
const status = useStatus(elementName);
|
||||
const { validateStatus, help } = useValidation(elementName);
|
||||
|
||||
return (
|
||||
<Form.Item help={help} validateStatus={validateStatus}>
|
||||
<Component
|
||||
onChange={
|
||||
((checked) => {
|
||||
setValue(checked);
|
||||
}) as SwitchChangeEventHandler
|
||||
}
|
||||
disabled={status === 'Disabled'}
|
||||
checked={value}
|
||||
{...props}
|
||||
/>
|
||||
</Form.Item>
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -3,4 +3,5 @@ export * from './build-check';
|
||||
export { default as buildLink } from './build-link';
|
||||
export { default as buildOptions } from './build-options';
|
||||
export { default as buildReadonly } from './build-readonly';
|
||||
export * from './build-switch';
|
||||
export * from './build-value';
|
||||
|
||||
@ -73,7 +73,7 @@ const components = wrapComponentsMap({
|
||||
selectCalcFinDepartment: e.Select,
|
||||
selectFinDepartmentRewardCondtion: e.Select,
|
||||
tbxFinDepartmentRewardSumm: e.InputNumber,
|
||||
cbxInsDecentral: e.Switch,
|
||||
cbxInsDecentral: e.Checkbox,
|
||||
tbxInsFranchise: e.InputNumber,
|
||||
cbxInsUnlimitDrivers: e.Switch,
|
||||
tbxInsAgeDrivers: e.InputNumber,
|
||||
|
||||
@ -4,7 +4,15 @@ import * as b from '../builders';
|
||||
import type { Elements as ActionElements } from './map/actions';
|
||||
import type { Elements as ValuesElements } from './map/values';
|
||||
|
||||
type ElementTypes = 'Action' | 'Check' | 'Link' | 'Options' | 'Readonly' | 'Value';
|
||||
type ElementTypes =
|
||||
| 'Action'
|
||||
| 'Check'
|
||||
| 'Link'
|
||||
| 'Number'
|
||||
| 'Options'
|
||||
| 'Readonly'
|
||||
| 'Switch'
|
||||
| 'Value';
|
||||
type Builders =
|
||||
| typeof b.buildAction
|
||||
| typeof b.buildOptions
|
||||
@ -49,6 +57,10 @@ const t = wrapTypeGetters({
|
||||
typeName: 'Check',
|
||||
builder: b.buildCheck,
|
||||
}),
|
||||
Switch: () => ({
|
||||
typeName: 'Switch',
|
||||
builder: b.buildSwitch,
|
||||
}),
|
||||
});
|
||||
|
||||
function wrapElementsTypes<T, E extends Record<ActionElements | ValuesElements, T>>(arg: E) {
|
||||
@ -94,25 +106,25 @@ const types = wrapElementsTypes({
|
||||
tbxFinDepartmentRewardSumm: t.Number,
|
||||
cbxInsDecentral: t.Check,
|
||||
tbxInsFranchise: t.Number,
|
||||
cbxInsUnlimitDrivers: t.Check,
|
||||
cbxInsUnlimitDrivers: t.Switch,
|
||||
tbxInsAgeDrivers: t.Number,
|
||||
tbxInsExpDrivers: t.Number,
|
||||
cbxLastPaymentRedemption: t.Check,
|
||||
cbxPriceWithDiscount: t.Check,
|
||||
cbxFullPriceWithDiscount: t.Check,
|
||||
cbxCostIncrease: t.Check,
|
||||
cbxInsurance: t.Check,
|
||||
cbxRegistrationQuote: t.Check,
|
||||
cbxTechnicalCardQuote: t.Check,
|
||||
cbxNSIB: t.Check,
|
||||
cbxLastPaymentRedemption: t.Switch,
|
||||
cbxPriceWithDiscount: t.Switch,
|
||||
cbxFullPriceWithDiscount: t.Switch,
|
||||
cbxCostIncrease: t.Switch,
|
||||
cbxInsurance: t.Switch,
|
||||
cbxRegistrationQuote: t.Switch,
|
||||
cbxTechnicalCardQuote: t.Switch,
|
||||
cbxNSIB: t.Switch,
|
||||
tbxQuoteName: t.Value,
|
||||
cbxQuoteRedemptionGraph: t.Check,
|
||||
cbxShowFinGAP: t.Check,
|
||||
cbxQuoteRedemptionGraph: t.Switch,
|
||||
cbxShowFinGAP: t.Switch,
|
||||
tbxCreditRate: t.Number,
|
||||
tbxMaxPriceChange: t.Number,
|
||||
tbxImporterRewardPerc: t.Number,
|
||||
tbxImporterRewardRub: t.Number,
|
||||
cbxDisableChecks: t.Check,
|
||||
cbxDisableChecks: t.Switch,
|
||||
tbxMileage: t.Number,
|
||||
tbxTotalPayments: t.Number,
|
||||
tbxVehicleTaxInYear: t.Number,
|
||||
@ -179,7 +191,7 @@ const types = wrapElementsTypes({
|
||||
selectLeasingWithoutKasko: t.Options,
|
||||
tbxVIN: t.Value,
|
||||
selectUser: t.Options,
|
||||
cbxSupplierFinancing: t.Check,
|
||||
cbxSupplierFinancing: t.Switch,
|
||||
|
||||
labelLeaseObjectRisk: t.Readonly,
|
||||
tbxInsKaskoPriceLeasePeriod: t.Readonly,
|
||||
|
||||
6
packages/ui/elements/Button.tsx
Normal file
6
packages/ui/elements/Button.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import type { ButtonProps } from 'antd';
|
||||
import { Button as AntdButton } from 'antd';
|
||||
|
||||
export function Button(props: ButtonProps) {
|
||||
return <AntdButton {...props}>{props.children}</AntdButton>;
|
||||
}
|
||||
6
packages/ui/elements/Checkbox.tsx
Normal file
6
packages/ui/elements/Checkbox.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import type { CheckboxProps } from 'antd';
|
||||
import { Checkbox as AntdCheckbox } from 'antd';
|
||||
|
||||
export function Checkbox(props: CheckboxProps) {
|
||||
return <AntdCheckbox {...props}>{props.children}</AntdCheckbox>;
|
||||
}
|
||||
6
packages/ui/elements/Input.tsx
Normal file
6
packages/ui/elements/Input.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import type { InputProps } from 'antd';
|
||||
import { Input as AntdInput } from 'antd';
|
||||
|
||||
export function Input(props: InputProps) {
|
||||
return <AntdInput {...props}>{props.children}</AntdInput>;
|
||||
}
|
||||
6
packages/ui/elements/Switch.tsx
Normal file
6
packages/ui/elements/Switch.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import type { SwitchProps } from 'antd';
|
||||
import { Switch as AntdSwitch } from 'antd';
|
||||
|
||||
export function Switch(props: SwitchProps) {
|
||||
return <AntdSwitch {...props} />;
|
||||
}
|
||||
@ -9,25 +9,25 @@ notification.config({
|
||||
placement: 'bottomRight',
|
||||
});
|
||||
|
||||
export * from './Button';
|
||||
export * from './Checkbox';
|
||||
export { default as AntdConfig } from './Config';
|
||||
export * from './Input';
|
||||
export { default as Link } from './Link';
|
||||
export { default as Radio } from './Radio';
|
||||
export { default as Segmented } from './Segmented';
|
||||
export { default as Select } from './Select';
|
||||
export * from './Switch';
|
||||
export { default as Text } from './Text';
|
||||
export {
|
||||
Alert,
|
||||
Badge,
|
||||
Button,
|
||||
Checkbox,
|
||||
Divider,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
notification,
|
||||
Result,
|
||||
Switch,
|
||||
Table,
|
||||
Tabs,
|
||||
Tag,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user