MED-104: create booking view with categories
This commit is contained in:
@@ -42,7 +42,7 @@ async function analysesLoader() {
|
||||
const serviceCategories = productCategories.filter(
|
||||
({ parent_category }) => parent_category?.handle === 'tto-categories',
|
||||
);
|
||||
console.log('serviceCategories', serviceCategories);
|
||||
|
||||
return {
|
||||
analyses:
|
||||
category?.products?.map<OrderAnalysisCard>(
|
||||
|
||||
31
app/home/(user)/_lib/server/load-category.ts
Normal file
31
app/home/(user)/_lib/server/load-category.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { cache } from 'react';
|
||||
|
||||
import { getProductCategories } from '@lib/data';
|
||||
|
||||
import { ServiceCategory } from '../../_components/service-categories';
|
||||
|
||||
async function categoryLoader({
|
||||
handle,
|
||||
}: {
|
||||
handle: string;
|
||||
}): Promise<{ category: ServiceCategory | null }> {
|
||||
const response = await getProductCategories({
|
||||
handle,
|
||||
fields: '*products, is_active, metadata',
|
||||
});
|
||||
|
||||
const category = response.product_categories[0];
|
||||
|
||||
return {
|
||||
category: {
|
||||
color:
|
||||
typeof category?.metadata?.color === 'string'
|
||||
? category?.metadata?.color
|
||||
: 'primary',
|
||||
description: category?.description || '',
|
||||
handle: category?.handle || '',
|
||||
name: category?.name || '',
|
||||
},
|
||||
};
|
||||
}
|
||||
export const loadCategory = cache(categoryLoader);
|
||||
@@ -8,7 +8,7 @@ async function ttoServicesLoader() {
|
||||
const response = await getProductCategories({
|
||||
fields: '*products, is_active, metadata',
|
||||
});
|
||||
console.log('response.product_categories', response.product_categories);
|
||||
|
||||
const heroCategories = response.product_categories?.filter(
|
||||
({ parent_category, is_active, metadata }) =>
|
||||
parent_category?.handle === 'tto-categories' &&
|
||||
|
||||
Reference in New Issue
Block a user