feat(MED-100): partner location metadata stored on order line instead of order
This commit is contained in:
@@ -73,11 +73,12 @@ const handleOrderToken = async (orderToken: string) => {
|
||||
}
|
||||
const { productTypes } = await listProductTypes();
|
||||
const analysisPackagesType = productTypes.find(({ metadata }) => metadata?.handle === 'analysis-packages');
|
||||
const { order } = await placeOrder(cartId, { revalidateCacheTags: true });
|
||||
const order = await placeOrder(cartId, { revalidateCacheTags: true });
|
||||
const analysisPackageOrderItem = order.items?.find(({ product_type_id }) => product_type_id === analysisPackagesType?.id);
|
||||
return {
|
||||
email: order.email,
|
||||
partnerLocationName: order.metadata?.partner_location_name as string ?? '',
|
||||
analysisPackageName: order.items?.find(item => item.product_type_id === analysisPackagesType?.id)?.title ?? '',
|
||||
partnerLocationName: analysisPackageOrderItem?.metadata?.partner_location_name as string ?? '',
|
||||
analysisPackageName: analysisPackageOrderItem?.title ?? '',
|
||||
};
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to place order, message=${error}`);
|
||||
@@ -105,8 +106,10 @@ export async function GET(request: Request) {
|
||||
|
||||
const { email, partnerLocationName, analysisPackageName } = orderResult;
|
||||
const personName = account.name;
|
||||
if (email && analysisPackageName && partnerLocationName) {
|
||||
if (email && analysisPackageName) {
|
||||
await sendEmail({ email, analysisPackageName, personName, partnerLocationName, language });
|
||||
} else {
|
||||
console.error("Missing email or analysisPackageName", orderResult);
|
||||
}
|
||||
return Response.redirect(new URL('/home/order', baseUrl))
|
||||
} catch (error) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { notFound } from 'next/navigation';
|
||||
import { retrieveOrder } from '~/medusa/lib/data/orders';
|
||||
import { createI18nServerInstance } from '@/lib/i18n/i18n.server';
|
||||
import OrderCompleted from '@/app/home/(user)/_components/order/order-completed';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ orderId: string }>;
|
||||
@@ -16,7 +17,7 @@ export async function generateMetadata() {
|
||||
};
|
||||
}
|
||||
|
||||
export default async function OrderConfirmedPage(props: Props) {
|
||||
async function OrderConfirmedPage(props: Props) {
|
||||
const params = await props.params;
|
||||
const order = await retrieveOrder(params.orderId).catch(() => null);
|
||||
|
||||
@@ -26,3 +27,5 @@ export default async function OrderConfirmedPage(props: Props) {
|
||||
|
||||
return <OrderCompleted order={order} />;
|
||||
}
|
||||
|
||||
export default withI18n(OrderConfirmedPage);
|
||||
|
||||
Reference in New Issue
Block a user