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(() => {
if (props.value) {
setFormattedValue(formatNumber(props.value as string));
} else {
setFormattedValue('');
}
}, [props.value])
+52 -54
View File
@@ -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 (
<div className='mt-4'>
@@ -63,60 +67,54 @@ const CustomerList: FC = () => {
</div>
</div>
<div className='relative overflow-x-auto rounded-3xl mt-9 w-full'>
<table className='w-full text-sm '>
<thead className='thead'>
<tr>
<Td text={t('customer.name')} />
<Td text={t('customer.company')} />
<Td text={t('customer.email')} />
<Td text={t('customer.active_services')} />
<Td text={t('customer.factor')} />
<Td text={t('customer.tickets')} />
<Td text={t('customer.detail')} />
<Td text={''} />
</tr>
</thead>
<tbody>
<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 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 text={''}>
<Link to={Pages.ticket.detail + '1'}>
<Eye size={20} color='#8C90A3' />
</Link>
</Td>
<Td text={''} />
</tr>
</tbody>
</table>
</div>
{
getCustomers.isPending ?
<PageLoading />
:
<div className='relative overflow-x-auto rounded-3xl mt-9 w-full'>
<table className='w-full text-sm '>
<thead className='thead'>
<tr>
<Td text={t('customer.name')} />
<Td text={t('customer.company')} />
<Td text={t('customer.email')} />
<Td text={t('customer.active_services')} />
<Td text={t('customer.factor')} />
<Td text={t('customer.tickets')} />
<Td text={t('customer.detail')} />
<Td text={''} />
</tr>
</thead>
<tbody>
{
getCustomers.data?.data?.customers?.map((item: CustomerItemType) => {
return (
<tr key={item.id} className='tr'>
<Td text={item.firstName + ' ' + item.lastName} />
<Td text={'شرکت داناک'} />
<Td text={item.email ? item.email : ''} />
<Td text={item.subscriptionsCount} />
<Td text={''}>
<div className='text-[#0047FF]'>{item.invoicesCount} صورت حساب</div>
</Td>
<Td text={''}>
<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>
)
})
}
</tbody>
</table>
</div>
}
</div>
)
}
@@ -17,4 +17,7 @@ export type CustomerItemType = {
tickets: unknown[];
updatedAt: string;
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 { 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 (
<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>
@@ -341,14 +334,8 @@ const CreateReceipt: FC = () => {
/>
</div>
<div onClick={() => {
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'>
<Add size={20} color='black' />
<div onClick={() => handleRemove(index)} className='size-10 border border-border rounded-xl flex justify-center items-center'>
<Trash size={20} color='black' />
</div>
</div>
)
+1 -1
View File
@@ -126,7 +126,7 @@ const ListService: FC = () => {
<Td text={item.name} />
<Td text={item.author} />
<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=''>
{
item.subscriptionCount === 0 ?
+1 -1
View File
@@ -260,7 +260,7 @@ const SideBar: FC = () => {
</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'>
{
subMenuName === 'services' ?