From 3fb908936e33b8ae9053ea21b1e2767f245f4068 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 26 Jan 2026 12:04:50 +0330 Subject: [PATCH] manage attribute form --- src/components/Radio.tsx | 20 ++++ src/components/RadioGroup.tsx | 31 +++++ .../order/components/ManageAttribute.tsx | 113 ++++++++++++++++++ src/pages/order/components/Order.tsx | 82 ++++++++++++- src/pages/order/enum/OrderEnum.ts | 10 ++ src/pages/order/type/Types.ts | 32 +++++ 6 files changed, 282 insertions(+), 6 deletions(-) create mode 100644 src/components/Radio.tsx create mode 100644 src/components/RadioGroup.tsx create mode 100644 src/pages/order/components/ManageAttribute.tsx diff --git a/src/components/Radio.tsx b/src/components/Radio.tsx new file mode 100644 index 0000000..6077733 --- /dev/null +++ b/src/components/Radio.tsx @@ -0,0 +1,20 @@ +import { type FC } from 'react' + +type Props = { + isActive: boolean, + value: string, + onChange: (value: string) => void +} + +const Radio: FC = (props: Props) => { + return ( +
props.onChange(props.value)} className='size-4 cursor-pointer rounded-full bg-[#EAEDF5] flex justify-center items-center'> + { + props.isActive && +
+ } +
+ ) +} + +export default Radio \ No newline at end of file diff --git a/src/components/RadioGroup.tsx b/src/components/RadioGroup.tsx new file mode 100644 index 0000000..bcb1d10 --- /dev/null +++ b/src/components/RadioGroup.tsx @@ -0,0 +1,31 @@ +import { type FC } from 'react' +import Radio from './Radio' + + +type Props = { + items: { + label: string + value: string + }[] + selected: string + onChange: (value: string) => void +} + +const RadioGroup: FC = (props: Props) => { + return ( +
+ { + props.items.map((item, index) => ( +
+ +
+ {item.label} +
+
+ )) + } +
+ ) +} + +export default RadioGroup \ No newline at end of file diff --git a/src/pages/order/components/ManageAttribute.tsx b/src/pages/order/components/ManageAttribute.tsx new file mode 100644 index 0000000..d4ea517 --- /dev/null +++ b/src/pages/order/components/ManageAttribute.tsx @@ -0,0 +1,113 @@ +import { type FC } from 'react' +import type { AttributeType } from '../type/Types' +import { clx } from '@/helpers/utils' +import { FieldTypeEnum } from '../enum/OrderEnum' +import Select from '@/components/Select' +import { Checkbox } from '@/components/ui/checkbox' +import RadioGroup from '@/components/RadioGroup' +import DatePickerComponent from '@/components/DatePicker' +import Input from '@/components/Input' +import Textarea from '@/components/Textarea' + +type Props = { + attributes?: AttributeType[] +} + +const ManageAttribute: FC = (props) => { + + const { attributes } = props + + return ( +
+ { + attributes?.map((item) => { + if (item?.type === FieldTypeEnum.select) + return ( +
+ +
+ ) + else if (item.type === FieldTypeEnum.textarea) + return ( +
+