From e8512bb147470dc6fe731c5d58ddee01ba3e1140 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 24 Feb 2025 10:21:40 +0330 Subject: [PATCH] p2 --- src/components/Input.tsx | 2 + src/pages/customer/List.tsx | 106 +++++++++++----------- src/pages/customer/types/CustomerTypes.ts | 3 + src/pages/receipts/Create.tsx | 25 ++--- src/pages/service/List.tsx | 2 +- src/shared/SideBar.tsx | 2 +- 6 files changed, 65 insertions(+), 75 deletions(-) diff --git a/src/components/Input.tsx b/src/components/Input.tsx index 4b130c3..e8a9f24 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -64,6 +64,8 @@ const Input: FC = (props: Props) => { useEffect(() => { if (props.value) { setFormattedValue(formatNumber(props.value as string)); + } else { + setFormattedValue(''); } }, [props.value]) diff --git a/src/pages/customer/List.tsx b/src/pages/customer/List.tsx index 26e3a06..8c166e6 100644 --- a/src/pages/customer/List.tsx +++ b/src/pages/customer/List.tsx @@ -7,10 +7,14 @@ import Input from '../../components/Input' import Td from '../../components/Td' import { Link } from 'react-router-dom' import { Pages } from '../../config/Pages' +import { useGetCustomers } from './hooks/useCustomerData' +import PageLoading from '../../components/PageLoading' +import { CustomerItemType } from './types/CustomerTypes' const CustomerList: FC = () => { const { t } = useTranslation('global') + const getCustomers = useGetCustomers() return (
@@ -63,60 +67,54 @@ const CustomerList: FC = () => {
-
- - - - - - - - - - - - - - - - - -
- - - - - - - -
- - - - -
۳ صورت حساب
-
-
۴ تیکت
-
- - - - -
- - - - -
۳ صورت حساب
-
-
۴ تیکت
-
- - - - -
-
+ { + getCustomers.isPending ? + + : +
+ + + + + + + { + getCustomers.data?.data?.customers?.map((item: CustomerItemType) => { + return ( + + + + + + ) + }) + } + + +
+ + + + + + + +
+ + + + +
{item.invoicesCount} صورت حساب
+
+
{item.ticketsCount} تیکت
+
+ + + + +
+
+ } ) } diff --git a/src/pages/customer/types/CustomerTypes.ts b/src/pages/customer/types/CustomerTypes.ts index 5cc3d2f..67005aa 100644 --- a/src/pages/customer/types/CustomerTypes.ts +++ b/src/pages/customer/types/CustomerTypes.ts @@ -17,4 +17,7 @@ export type CustomerItemType = { tickets: unknown[]; updatedAt: string; userName: string | null; + subscriptionsCount: string; + ticketsCount: string; + invoicesCount: string; }; diff --git a/src/pages/receipts/Create.tsx b/src/pages/receipts/Create.tsx index 3eb7bb0..db0ee4d 100644 --- a/src/pages/receipts/Create.tsx +++ b/src/pages/receipts/Create.tsx @@ -1,7 +1,7 @@ import { ChangeEvent, FC, Fragment, useState } from 'react' import { useTranslation } from 'react-i18next' import Button from '../../components/Button' -import { Add, TickCircle, TickSquare } from 'iconsax-react' +import { Add, TickCircle, TickSquare, Trash } from 'iconsax-react' import Select from '../../components/Select' import Input from '../../components/Input' import { CreateReceiptType, ReceiptCreateItemsType } from './types/ReceiptTypes' @@ -73,8 +73,9 @@ const CreateReceipt: FC = () => { } } - console.log('as', formik.values); - + const handleRemove = (index: number) => { + setItems((prev) => prev.filter((_, i) => i !== index)) + } return ( @@ -269,14 +270,6 @@ const CreateReceipt: FC = () => { items.map((item, index: number) => { return (
-
-
- {t('receip.number')} -
-
- {index + 1} -
-
@@ -341,14 +334,8 @@ const CreateReceipt: FC = () => { />
-
{ - if (formik.errors.name || formik.errors.count || formik.errors.unitPrice || formik.errors.discount) { - toast.error(t('receip.error_empty')) - } else { - formik.handleSubmit() - } - }} className='size-10 border border-border rounded-xl flex justify-center items-center'> - +
handleRemove(index)} className='size-10 border border-border rounded-xl flex justify-center items-center'> +
) diff --git a/src/pages/service/List.tsx b/src/pages/service/List.tsx index 19a440e..540ca97 100644 --- a/src/pages/service/List.tsx +++ b/src/pages/service/List.tsx @@ -126,7 +126,7 @@ const ListService: FC = () => { - + { item.subscriptionCount === 0 ? diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index 4d1d0b0..b7403c2 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -260,7 +260,7 @@ const SideBar: FC = () => {
{ - hasSubMenu && (openSidebar || window.innerWidth > 1000) && + hasSubMenu && (openSidebar || window.innerWidth > 1139) &&
{ subMenuName === 'services' ?