history list
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
export const enum OrderStatus {
|
||||
NEW = "new",
|
||||
PENDING_PAYMENT = "pendingPayment",
|
||||
PAID = "paid",
|
||||
CONFIRMED = "confirmed",
|
||||
PREPARING = "preparing",
|
||||
READY = "ready",
|
||||
DELIVERED_TO_RECEPIENT = "deliveredToRecepient",
|
||||
SHIPPED = "shipped",
|
||||
COMPLETED = "completed",
|
||||
|
||||
CANCELED = "canceled",
|
||||
FAILED = "failed",
|
||||
REFUNDED = "refunded",
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
export const enum OrderStatus {
|
||||
PENDING_PAYMENT = "pendingPayment",
|
||||
PAID = "paid",
|
||||
PREPARING = "preparing",
|
||||
DELIVERED_TO_WAITER = "deliveredToWaiter",
|
||||
DELIVERED_TO_RECEPTIONIST = "deliveredToReceptionist",
|
||||
SHIPPED = "shipped",
|
||||
COMPLETED = "completed",
|
||||
CANCELED = "canceled",
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import React, { useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useGetOrders } from './hooks/useHistoryData';
|
||||
import { HistoryOrderItem } from './types/Types';
|
||||
import { OrderStatus } from './enum/Enum';
|
||||
import { OrderStatus } from '@/app/[name]/(Dialogs)/order/checkout/enum/Enum';
|
||||
|
||||
const fallbackImage = '/assets/images/food-preview.png';
|
||||
|
||||
@@ -45,11 +45,10 @@ const getStatusColor = (status: string): string => {
|
||||
'paid': 'text-green-600 dark:text-green-400',
|
||||
'preparing': 'text-blue-600 dark:text-blue-400',
|
||||
'deliveredToWaiter': 'text-purple-600 dark:text-purple-400',
|
||||
'deliveredToReceptionist': 'text-indigo-600 dark:text-indigo-400',
|
||||
'deliveredToRecepient': 'text-indigo-600 dark:text-indigo-400',
|
||||
'shipped': 'text-cyan-600 dark:text-cyan-400',
|
||||
'completed': 'text-green-600 dark:text-green-400',
|
||||
'canceled': 'text-red-600 dark:text-red-400',
|
||||
'cancelled': 'text-red-600 dark:text-red-400',
|
||||
};
|
||||
return statusMap[status] || 'text-gray-600 dark:text-gray-400';
|
||||
};
|
||||
@@ -105,8 +104,8 @@ function OrdersIndex() {
|
||||
|
||||
<div className='mt-6 space-y-3'>
|
||||
{items.map((item) => {
|
||||
const imageUrl = getFoodImage(item.food.images);
|
||||
const foodName = item.food.title || 'بدون نام';
|
||||
const imageUrl = getFoodImage(item.variant?.product.images);
|
||||
const foodName = item.variant?.product.title || 'بدون نام';
|
||||
const itemTotalPrice = (item.totalPrice || item.unitPrice * item.quantity).toLocaleString('fa-IR');
|
||||
return (
|
||||
<div key={item.id} className='flex gap-3 items-center'>
|
||||
@@ -190,8 +189,8 @@ function OrdersIndex() {
|
||||
|
||||
<div className='mt-6 space-y-3'>
|
||||
{items.map((item) => {
|
||||
const imageUrl = getFoodImage(item.food.images);
|
||||
const foodName = item.food.title || 'بدون نام';
|
||||
const imageUrl = getFoodImage(item.variant?.product.images);
|
||||
const foodName = item.variant?.product.title || 'بدون نام';
|
||||
const itemTotalPrice = (item.totalPrice || item.unitPrice * item.quantity).toLocaleString('fa-IR');
|
||||
return (
|
||||
<div key={item.id} className='flex gap-3 items-center'>
|
||||
@@ -219,7 +218,7 @@ function OrdersIndex() {
|
||||
</div>
|
||||
</div>
|
||||
{order.status === OrderStatus.COMPLETED && (
|
||||
<Link href={`rate/${order.id}?foodId=${item.food.id}`}>
|
||||
<Link href={`rate/${order.id}?foodId=${item.variant?.product.id}`}>
|
||||
<Button className='text-xs px-3 py-2 h-auto'>{t('Card.Rate')}</Button>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { api } from "@/config/axios";
|
||||
import { OrdersResponse } from "../types/Types";
|
||||
import { OrderStatus } from "../enum/Enum";
|
||||
import { OrderStatus } from "@/app/[name]/(Dialogs)/order/checkout/enum/Enum";
|
||||
|
||||
export const getOrders = async (
|
||||
status: "old" | "current"
|
||||
status: "old" | "current",
|
||||
): Promise<OrdersResponse> => {
|
||||
const statuses =
|
||||
status === "old"
|
||||
@@ -12,10 +12,9 @@ export const getOrders = async (
|
||||
OrderStatus.PENDING_PAYMENT,
|
||||
OrderStatus.PAID,
|
||||
OrderStatus.PREPARING,
|
||||
OrderStatus.DELIVERED_TO_WAITER,
|
||||
OrderStatus.DELIVERED_TO_RECEPTIONIST,
|
||||
OrderStatus.SHIPPED,
|
||||
OrderStatus.COMPLETED,
|
||||
OrderStatus.DELIVERED_TO_RECEPIENT,
|
||||
];
|
||||
|
||||
const { data } = await api.get<OrdersResponse>(`/public/orders`, {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseResponse } from "@/app/[name]/(Main)/types/Types";
|
||||
import { BaseResponse, Product } from "@/app/[name]/(Main)/types/Types";
|
||||
import { ServiceArea } from "@/app/[name]/(Dialogs)/order/checkout/types/Types";
|
||||
|
||||
export interface HistoryOrderUser {
|
||||
@@ -8,13 +8,13 @@ export interface HistoryOrderUser {
|
||||
deletedAt: string | null;
|
||||
firstName: string;
|
||||
lastName: string | null;
|
||||
phone: string;
|
||||
birthDate: string | null;
|
||||
marriageDate: string | null;
|
||||
referrer: string | null;
|
||||
isActive: boolean;
|
||||
gender: boolean;
|
||||
avatarUrl: string | null;
|
||||
phone: string;
|
||||
}
|
||||
|
||||
export interface HistoryOrderRestaurantScore {
|
||||
@@ -28,7 +28,7 @@ export interface HistoryOrderRestaurantScore {
|
||||
marriageDateScore: string;
|
||||
}
|
||||
|
||||
export interface HistoryOrderRestaurant {
|
||||
export interface HistoryOrderShop {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -55,7 +55,6 @@ export interface HistoryOrderRestaurant {
|
||||
vat: number;
|
||||
domain: string;
|
||||
score: HistoryOrderRestaurantScore;
|
||||
plan: string;
|
||||
subscriptionId: string;
|
||||
subscriptionEndDate: string;
|
||||
subscriptionStartDate: string;
|
||||
@@ -66,8 +65,8 @@ export interface HistoryOrderDeliveryMethod {
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
method: "dineIn" | "pickup" | "deliveryCar" | "deliveryCourier";
|
||||
restaurant: string;
|
||||
method: string;
|
||||
shop: string;
|
||||
deliveryFee: number;
|
||||
deliveryFeeType: string;
|
||||
perKilometerFee: number | null;
|
||||
@@ -89,30 +88,13 @@ export interface HistoryOrderUserAddress {
|
||||
postalCode: string;
|
||||
}
|
||||
|
||||
export interface HistoryOrderAddress {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
user: string;
|
||||
title: string;
|
||||
address: string;
|
||||
city: string;
|
||||
province: string;
|
||||
postalCode: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
phone: string;
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
export interface HistoryOrderPaymentMethod {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
restaurant: string;
|
||||
method: "CardOnDelivery" | "Cash" | "Online" | "Wallet";
|
||||
shop: string;
|
||||
method: string;
|
||||
gateway: string | null;
|
||||
description: string;
|
||||
enabled: boolean;
|
||||
@@ -120,28 +102,14 @@ export interface HistoryOrderPaymentMethod {
|
||||
merchantId: string | null;
|
||||
}
|
||||
|
||||
export interface HistoryOrderFood {
|
||||
export interface HistoryOrderVariant {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
restaurant: string;
|
||||
category: string;
|
||||
title: string;
|
||||
desc: string | null;
|
||||
content: string | null;
|
||||
value: string;
|
||||
price: number;
|
||||
order: number | null;
|
||||
prepareTime: number | null;
|
||||
weekDays: number[];
|
||||
mealTypes: ("breakfast" | "lunch" | "dinner" | "snack")[];
|
||||
isActive: boolean;
|
||||
images: string[] | null;
|
||||
inPlaceServe: boolean;
|
||||
pickupServe: boolean;
|
||||
score: number;
|
||||
discount: number;
|
||||
isSpecialOffer: boolean;
|
||||
product: Product;
|
||||
}
|
||||
|
||||
export interface HistoryOrderItem {
|
||||
@@ -150,7 +118,7 @@ export interface HistoryOrderItem {
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
order: string;
|
||||
food: HistoryOrderFood;
|
||||
variant: HistoryOrderVariant;
|
||||
quantity: number;
|
||||
unitPrice: number;
|
||||
discount: number;
|
||||
@@ -168,10 +136,9 @@ export interface HistoryOrder {
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
user: HistoryOrderUser;
|
||||
restaurant: HistoryOrderRestaurant;
|
||||
shop: HistoryOrderShop;
|
||||
deliveryMethod: HistoryOrderDeliveryMethod;
|
||||
userAddress: HistoryOrderUserAddress | null;
|
||||
carAddress: HistoryOrderUserAddress | null;
|
||||
paymentMethod: HistoryOrderPaymentMethod;
|
||||
orderNumber: number;
|
||||
couponDiscount: number;
|
||||
@@ -184,7 +151,6 @@ export interface HistoryOrder {
|
||||
total: number;
|
||||
totalItems: number;
|
||||
description: string;
|
||||
tableNumber: string | null;
|
||||
status: string;
|
||||
history: HistoryOrderHistoryItem[];
|
||||
items: HistoryOrderItem[];
|
||||
@@ -197,12 +163,6 @@ export interface OrdersResponseMeta {
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
export interface OrdersResponseData {
|
||||
data: HistoryOrder[];
|
||||
meta: OrdersResponseMeta;
|
||||
}
|
||||
|
||||
export type OrdersResponse = BaseResponse<HistoryOrder[]> & {
|
||||
meta?: OrdersResponseMeta;
|
||||
meta: OrdersResponseMeta;
|
||||
};
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ type MenuItemType = {
|
||||
const menuItems: Array<Array<MenuItemType>> = [
|
||||
[
|
||||
{ href: 'notifications', title: 'Notifications', icon: Notification },
|
||||
{ href: 'transactions/discount/club', title: 'CustomerClub', icon: Cup, premiumOnly: true },
|
||||
{ href: 'transactions/discount', title: 'Discounts', icon: TicketDiscount, premiumOnly: true },
|
||||
{ href: 'order/history', title: 'Orders', icon: CalendarSearch, premiumOnly: true },
|
||||
{ href: 'transactions', title: 'Transactions', icon: Receipt1, premiumOnly: true },
|
||||
{ href: 'transactions/discount/club', title: 'CustomerClub', icon: Cup, premiumOnly: false },
|
||||
{ href: 'transactions/discount', title: 'Discounts', icon: TicketDiscount, premiumOnly: false },
|
||||
{ href: 'order/history', title: 'Orders', icon: CalendarSearch, premiumOnly: false },
|
||||
{ href: 'transactions', title: 'Transactions', icon: Receipt1, premiumOnly: false },
|
||||
{ href: 'game', title: 'Games', icon: Game },
|
||||
{ href: '?share', title: 'ShareWithFriends', icon: Like1 },
|
||||
{ href: 'report', title: 'ReportProblem', icon: NoteBoardIcon },
|
||||
|
||||
Reference in New Issue
Block a user