request list
This commit is contained in:
@@ -9,6 +9,13 @@ export const useGetOrders = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useGetRequests = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["requests"],
|
||||||
|
queryFn: api.getRequests,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const useGetOrderDetails = (id: string) => {
|
export const useGetOrderDetails = (id: string) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["order", id],
|
queryKey: ["order", id],
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ export const getOrders = async () => {
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRequests = async () => {
|
||||||
|
const { data } = await axios.get<OrderResponseType>(`/admin/orders/request`);
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
export const getOrderDetail = async (id: string) => {
|
export const getOrderDetail = async (id: string) => {
|
||||||
const { data } = await axios.get<OrderDetailResponseType>(
|
const { data } = await axios.get<OrderDetailResponseType>(
|
||||||
`/admin/orders/${id}`
|
`/admin/orders/${id}`
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import Filters from '@/components/Filters'
|
import Filters from '@/components/Filters'
|
||||||
import Table from '@/components/Table'
|
import Table from '@/components/Table'
|
||||||
import { type FC } from 'react'
|
import { type FC } from 'react'
|
||||||
|
import { useGetRequests } from '../order/hooks/useOrderData'
|
||||||
|
import moment from 'moment-jalaali'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import { Paths } from '@/config/Paths'
|
||||||
|
import { Edit2, Eye, Receipt21 } from 'iconsax-react'
|
||||||
|
|
||||||
const RequestList: FC = () => {
|
const RequestList: FC = () => {
|
||||||
|
|
||||||
|
const { data } = useGetRequests()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='mt-5'>
|
<div className='mt-5'>
|
||||||
<h1 className='text-lg font-light'>درخواست ها</h1>
|
<h1 className='text-lg font-light'>درخواست ها</h1>
|
||||||
@@ -40,24 +48,37 @@ const RequestList: FC = () => {
|
|||||||
<Table
|
<Table
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
key: 'id',
|
key: 'orderNumber',
|
||||||
title: 'شماره',
|
title: 'شماره',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'customer',
|
key: 'customer',
|
||||||
title: 'مشتری',
|
title: 'مشتری',
|
||||||
|
render: (item) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{item.user?.firstName ? item.user.firstName + ' ' + item.user?.lastName : item.user?.phone}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'creationDate',
|
key: 'createdAt',
|
||||||
title: 'تاریخ ایجاد درخواست',
|
title: 'تاریخ ایجاد درخواست',
|
||||||
},
|
render: (item) => {
|
||||||
{
|
return (
|
||||||
key: 'lastApprovalDate',
|
<div>{moment(item.createdAt).format('jYYYY-jMM-jDD')}</div>
|
||||||
title: 'آخرین مهلت تایید',
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'itemCount',
|
key: 'itemCount',
|
||||||
title: 'تعداد اقلام',
|
title: 'تعداد اقلام',
|
||||||
|
render: (item) => {
|
||||||
|
return (
|
||||||
|
<div>{item.items.length}</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'status',
|
key: 'status',
|
||||||
@@ -73,26 +94,25 @@ const RequestList: FC = () => {
|
|||||||
{
|
{
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
title: '',
|
title: '',
|
||||||
|
render: (item) => {
|
||||||
|
return (
|
||||||
|
<div className='flex gap-2 items-center'>
|
||||||
|
<Link
|
||||||
|
to={Paths.order.details + item.id}
|
||||||
|
>
|
||||||
|
<Eye size={20} color='#8C90A3' />
|
||||||
|
</Link>
|
||||||
|
<Link to={Paths.order.edit + item.id}>
|
||||||
|
<Edit2 size={20} color='#0037FF' />
|
||||||
|
</Link>
|
||||||
|
<Receipt21 size={20} color='#FF8000' />
|
||||||
|
{/* <Setting2 size={20} color='#00B89F' /> */}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
data={[
|
data={data?.data}
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
customer: 'مشتری 1',
|
|
||||||
creationDate: '2024-01-01',
|
|
||||||
lastApprovalDate: '2024-01-01',
|
|
||||||
itemCount: 10,
|
|
||||||
status: 'درحال انتظار',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
customer: 'مشتری 2',
|
|
||||||
creationDate: '2024-01-01',
|
|
||||||
lastApprovalDate: '2024-01-01',
|
|
||||||
itemCount: 10,
|
|
||||||
status: 'تایید شده',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user