"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 // 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); 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); createAppLog(L_INFO, 'Get order detail OK', debug);
return response({ order }, STATUS.OK); return response({ partyOrder }, STATUS.OK);
} catch (error) { } catch (error) {
createAppLog(L_ERROR, 'order detail error', debug); createAppLog(L_ERROR, 'order detail error', debug);

View File

@@ -1,7 +1,7 @@
### ###
# Get details for a specific party order # 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, partyOrderLoading: isLoading,
partyOrderError: error, partyOrderError: error,
partyOrderValidating: isValidating, partyOrderValidating: isValidating,
mutate,
}), }),
[data?.partyOrder, error, isLoading, isValidating] [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: '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', title: 'Product',
path: paths.dashboard.product.root, path: paths.dashboard.product.root,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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