"fix: update party order details route variable naming and test case ID"

This commit is contained in:
louiscklaw
2025-06-16 00:35:17 +08:00
parent db16b2d5dd
commit 8d52be9b96
15 changed files with 1778 additions and 51 deletions

View File

@@ -37,17 +37,17 @@ export async function GET(req: NextRequest) {
}
// NOTE: partyOrderId confirmed exist, run below
const order = await getOrder(partyOrderId);
const partyOrder = await getOrder(partyOrderId);
if (!order) {
if (!partyOrder) {
return response({ message: 'Order not found!' }, STATUS.NOT_FOUND);
}
logger('[PartyOrder] details', order.id);
logger('[PartyOrder] details', partyOrder.id);
createAppLog(L_INFO, 'Get order detail OK', debug);
return response({ order }, STATUS.OK);
return response({ partyOrder }, STATUS.OK);
} catch (error) {
createAppLog(L_ERROR, 'order detail error', debug);

View File

@@ -1,7 +1,7 @@
###
# Get details for a specific party order
GET http://localhost:7272/api/party-order/details?partyOrderId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b02
GET http://localhost:7272/api/party-order/details?partyOrderId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b13
###

File diff suppressed because it is too large Load Diff

View File

@@ -60,7 +60,6 @@ export function useGetPartyOrder(partyOrderId: string) {
partyOrderLoading: isLoading,
partyOrderError: error,
partyOrderValidating: isValidating,
mutate,
}),
[data?.partyOrder, error, isLoading, isValidating]
);

View File

@@ -102,6 +102,15 @@ export const navData: NavSectionProps['data'] = [
{ title: 'Edit', path: paths.dashboard.partyEvent.demo.edit },
],
},
{
title: 'party-order',
path: paths.dashboard.partyOrder.root,
icon: ICONS.order,
children: [
{ title: 'List', path: paths.dashboard.partyOrder.root },
{ title: 'Details', path: paths.dashboard.partyOrder.demo.details },
],
},
{
title: 'Product',
path: paths.dashboard.product.root,

View File

@@ -1,10 +1,9 @@
// src/pages/dashboard/order/details.tsx
//
import { _orders } from 'src/_mock/_order';
import { useGetOrder } from 'src/actions/order';
import { useGetPartyOrder } from 'src/actions/party-order';
import { CONFIG } from 'src/global-config';
import { useParams } from 'src/routes/hooks';
import { OrderDetailsView } from 'src/sections/order/view';
import { PartyOrderDetailsView } from 'src/sections/party-order/view';
// ----------------------------------------------------------------------
@@ -15,16 +14,15 @@ export default function Page() {
// const currentOrder = _orders.find((order) => order.id === id);
// TODO: error handling
const { order, orderLoading, orderError } = useGetOrder(id);
const { partyOrder, partyOrderLoading, partyOrderError } = useGetPartyOrder(id);
if (!order) return <>loading</>;
if (orderLoading) return <>loading</>;
if (!partyOrder) return <></>;
return (
<>
<title>{metadata.title}</title>
<OrderDetailsView order={order} />
<PartyOrderDetailsView partyOrder={partyOrder} />
</>
);
}

View File

@@ -14,7 +14,7 @@ type Props = {
customer?: IOrderCustomer;
};
export function OrderDetailsCustomer({ customer }: Props) {
export function PartyOrderDetailsCustomer({ customer }: Props) {
return (
<>
<CardHeader

View File

@@ -13,7 +13,7 @@ type Props = {
delivery?: IOrderDelivery;
};
export function OrderDetailsDelivery({ delivery }: Props) {
export function PartyOrderDetailsDelivery({ delivery }: Props) {
const { t } = useTranslation();
return (
<>

View File

@@ -20,7 +20,7 @@ type Props = {
history?: IOrderHistory;
};
export function OrderDetailsHistory({ history }: Props) {
export function PartyOrderDetailsHistory({ history }: Props) {
const { t } = useTranslation();
const renderSummary = () => (

View File

@@ -22,7 +22,7 @@ type Props = CardProps & {
items?: IOrderProductItem[];
};
export function OrderDetailsItems({
export function PartyOrderDetailsItems({
sx,
taxes,
shipping,

View File

@@ -10,7 +10,7 @@ type Props = {
payment?: IOrderPayment;
};
export function OrderDetailsPayment({ payment }: Props) {
export function PartyOrderDetailsPayment({ payment }: Props) {
return (
<>
<CardHeader

View File

@@ -11,7 +11,7 @@ type Props = {
shippingAddress?: IOrderShippingAddress;
};
export function OrderDetailsShipping({ shippingAddress }: Props) {
export function PartyOrderDetailsShipping({ shippingAddress }: Props) {
return (
<>
<CardHeader

View File

@@ -27,7 +27,7 @@ type Props = {
statusOptions: { value: string; label: string }[];
};
export function OrderDetailsToolbar({
export function PartyOrderDetailsToolbar({
status,
backHref,
createdAt,

View File

@@ -1,5 +1,5 @@
// src/sections/order/view/order-details-view.tsx
//
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import Divider from '@mui/material/Divider';
@@ -13,32 +13,32 @@ import { DashboardContent } from 'src/layouts/dashboard';
import { useTranslate } from 'src/locales';
import { paths } from 'src/routes/paths';
import type { IPartyOrderItem } from 'src/types/party-order';
import { OrderDetailsCustomer } from '../party-order-details-customer';
import { OrderDetailsDelivery } from '../party-order-details-delivery';
import { OrderDetailsHistory } from '../party-order-details-history';
import { OrderDetailsItems } from '../party-order-details-items';
import { OrderDetailsPayment } from '../party-order-details-payment';
import { OrderDetailsShipping } from '../party-order-details-shipping';
import { OrderDetailsToolbar } from '../party-order-details-toolbar';
import { PartyOrderDetailsCustomer } from '../party-order-details-customer';
import { PartyOrderDetailsDelivery } from '../party-order-details-delivery';
import { PartyOrderDetailsHistory } from '../party-order-details-history';
import { PartyOrderDetailsItems } from '../party-order-details-items';
import { PartyOrderDetailsPayment } from '../party-order-details-payment';
import { PartyOrderDetailsShipping } from '../party-order-details-shipping';
import { PartyOrderDetailsToolbar } from '../party-order-details-toolbar';
// ----------------------------------------------------------------------
type Props = {
order: IPartyOrderItem;
partyOrder: IPartyOrderItem;
};
export function OrderDetailsView({ order }: Props) {
export function PartyOrderDetailsView({ partyOrder }: Props) {
const { t } = useTranslation();
const [status, setStatus] = useState(order.status);
const [status, setStatus] = useState(partyOrder.status);
const handleChangeStatus = useCallback(
async (newValue: string) => {
setStatus(newValue);
// change order status
try {
if (order?.id) {
await changeStatus(order.id, newValue);
if (partyOrder?.id) {
await changeStatus(partyOrder.id, newValue);
toast.success('order status updated');
}
@@ -47,16 +47,16 @@ export function OrderDetailsView({ order }: Props) {
toast.warning('error during update order status');
}
},
[order.id]
[partyOrder.id]
);
return (
<DashboardContent>
<OrderDetailsToolbar
<PartyOrderDetailsToolbar
status={status}
createdAt={order?.createdAt}
orderNumber={order?.orderNumber}
backHref={paths.dashboard.order.root}
createdAt={partyOrder?.createdAt}
orderNumber={partyOrder?.orderNumber}
backHref={paths.dashboard.partyOrder.root}
onChangeStatus={handleChangeStatus}
statusOptions={ORDER_STATUS_OPTIONS}
/>
@@ -71,31 +71,31 @@ export function OrderDetailsView({ order }: Props) {
flexDirection: { xs: 'column-reverse', md: 'column' },
}}
>
<OrderDetailsItems
items={order?.items}
taxes={order?.taxes}
shipping={order?.shipping}
discount={order?.discount}
subtotal={order?.subtotal}
totalAmount={order?.totalAmount}
<PartyOrderDetailsItems
items={partyOrder?.items}
taxes={partyOrder?.taxes}
shipping={partyOrder?.shipping}
discount={partyOrder?.discount}
subtotal={partyOrder?.subtotal}
totalAmount={partyOrder?.totalAmount}
/>
<OrderDetailsHistory history={order?.history} />
<PartyOrderDetailsHistory history={partyOrder?.history} />
</Box>
</Grid>
<Grid size={{ xs: 12, md: 4 }}>
<Card>
<OrderDetailsCustomer customer={order?.customer} />
<PartyOrderDetailsCustomer customer={partyOrder?.customer} />
<Divider sx={{ borderStyle: 'dashed' }} />
<OrderDetailsDelivery delivery={order?.delivery} />
<PartyOrderDetailsDelivery delivery={partyOrder?.delivery} />
<Divider sx={{ borderStyle: 'dashed' }} />
<OrderDetailsShipping shippingAddress={order?.shippingAddress} />
<PartyOrderDetailsShipping shippingAddress={partyOrder?.shippingAddress} />
<Divider sx={{ borderStyle: 'dashed' }} />
<OrderDetailsPayment payment={order?.payment} />
<PartyOrderDetailsPayment payment={partyOrder?.payment} />
</Card>
</Grid>
</Grid>

View File

@@ -283,7 +283,7 @@ export function PartyOrderListView() {
selected={table.selected.includes(row.id)}
onSelectRow={() => table.onSelectRow(row.id)}
onDeleteRow={() => handleDeleteRow(row.id)}
detailsHref={paths.dashboard.order.details(row.id)}
detailsHref={paths.dashboard.partyOrder.details(row.id)}
/>
))}