import { Collection, Product } from "./types"; const products: Product[] = [ { id: "1", handle: "kinaskak-blokk", availableForSale: true, title: "Kínaskák stigatafla", description: "50 blaða Kínaskák stigatafla sem rifblokk", descriptionHtml: "

50 blaða Kínaskák stigatafla sem rifblokk

", options: [ { id: "default", name: "Default", values: ["Default"], }, ], priceRange: { maxVariantPrice: { amount: "2499", currencyCode: "ISK", }, minVariantPrice: { amount: "2499", currencyCode: "ISK", }, }, variants: [ { id: "default", title: "Kínaskák stigatafla", availableForSale: true, selectedOptions: [{ name: "Default", value: "Default" }], price: { amount: "2499", currencyCode: "ISK", }, }, ], featuredImage: { source: { type: "static", path: "/images/products/kinaskak.png", }, altText: "Kínaskák stigatafla", }, images: [ { source: { type: "static", path: "/images/products/kinaskak.png", }, altText: "Kínaskák stigatafla", }, { source: { type: "static", path: "/images/products/kinaskak-back.jpg", }, altText: "Kínaskák stigatafla - Bakhlið", }, ], seo: { title: "Kínaskák stigatafla", description: "50 blaða Kínaskák stigatafla sem rifblokk", }, tags: ["jacket", "leather", "classic"], updatedAt: new Date().toISOString(), }, ]; const collections: Collection[] = [ { handle: "jackets", title: "Jackets", description: "Our collection of premium jackets", seo: { title: "Jackets Collection", description: "Explore our premium collection of jackets", }, updatedAt: new Date().toISOString(), }, ]; export const getProduct = ({ handle, }: { handle: string; }): Promise => { return Promise.resolve(products.find((p) => p.handle === handle)); }; export const getProducts = ({ query, reverse, sortKey, }: { query?: string; reverse?: boolean; sortKey?: string; } = {}): Promise => { let filteredProducts = [...products]; if (query) { const searchQuery = query.toLowerCase(); filteredProducts = filteredProducts.filter( (product) => product.title.toLowerCase().includes(searchQuery) || product.description.toLowerCase().includes(searchQuery) ); } if (sortKey) { filteredProducts.sort((a, b) => { switch (sortKey) { case "TITLE": return reverse ? b.title.localeCompare(a.title) : a.title.localeCompare(b.title); case "PRICE": return reverse ? parseFloat(b.priceRange.minVariantPrice.amount) - parseFloat(a.priceRange.minVariantPrice.amount) : parseFloat(a.priceRange.minVariantPrice.amount) - parseFloat(b.priceRange.minVariantPrice.amount); case "CREATED_AT": return reverse ? new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime() : new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime(); default: return 0; } }); } return Promise.resolve(filteredProducts); }; export const getProductRecommendations = ({ productId, }: { productId: string; }): Promise => { // For now, just return other products excluding the current one return Promise.resolve(products.filter((p) => p.id !== productId)); }; export const getCollectionProducts = ({ collection, sortKey, reverse, }: { collection: string; sortKey?: string; reverse?: boolean; }): Promise => { // For now, return all products since we don't have collection associations return getProducts({ sortKey, reverse }); }; export const getCollections = (): Promise => { return Promise.resolve(collections); };