diff --git a/src/app/[name]/(Main)/order/history/page.tsx b/src/app/[name]/(Main)/order/history/page.tsx index a7ce300..1e6463b 100644 --- a/src/app/[name]/(Main)/order/history/page.tsx +++ b/src/app/[name]/(Main)/order/history/page.tsx @@ -59,7 +59,7 @@ function OrdersIndex() { } return orders.map((order) => { - const address = order.address?.address || 'آدرس ثبت نشده'; + const address = order.userAddress?.address || 'آدرس ثبت نشده'; const formattedDate = formatDate(order.createdAt); const formattedPrice = order.total.toLocaleString('fa-IR'); const items: HistoryOrderItem[] = order.items || []; @@ -134,7 +134,7 @@ function OrdersIndex() { } return orders.map((order) => { - const address = order.address?.address || 'آدرس ثبت نشده'; + const address = order.userAddress?.address || 'آدرس ثبت نشده'; const formattedDate = formatDate(order.createdAt); const formattedPrice = order.total.toLocaleString('fa-IR'); const items: HistoryOrderItem[] = order.items || []; diff --git a/src/app/[name]/(Main)/order/history/service/Service.ts b/src/app/[name]/(Main)/order/history/service/Service.ts index a359c46..d4e8cac 100644 --- a/src/app/[name]/(Main)/order/history/service/Service.ts +++ b/src/app/[name]/(Main)/order/history/service/Service.ts @@ -18,8 +18,6 @@ export const getOrders = async ( OrderStatus.COMPLETED, ]; - console.log(statuses); - const { data } = await api.get(`/public/orders`, { params: { statuses: statuses, diff --git a/src/app/[name]/(Main)/order/history/types/Types.ts b/src/app/[name]/(Main)/order/history/types/Types.ts index 9173dd0..9f4ff8c 100644 --- a/src/app/[name]/(Main)/order/history/types/Types.ts +++ b/src/app/[name]/(Main)/order/history/types/Types.ts @@ -7,15 +7,25 @@ export interface HistoryOrderUser { updatedAt: string; deletedAt: string | null; firstName: string; - lastName: string; + lastName: string | null; phone: string; - birthDate: string; - marriageDate: string; + birthDate: string | null; + marriageDate: string | null; referrer: string | null; isActive: boolean; gender: boolean; - wallet: number; - points: number; + avatarUrl: string | null; +} + +export interface HistoryOrderRestaurantScore { + scoreAmount: string; + scoreCredit: string; + birthdayScore: string; + purchaseScore: string; + referrerScore: string; + registerScore: string; + purchaseAmount: string; + marriageDateScore: string; } export interface HistoryOrderRestaurant { @@ -30,10 +40,9 @@ export interface HistoryOrderRestaurant { menuColor: string | null; latitude: number | null; longitude: number | null; - serviceArea: ServiceArea; + serviceArea: ServiceArea | null; isActive: boolean; establishedYear: number | null; - phoneNumber: string | null; phone: string; instagram: string | null; telegram: string | null; @@ -45,6 +54,11 @@ export interface HistoryOrderRestaurant { images: string | null; vat: number; domain: string; + score: HistoryOrderRestaurantScore; + plan: string; + subscriptionId: string; + subscriptionEndDate: string; + subscriptionStartDate: string; } export interface HistoryOrderDeliveryMethod { @@ -52,16 +66,29 @@ export interface HistoryOrderDeliveryMethod { createdAt: string; updatedAt: string; deletedAt: string | null; - title: string; method: "dineIn" | "pickup" | "deliveryCar" | "deliveryCourier"; restaurant: string; deliveryFee: number; + deliveryFeeType: string; + perKilometerFee: number | null; + distanceBasedMinCost: number | null; minOrderPrice: number; description: string; enabled: boolean; order: number; } +export interface HistoryOrderUserAddress { + city: string; + phone: string; + address: string; + fullName: string; + latitude: number; + province: string; + longitude: number; + postalCode: string; +} + export interface HistoryOrderAddress { id: string; createdAt: string; @@ -85,7 +112,6 @@ export interface HistoryOrderPaymentMethod { updatedAt: string; deletedAt: string | null; restaurant: string; - title: string; method: "CardOnDelivery" | "Cash" | "Online"; gateway: string | null; description: string; @@ -105,23 +131,17 @@ export interface HistoryOrderFood { desc: string | null; content: string | null; price: number; - points: number | null; order: number | null; prepareTime: number | null; - sat: boolean; - sun: boolean; - mon: boolean; - breakfast: boolean; - noon: boolean; - dinner: boolean; - stock: number; - stockDefault: number; + weekDays: number[]; + mealTypes: ("breakfast" | "lunch" | "dinner" | "snack")[]; isActive: boolean; images: string[] | null; inPlaceServe: boolean; pickupServe: boolean; - rate: number; + score: number; discount: number; + isSpecialOffer: boolean; } export interface HistoryOrderItem { @@ -137,6 +157,11 @@ export interface HistoryOrderItem { totalPrice: number; } +export interface HistoryOrderHistoryItem { + status: string; + changedAt: string; +} + export interface HistoryOrder { id: string; createdAt: string; @@ -145,21 +170,39 @@ export interface HistoryOrder { user: HistoryOrderUser; restaurant: HistoryOrderRestaurant; deliveryMethod: HistoryOrderDeliveryMethod; - address: HistoryOrderAddress | null; + userAddress: HistoryOrderUserAddress | null; + carAddress: HistoryOrderUserAddress | null; paymentMethod: HistoryOrderPaymentMethod; orderNumber: number; couponDiscount: number; + couponDetail: unknown | null; itemsDiscount: number; totalDiscount: number; subTotal: number; tax: number; - shipmentFee: number; + deliveryFee: number; total: number; totalItems: number; + description: string; + tableNumber: string | null; status: string; - paymentStatus: string; + history: HistoryOrderHistoryItem[]; items: HistoryOrderItem[]; } -export type OrdersResponse = BaseResponse; +export interface OrdersResponseMeta { + total: number; + page: number; + limit: number; + totalPages: number; +} + +export interface OrdersResponseData { + data: HistoryOrder[]; + meta: OrdersResponseMeta; +} + +export type OrdersResponse = BaseResponse & { + meta?: OrdersResponseMeta; +};