This commit is contained in:
hamid zarghami
2025-02-24 10:21:40 +03:30
parent f8054e2202
commit e8512bb147
6 changed files with 65 additions and 75 deletions
+2
View File
@@ -64,6 +64,8 @@ const Input: FC<Props> = (props: Props) => {
useEffect(() => { useEffect(() => {
if (props.value) { if (props.value) {
setFormattedValue(formatNumber(props.value as string)); setFormattedValue(formatNumber(props.value as string));
} else {
setFormattedValue('');
} }
}, [props.value]) }, [props.value])
+22 -24
View File
@@ -7,10 +7,14 @@ import Input from '../../components/Input'
import Td from '../../components/Td' import Td from '../../components/Td'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Pages } from '../../config/Pages' import { Pages } from '../../config/Pages'
import { useGetCustomers } from './hooks/useCustomerData'
import PageLoading from '../../components/PageLoading'
import { CustomerItemType } from './types/CustomerTypes'
const CustomerList: FC = () => { const CustomerList: FC = () => {
const { t } = useTranslation('global') const { t } = useTranslation('global')
const getCustomers = useGetCustomers()
return ( return (
<div className='mt-4'> <div className='mt-4'>
@@ -63,6 +67,10 @@ const CustomerList: FC = () => {
</div> </div>
</div> </div>
{
getCustomers.isPending ?
<PageLoading />
:
<div className='relative overflow-x-auto rounded-3xl mt-9 w-full'> <div className='relative overflow-x-auto rounded-3xl mt-9 w-full'>
<table className='w-full text-sm '> <table className='w-full text-sm '>
<thead className='thead'> <thead className='thead'>
@@ -78,34 +86,19 @@ const CustomerList: FC = () => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr className='tr'> {
<Td text='مهرداد مظفری' /> getCustomers.data?.data?.customers?.map((item: CustomerItemType) => {
return (
<tr key={item.id} className='tr'>
<Td text={item.firstName + ' ' + item.lastName} />
<Td text={'شرکت داناک'} /> <Td text={'شرکت داناک'} />
<Td text={'info@example.com'} /> <Td text={item.email ? item.email : ''} />
<Td text={'2 سرویس'} /> <Td text={item.subscriptionsCount} />
<Td text={''}> <Td text={''}>
<div className='text-[#0047FF]'>۳ صورت حساب</div> <div className='text-[#0047FF]'>{item.invoicesCount} صورت حساب</div>
</Td> </Td>
<Td text={''}> <Td text={''}>
<div className='text-[#0047FF]'>۴ تیکت</div> <div className='text-[#0047FF]'>{item.ticketsCount} تیکت</div>
</Td>
<Td text={''}>
<Link to={Pages.ticket.detail + '1'}>
<Eye size={20} color='#8C90A3' />
</Link>
</Td>
<Td text={''} />
</tr>
<tr className='tr'>
<Td text='مهرداد مظفری' />
<Td text={'شرکت داناک'} />
<Td text={'info@example.com'} />
<Td text={'2 سرویس'} />
<Td text={''}>
<div className='text-[#0047FF]'>۳ صورت حساب</div>
</Td>
<Td text={''}>
<div className='text-[#0047FF]'>۴ تیکت</div>
</Td> </Td>
<Td text={''}> <Td text={''}>
<Link to={Pages.ticket.detail + '1'}> <Link to={Pages.ticket.detail + '1'}>
@@ -114,9 +107,14 @@ const CustomerList: FC = () => {
</Td> </Td>
<Td text={''} /> <Td text={''} />
</tr> </tr>
)
})
}
</tbody> </tbody>
</table> </table>
</div> </div>
}
</div> </div>
) )
} }
@@ -17,4 +17,7 @@ export type CustomerItemType = {
tickets: unknown[]; tickets: unknown[];
updatedAt: string; updatedAt: string;
userName: string | null; userName: string | null;
subscriptionsCount: string;
ticketsCount: string;
invoicesCount: string;
}; };
+6 -19
View File
@@ -1,7 +1,7 @@
import { ChangeEvent, FC, Fragment, useState } from 'react' import { ChangeEvent, FC, Fragment, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Button from '../../components/Button' 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 Select from '../../components/Select'
import Input from '../../components/Input' import Input from '../../components/Input'
import { CreateReceiptType, ReceiptCreateItemsType } from './types/ReceiptTypes' 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 ( return (
@@ -269,14 +270,6 @@ const CreateReceipt: FC = () => {
items.map((item, index: number) => { items.map((item, index: number) => {
return ( return (
<div key={item.name} className='mt-8 flex items-end justify-between text-xs text-description'> <div key={item.name} className='mt-8 flex items-end justify-between text-xs text-description'>
<div className='flex flex-col gap-2 items-center'>
<div>
{t('receip.number')}
</div>
<div className='size-10 bg-[#EBEDF5] rounded-xl flex justify-center items-center'>
{index + 1}
</div>
</div>
<div className='flex flex-col gap-2 items-center'> <div className='flex flex-col gap-2 items-center'>
<div> <div>
@@ -341,14 +334,8 @@ const CreateReceipt: FC = () => {
/> />
</div> </div>
<div onClick={() => { <div onClick={() => handleRemove(index)} className='size-10 border border-border rounded-xl flex justify-center items-center'>
if (formik.errors.name || formik.errors.count || formik.errors.unitPrice || formik.errors.discount) { <Trash size={20} color='black' />
toast.error(t('receip.error_empty'))
} else {
formik.handleSubmit()
}
}} className='size-10 border border-border rounded-xl flex justify-center items-center'>
<Add size={20} color='black' />
</div> </div>
</div> </div>
) )
+1 -1
View File
@@ -126,7 +126,7 @@ const ListService: FC = () => {
<Td text={item.name} /> <Td text={item.name} />
<Td text={item.author} /> <Td text={item.author} />
<Td text={item.category?.title} /> <Td text={item.category?.title} />
<Td text={moment(item.createDate).format('jYYYY-jMM-jDD')} /> <Td text={moment(item.createDate, 'jYYYY-jMM-jDD').format('jYYYY-jMM-jDD')} />
<Td text=''> <Td text=''>
{ {
item.subscriptionCount === 0 ? item.subscriptionCount === 0 ?
+1 -1
View File
@@ -260,7 +260,7 @@ const SideBar: FC = () => {
</div> </div>
{ {
hasSubMenu && (openSidebar || window.innerWidth > 1000) && hasSubMenu && (openSidebar || window.innerWidth > 1139) &&
<div className='fixed xl:right-[112px] right-[96px] bg-white z-20 xl:top-4 xl:bottom-4 top-0 bottom-0 rounded-tl-[32px] rounded-bl-[32px] w-[190px] border-r'> <div className='fixed xl:right-[112px] right-[96px] bg-white z-20 xl:top-4 xl:bottom-4 top-0 bottom-0 rounded-tl-[32px] rounded-bl-[32px] w-[190px] border-r'>
{ {
subMenuName === 'services' ? subMenuName === 'services' ?