update order
This commit is contained in:
@@ -1,20 +1,31 @@
|
||||
import { cache } from 'react';
|
||||
|
||||
import { getProductCategories, listProducts } from '@lib/data';
|
||||
import {
|
||||
getProductCategories,
|
||||
listProductTypes,
|
||||
listProducts,
|
||||
} from '@lib/data';
|
||||
|
||||
import { findProductTypeIdByHandle } from '~/lib/utils';
|
||||
|
||||
import { isPaymentRequiredForService } from './actions';
|
||||
import { loadCountryCodes } from './load-analyses';
|
||||
|
||||
async function categoryLoader({ handle }: { handle: string }) {
|
||||
const [response, countryCodes] = await Promise.all([
|
||||
const [response, countryCodes, { productTypes }] = await Promise.all([
|
||||
getProductCategories({
|
||||
handle,
|
||||
limit: 1,
|
||||
}),
|
||||
loadCountryCodes(),
|
||||
listProductTypes(),
|
||||
]);
|
||||
const category = response.product_categories[0];
|
||||
const countryCode = countryCodes[0]!;
|
||||
const ttoServiceTypeId = findProductTypeIdByHandle(
|
||||
productTypes,
|
||||
'tto-service',
|
||||
);
|
||||
|
||||
if (!response.product_categories?.[0]?.id) {
|
||||
return { category: null };
|
||||
@@ -29,6 +40,9 @@ async function categoryLoader({ handle }: { handle: string }) {
|
||||
|
||||
const productsWithNoRequiredPayment = categoryProducts.filter(
|
||||
async (product) => {
|
||||
if (product.type_id !== ttoServiceTypeId) {
|
||||
return false;
|
||||
}
|
||||
if (product.metadata?.serviceIds) {
|
||||
const serviceIds: number[] = JSON.parse(
|
||||
product.metadata.serviceIds as string,
|
||||
|
||||
Reference in New Issue
Block a user