From bc58e6b5643add32b8531e9bfce9f043a3bac8f0 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 27 Jan 2026 08:45:42 +0330 Subject: [PATCH] single order --- .env | 2 +- .../order/components/ManageAttribute.tsx | 39 +++++++++--- src/pages/order/components/Order.tsx | 60 ++++++++++++++----- src/pages/order/hooks/useOrderData.ts | 8 ++- src/pages/order/service/OrderService.ts | 7 ++- src/pages/order/store/OrderStore.ts | 9 +-- src/pages/order/type/Types.ts | 18 ++++-- src/pages/uploader/hooks/useUploader.ts | 14 +++++ src/pages/uploader/service/UploaderService.ts | 27 +++++++++ src/pages/uploader/types/Types.ts | 13 ++++ 10 files changed, 161 insertions(+), 36 deletions(-) create mode 100644 src/pages/uploader/hooks/useUploader.ts create mode 100644 src/pages/uploader/service/UploaderService.ts create mode 100644 src/pages/uploader/types/Types.ts diff --git a/.env b/.env index 611f4dd..7b0e99e 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ VITE_TOKEN_NAME = 'negareh_t' VITE_REFRESH_TOKEN_NAME = 'negareh_rt' -VITE_API_BASE_URL = 'http://192.168.99.235:4000' +VITE_API_BASE_URL = 'http://192.168.99.226:4000' diff --git a/src/pages/order/components/ManageAttribute.tsx b/src/pages/order/components/ManageAttribute.tsx index d4ea517..785da50 100644 --- a/src/pages/order/components/ManageAttribute.tsx +++ b/src/pages/order/components/ManageAttribute.tsx @@ -1,5 +1,5 @@ import { type FC } from 'react' -import type { AttributeType } from '../type/Types' +import type { AttributeType, OrderType } from '../type/Types' import { clx } from '@/helpers/utils' import { FieldTypeEnum } from '../enum/OrderEnum' import Select from '@/components/Select' @@ -8,14 +8,28 @@ import RadioGroup from '@/components/RadioGroup' import DatePickerComponent from '@/components/DatePicker' import Input from '@/components/Input' import Textarea from '@/components/Textarea' +import type { FormikProps } from 'formik' type Props = { - attributes?: AttributeType[] + attributes?: AttributeType[], + formik: FormikProps } const ManageAttribute: FC = (props) => { - const { attributes } = props + const { attributes, formik } = props + + const handleChange = (attributeId: number, value: string) => { + const attribute = formik.values.attributes + const index: number = attribute.findIndex(o => o.attributeId === attributeId) + if (index > -1) { + attribute[index].value = value + } else { + attribute.push({ attributeId: attributeId, value: value }) + } + formik.setFieldValue('attributes', attribute) + } + return (
= (props) => { value: value.value } })} + onChange={(e) => handleChange(item.id, e.target.value)} />
) @@ -45,13 +60,14 @@ const ManageAttribute: FC = (props) => {
{ item.values?.map((value) => { + const object = formik.values.attributes.find(o => o.attributeId === item.id) return (
{value.value}
console.log(c)} + checked={object?.value === value.value} + onCheckedChange={(checked) => handleChange(item.id, checked ? value.value : '')} />
) @@ -60,7 +76,8 @@ const ManageAttribute: FC = (props) => {
) - else if (item.type === FieldTypeEnum.radio) + else if (item.type === FieldTypeEnum.radio) { + const object = formik.values.attributes.find(o => o.attributeId === item.id) return (
{item.name}
@@ -71,16 +88,18 @@ const ManageAttribute: FC = (props) => { value: value.value } })} - onChange={(v) => console.log(v)} - selected='' + onChange={(v) => handleChange(item.id, v)} + selected={object?.value + '' || ''} />
) + } + else if (item.type === FieldTypeEnum.date) return (
console.log(date)} + onChange={(date) => handleChange(item.id, date)} placeholder='' label={item.name} /> @@ -92,6 +111,7 @@ const ManageAttribute: FC = (props) => { handleChange(item.id, e.target.value)} />
) @@ -100,6 +120,7 @@ const ManageAttribute: FC = (props) => {