feat(MED-100): update cart checkout flow and views

This commit is contained in:
2025-07-17 10:16:52 +03:00
parent ea3fb22f1d
commit 6426e2a79b
33 changed files with 1505 additions and 138 deletions

View File

@@ -0,0 +1,36 @@
import { cache } from 'react';
import { listCollections, listProducts, listRegions } from "@lib/data";
async function countryCodesLoader() {
const countryCodes = await listRegions().then((regions) =>
regions?.map((r) => r.countries?.map((c) => c.iso_2)).flat(),
);
return countryCodes ?? [];
}
export const loadCountryCodes = cache(countryCodesLoader);
async function collectionsLoader() {
const { collections } = await listCollections({
fields: 'id, handle',
});
return collections ?? [];
}
export const loadCollections = cache(collectionsLoader);
async function analysisPackagesLoader() {
const [countryCodes, collections] = await Promise.all([loadCountryCodes(), loadCollections()]);
const countryCode = countryCodes[0]!;
const collection = collections.find(({ handle }) => handle === 'analysis-packages');
if (!collection) {
return { analysisPackages: [], countryCode };
}
const { response } = await listProducts({
countryCode,
queryParams: { limit: 100, collection_id: collection?.id },
});
return { analysisPackages: response.products, countryCode };
}
export const loadAnalysisPackages = cache(analysisPackagesLoader);