Skip to content

Commit

Permalink
✨ get Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
DuvCharles committed Nov 14, 2023
1 parent 452ae5f commit 01d0e34
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/sylius/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { REST_METHODS, SYLIUS_API_ENDPOINT } from 'lib/constants';
import { normalizeCollection } from './normalizer/collection-normalizer';
import { normalizeProduct } from './normalizer/product-normalizer';
import { SyliusProduct, SyliusTaxon } from './sylius-types/product-types';
import { AddToCartPayload, GetCollectionProductsPayload, GetProductsPayload } from './types';
import { AddToCartPayload, Collection, GetCollectionProductsPayload, GetProductsPayload } from './types';

const DOMAIN = `${process.env.SYLIUS_STORE_DOMAIN}`;
const ENDPOINT = `${DOMAIN}${SYLIUS_API_ENDPOINT}`;
Expand Down Expand Up @@ -93,7 +93,7 @@ export const getProduct = async (slug: string) => {
export const getProductRecommendations = () => {
return [];
};
export const getCollections = async () => {
export const getCollections = async (): Promise<Collection[]> => {
const data = await syliusRequest(REST_METHODS.GET, '/taxons');

const syliusTaxons = data.body;
Expand Down Expand Up @@ -162,9 +162,18 @@ export const removeFromCart = () => {};
export const updateCart = () => {};

// Site
export const getMenu = () => [
{
export const getMenu = async () => {
const collections = await getCollections();
const menuTabs = [];
menuTabs.push({
title: 'All',
path: '/search'
}
];
});
collections.slice(0,2).forEach((collection) => {
menuTabs.push({
title: collection.title,
path: collection.path
});
});
return menuTabs;
};

0 comments on commit 01d0e34

Please sign in to comment.