This commit is contained in:
hamid zarghami
2026-01-31 10:28:38 +03:30
parent acbd06425b
commit 7df6d04d5f
6 changed files with 146 additions and 19 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
VITE_API_BASE_URL = 'http://10.22.13.88:4000' VITE_API_BASE_URL = 'http://10.24.161.1:4000'
VITE_TOKEN_NAME = 'negareh_at' VITE_TOKEN_NAME = 'negareh_at'
VITE_REFRESH_TOKEN_NAME = 'negareh_art' VITE_REFRESH_TOKEN_NAME = 'negareh_art'
+28 -18
View File
@@ -2,8 +2,13 @@ import Filters from '@/components/Filters'
import { type FC } from 'react' import { type FC } from 'react'
import Table from '@/components/Table' import Table from '@/components/Table'
import { Edit2, Eye, Receipt21, Setting2 } from 'iconsax-react' import { Edit2, Eye, Receipt21, Setting2 } from 'iconsax-react'
import { useGetOrders } from './hooks/useOrderData'
import moment from 'moment-jalaali'
const OrdersList: FC = () => { const OrdersList: FC = () => {
const { data } = useGetOrders()
return ( return (
<div className='mt-5'> <div className='mt-5'>
<h1 className='text-lg font-light'>سفارش ها</h1> <h1 className='text-lg font-light'>سفارش ها</h1>
@@ -37,24 +42,39 @@ const OrdersList: FC = () => {
<Table <Table
columns={[ columns={[
{ {
key: 'id', key: 'orderNumber',
title: 'شماره', title: 'شماره',
}, },
{
key: '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: 'date', key: 'createdAt',
title: 'تاریخ ایجاد ', title: 'تاریخ ایجاد ',
render: (item) => {
return (
<div>{moment(item.createdAt).format('jYYYY-jMM-jDD')}</div>
)
}
}, },
{ {
key: 'type', key: 'type',
title: 'نوع', title: 'تعداد اقلام',
render: (item) => {
return (
<div>
{item.items.length}
</div>
)
}
}, },
{ {
key: 'designer', key: 'designer',
@@ -86,17 +106,7 @@ const OrdersList: FC = () => {
} }
}, },
]} ]}
data={[ data={data?.data}
{
id: 1,
title: 'سفارش 1',
customer: 'مشتری 1',
date: '2025/01/01',
type: 'نوع 1',
designer: 'مجری 1',
status: 'درحال انتظار',
}
]}
/> />
</div> </div>
</div> </div>
+24
View File
@@ -0,0 +1,24 @@
export enum OrderStatusEnum {
CREATED = "created",
INVOICED = "invoiced",
WAITING_to_CONFIRM_INVOICE = "waiting_to_confirm_invoice",
DESIGN_INITIATED = "design_initiated",
DESIGN_FINISHED = "design_finished",
DESIGN_REVISION = "design_revision",
READY_TO_PRINTING = "ready_to_printing",
IN_PRINTING = "in_printing",
READY_FOR_DELIVERY = "ready_for_delivery",
DELIVERED = "delivered",
AFTER_PRINT_COVER = "after_print_cover",
AFTER_PRINT_BOXING = "after_print_boxing",
AFTER_PRINT_CARTONING = "after_print_cartoning",
FINISHED = "finished",
CANCELED = "canceled",
}
+9
View File
@@ -0,0 +1,9 @@
import { useQuery } from "@tanstack/react-query";
import * as api from "../service/OrderService";
export const useGetOrders = () => {
return useQuery({
queryKey: ["orders"],
queryFn: api.getOrders,
});
};
+7
View File
@@ -0,0 +1,7 @@
import axios from "@/config/axios";
import type { OrderResponseType } from "../types/Types";
export const getOrders = async () => {
const { data } = await axios.get<OrderResponseType>(`/admin/orders`);
return data;
};
+77
View File
@@ -0,0 +1,77 @@
import type { BaseResponse } from "@/shared/types/Types";
import type { OrderStatusEnum } from "../enum/OrderEnum";
import type { RowDataType } from "@/components/types/TableTypes";
export interface OrderType extends RowDataType {
id: string;
user: UserType;
creator: string | null;
orderNumber: number;
estimatedDays: number | null;
status: OrderStatusEnum;
paymentMethod: string | null;
invoicedAt: string | null;
enableTax: boolean;
createdAt: string;
deletedAt: string | null;
items: OrderItem[];
discount: string;
subTotal: string;
taxAmount: string;
total: string;
paidAmount: string;
balance: string;
}
export interface OrderItem {
id: string;
order: string;
product: Product;
designer: string | null;
attributes: OrderItemAttribute[];
quantity: number;
unitPrice: string | null;
discount: string | null;
description: string | null;
adminDescription: string | null;
attachments: string[];
printAttachments: null;
printAttributes: null;
confirmedAt: string | null;
createdAt: string;
deletedAt: string | null;
subTotal: string;
total: string;
}
export interface Product {
id: string;
createdAt: string;
deletedAt: string | null;
category: string;
title: string;
desc: string;
quantities: number[];
linkUrl: string | null;
isActive: boolean;
images: string[];
order: number;
}
export interface OrderItemAttribute {
attributeId: string;
value: string;
}
export type OrderResponseType = BaseResponse<OrderType[]>;
export type UserType = {
addresse?: string;
createdAt: string;
firstName?: string;
lastName?: string;
isActive: boolean;
id: string;
maxCredit: number;
phone: string;
};