feat(MED-87): improve naming
This commit is contained in:
@@ -10,7 +10,7 @@ import { HomeLayoutPageHeader } from '../../_components/home-page-header';
|
||||
import OrdersTable from '../../_components/orders/orders-table';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
import type { IOrderLineItem } from '../../_components/orders/types';
|
||||
import { getOrders } from '~/lib/services/order.service';
|
||||
import { getAnalysisOrders } from '~/lib/services/order.service';
|
||||
|
||||
export async function generateMetadata() {
|
||||
const { t } = await createI18nServerInstance();
|
||||
@@ -21,19 +21,19 @@ export async function generateMetadata() {
|
||||
}
|
||||
|
||||
async function OrdersPage() {
|
||||
const orders = await listOrders();
|
||||
const localOrders = await getOrders();
|
||||
const medusaOrders = await listOrders();
|
||||
const analysisOrders = await getAnalysisOrders();
|
||||
const { productTypes } = await listProductTypes();
|
||||
|
||||
if (!orders || !productTypes) {
|
||||
if (!medusaOrders || !productTypes) {
|
||||
redirect(pathsConfig.auth.signIn);
|
||||
}
|
||||
|
||||
const analysisPackagesType = productTypes.find(({ metadata }) => metadata?.handle === 'analysis-packages');
|
||||
const analysisPackageOrders: IOrderLineItem[] = orders.flatMap(({ id, items, payment_status, fulfillment_status }) => items
|
||||
const analysisPackageOrders: IOrderLineItem[] = medusaOrders.flatMap(({ id, items, payment_status, fulfillment_status }) => items
|
||||
?.filter((item) => item.product_type_id === analysisPackagesType?.id)
|
||||
.map((item) => {
|
||||
const localOrder = localOrders.find((order) => order.medusa_order_id === id);
|
||||
const localOrder = analysisOrders.find((order) => order.medusa_order_id === id);
|
||||
if (!localOrder) {
|
||||
return null;
|
||||
}
|
||||
@@ -48,19 +48,19 @@ async function OrdersPage() {
|
||||
.filter((order) => order !== null)
|
||||
|| []);
|
||||
|
||||
const otherOrders: IOrderLineItem[] = orders
|
||||
const otherOrders: IOrderLineItem[] = medusaOrders
|
||||
.filter(({ items }) => items?.some((item) => item.product_type_id !== analysisPackagesType?.id))
|
||||
.flatMap(({ id, items, payment_status, fulfillment_status }) => items
|
||||
?.map((item) => {
|
||||
const localOrder = localOrders.find((order) => order.medusa_order_id === id);
|
||||
if (!localOrder) {
|
||||
const analysisOrder = analysisOrders.find((order) => order.medusa_order_id === id);
|
||||
if (!analysisOrder) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
item,
|
||||
medusaOrderId: id,
|
||||
orderId: localOrder.id,
|
||||
orderStatus: localOrder.status,
|
||||
orderId: analysisOrder.id,
|
||||
orderStatus: analysisOrder.status,
|
||||
}
|
||||
})
|
||||
.filter((order) => order !== null)
|
||||
|
||||
Reference in New Issue
Block a user