This commit is contained in:
Henrik Larsson
2023-08-08 11:46:46 +02:00
parent 6527974989
commit 3e513eaf99
27 changed files with 449 additions and 760 deletions

View File

@@ -1,25 +0,0 @@
export type SortFilterItem = {
title: string;
slug: string | null;
sortKey: 'RELEVANCE' | 'BEST_SELLING' | 'CREATED_AT' | 'PRICE';
reverse: boolean;
};
export const defaultSort: SortFilterItem = {
title: 'Relevance',
slug: null,
sortKey: 'RELEVANCE',
reverse: false
};
export const sorting: SortFilterItem[] = [
defaultSort,
{ title: 'Trending', slug: 'trending-desc', sortKey: 'BEST_SELLING', reverse: false }, // asc
{ title: 'Latest arrivals', slug: 'latest-desc', sortKey: 'CREATED_AT', reverse: true },
{ title: 'Price: Low to high', slug: 'price-asc', sortKey: 'PRICE', reverse: false }, // asc
{ title: 'Price: High to low', slug: 'price-desc', sortKey: 'PRICE', reverse: true }
];
export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden';
export const DEFAULT_OPTION = 'Default Title';
export const SHOPIFY_GRAPHQL_API_ENDPOINT = '/api/2023-01/graphql.json';

View File

@@ -147,61 +147,6 @@ export interface Product {
locale?: string
}
export interface SearchProductsBody {
/**
* The search query string to filter the products by.
*/
search?: string
/**
* The category ID to filter the products by.
*/
categoryId?: string
/**
* The brand ID to filter the products by.
*/
brandId?: string
/**
* The sort key to sort the products by.
* @example 'trending-desc' | 'latest-desc' | 'price-asc' | 'price-desc'
*/
sort?: string
/**
* The locale code, used to localize the product data (if the provider supports it).
*/
locale?: string
}
/**
* Fetches a list of products based on the given search criteria.
*/
export type SearchProductsHook = {
data: {
/**
* List of products matching the query.
*/
products: Product[]
/**
* Indicates if there are any products matching the query.
*/
found: boolean
}
body: SearchProductsBody
input: SearchProductsBody
fetcherInput: SearchProductsBody
}
/**
* Product API schema
*/
export type ProductsSchema = {
endpoint: {
options: {}
handlers: {
getProducts: SearchProductsHook
}
}
}
/**
* Product operations