diff --git a/.env b/.env
index d366931..52ebffc 100644
--- a/.env
+++ b/.env
@@ -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_REFRESH_TOKEN_NAME = 'negareh_art'
\ No newline at end of file
diff --git a/src/pages/order/List.tsx b/src/pages/order/List.tsx
index 4f7c411..befc997 100644
--- a/src/pages/order/List.tsx
+++ b/src/pages/order/List.tsx
@@ -2,8 +2,13 @@ import Filters from '@/components/Filters'
import { type FC } from 'react'
import Table from '@/components/Table'
import { Edit2, Eye, Receipt21, Setting2 } from 'iconsax-react'
+import { useGetOrders } from './hooks/useOrderData'
+import moment from 'moment-jalaali'
const OrdersList: FC = () => {
+
+ const { data } = useGetOrders()
+
return (
سفارش ها
@@ -37,24 +42,39 @@ const OrdersList: FC = () => {
{
+ return (
+
+ {item.user?.firstName ? item.user?.firstName + ' ' + item.user?.lastName : item.user?.phone}
+
+ )
+ }
},
{
- key: 'date',
+ key: 'createdAt',
title: 'تاریخ ایجاد ',
+ render: (item) => {
+ return (
+ {moment(item.createdAt).format('jYYYY-jMM-jDD')}
+ )
+ }
},
{
key: 'type',
- title: 'نوع',
+ title: 'تعداد اقلام',
+ render: (item) => {
+ return (
+
+ {item.items.length}
+
+ )
+ }
},
{
key: 'designer',
@@ -86,17 +106,7 @@ const OrdersList: FC = () => {
}
},
]}
- data={[
- {
- id: 1,
- title: 'سفارش 1',
- customer: 'مشتری 1',
- date: '2025/01/01',
- type: 'نوع 1',
- designer: 'مجری 1',
- status: 'درحال انتظار',
- }
- ]}
+ data={data?.data}
/>
diff --git a/src/pages/order/enum/OrderEnum.ts b/src/pages/order/enum/OrderEnum.ts
new file mode 100644
index 0000000..ac39234
--- /dev/null
+++ b/src/pages/order/enum/OrderEnum.ts
@@ -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",
+}
diff --git a/src/pages/order/hooks/useOrderData.ts b/src/pages/order/hooks/useOrderData.ts
new file mode 100644
index 0000000..d690800
--- /dev/null
+++ b/src/pages/order/hooks/useOrderData.ts
@@ -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,
+ });
+};
diff --git a/src/pages/order/service/OrderService.ts b/src/pages/order/service/OrderService.ts
new file mode 100644
index 0000000..18b4a8f
--- /dev/null
+++ b/src/pages/order/service/OrderService.ts
@@ -0,0 +1,7 @@
+import axios from "@/config/axios";
+import type { OrderResponseType } from "../types/Types";
+
+export const getOrders = async () => {
+ const { data } = await axios.get(`/admin/orders`);
+ return data;
+};
diff --git a/src/pages/order/types/Types.ts b/src/pages/order/types/Types.ts
new file mode 100644
index 0000000..7b568f9
--- /dev/null
+++ b/src/pages/order/types/Types.ts
@@ -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;
+
+export type UserType = {
+ addresse?: string;
+ createdAt: string;
+ firstName?: string;
+ lastName?: string;
+ isActive: boolean;
+ id: string;
+ maxCredit: number;
+ phone: string;
+};