Adding more to the Local Provider (#366)
* Adding more data * Adding more data
@ -17,9 +17,9 @@ export default function getAllProductsOperation({
|
|||||||
config?: Partial<LocalConfig>
|
config?: Partial<LocalConfig>
|
||||||
preview?: boolean
|
preview?: boolean
|
||||||
} = {}): Promise<{ products: Product[] | any[] }> {
|
} = {}): Promise<{ products: Product[] | any[] }> {
|
||||||
return Promise.resolve({
|
return {
|
||||||
products: data.products,
|
products: data.products,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
return getAllProducts
|
return getAllProducts
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export type Page = any
|
export type Page = any
|
||||||
export type GetPageResult = { page?: Page }
|
export type GetPageResult = { page?: Page }
|
||||||
|
|
||||||
export type PageVariables = {
|
export type PageVariables = {
|
||||||
id: number
|
id: number
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ export default function getProductOperation({
|
|||||||
config?: Partial<LocalConfig>
|
config?: Partial<LocalConfig>
|
||||||
preview?: boolean
|
preview?: boolean
|
||||||
} = {}): Promise<Product | {} | any> {
|
} = {}): Promise<Product | {} | any> {
|
||||||
return Promise.resolve({
|
return {
|
||||||
product: data.products[0],
|
product: data.products.find(({ slug }) => slug === variables!.slug),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getProduct
|
return getProduct
|
||||||
|
@ -21,7 +21,20 @@ export default function getSiteInfoOperation({}: OperationContext<any>) {
|
|||||||
preview?: boolean
|
preview?: boolean
|
||||||
} = {}): Promise<GetSiteInfoResult> {
|
} = {}): Promise<GetSiteInfoResult> {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
categories: [],
|
categories: [
|
||||||
|
{
|
||||||
|
id: 'new-arrivals',
|
||||||
|
name: 'New Arrivals',
|
||||||
|
slug: 'new-arrivals',
|
||||||
|
path: '/new-arrivals',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'featured',
|
||||||
|
name: 'Featured',
|
||||||
|
slug: 'featured',
|
||||||
|
path: '/featured',
|
||||||
|
},
|
||||||
|
],
|
||||||
brands: [],
|
brands: [],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -80,42 +80,54 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
|
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9ksdWN0LzU0NDczMjUwMjQ0MjA=",
|
||||||
"name": "New Short Sleeve T-Shirt",
|
"name": "Lightweight Jacket",
|
||||||
"vendor": "Next.js",
|
"vendor": "Next.js",
|
||||||
"path": "/new-short-sleeve-t-shirt",
|
"path": "/lightweight-jacket",
|
||||||
"slug": "new-short-sleeve-t-shirt",
|
"slug": "lightweight-jacket",
|
||||||
"price": { "value": 25, "currencyCode": "USD" },
|
"price": { "value": 249.99, "currencyCode": "USD" },
|
||||||
"descriptionHtml": "<p><span>Show off your love for Next.js and Vercel with this unique, </span><strong>limited edition</strong><span> t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made! </span><strong>All proceeds will be donated to charity.</strong></p>",
|
"descriptionHtml": "<p><span>Show off your love for Next.js and Vercel with this unique, </span><strong>limited edition</strong><span> t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made! </span><strong>All proceeds will be donated to charity.</strong></p>",
|
||||||
"images": [
|
"images": [
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-0.png",
|
"url": "/assets/lightweight-jacket-0.png",
|
||||||
"altText": "Shirt",
|
"altText": "Lightweight Jacket",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-1.png",
|
"url": "/assets/lightweight-jacket-1.png",
|
||||||
"altText": "Shirt",
|
"altText": "Lightweight Jacket",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-2.png",
|
"url": "/assets/lightweight-jacket-2.png",
|
||||||
"altText": "Shirt",
|
"altText": "Lightweight Jacket",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-3.png",
|
"url": "/assets/lightweight-jacket-3.png",
|
||||||
"altText": "Shirt",
|
"altText": "Lightweight Jacket",
|
||||||
|
"width": 1000,
|
||||||
|
"height": 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/assets/lightweight-jacket-4.png",
|
||||||
|
"altText": "Lightweight Jacket",
|
||||||
|
"width": 1000,
|
||||||
|
"height": 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/assets/lightweight-jacket-5.png",
|
||||||
|
"altText": "Lightweight Jacket",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"variants": [
|
"variants": [
|
||||||
{
|
{
|
||||||
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
|
"id": "Z2lkOid8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
|
||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"__typename": "MultipleChoiceOption",
|
"__typename": "MultipleChoiceOption",
|
||||||
@ -159,34 +171,46 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
|
"id": "Z2lkOis8vc2hvcGlmsddeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
|
||||||
"name": "New Short Sleeve T-Shirt",
|
"name": "Shirt",
|
||||||
"vendor": "Next.js",
|
"vendor": "Next.js",
|
||||||
"path": "/new-short-sleeve-t-shirt",
|
"path": "/shirt",
|
||||||
"slug": "new-short-sleeve-t-shirt",
|
"slug": "shirt",
|
||||||
"price": { "value": 25, "currencyCode": "USD" },
|
"price": { "value": 25, "currencyCode": "USD" },
|
||||||
"descriptionHtml": "<p><span>Show off your love for Next.js and Vercel with this unique, </span><strong>limited edition</strong><span> t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made! </span><strong>All proceeds will be donated to charity.</strong></p>",
|
"descriptionHtml": "<p><span>Show off your love for Next.js and Vercel with this unique, </span><strong>limited edition</strong><span> t-shirt. This design is part of a limited run, numbered drop at the June 2021 Next.js Conf. It features a unique, handcrafted triangle design. Get it while supplies last – only 200 of these shirts will be made! </span><strong>All proceeds will be donated to charity.</strong></p>",
|
||||||
"images": [
|
"images": [
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-0.png",
|
"url": "/assets/t-shirt-0.png",
|
||||||
"altText": "Shirt",
|
"altText": "Shirt",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-1.png",
|
"url": "/assets/t-shirt-1.png",
|
||||||
"altText": "Shirt",
|
"altText": "Shirt",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-2.png",
|
"url": "/assets/t-shirt-2.png",
|
||||||
"altText": "Shirt",
|
"altText": "Shirt",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/assets/drop-shirt-3.png",
|
"url": "/assets/t-shirt-3.png",
|
||||||
|
"altText": "Shirt",
|
||||||
|
"width": 1000,
|
||||||
|
"height": 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/assets/t-shirt-4.png",
|
||||||
|
"altText": "Shirt",
|
||||||
|
"width": 1000,
|
||||||
|
"height": 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "/assets/t-shirt-5.png",
|
||||||
"altText": "Shirt",
|
"altText": "Shirt",
|
||||||
"width": 1000,
|
"width": 1000,
|
||||||
"height": 1000
|
"height": 1000
|
||||||
@ -194,7 +218,7 @@
|
|||||||
],
|
],
|
||||||
"variants": [
|
"variants": [
|
||||||
{
|
{
|
||||||
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
|
"id": "Z2lkOi8vc2hvcGlmeS9Qcms9kdWN0LzU0NDczMjUwMjQ0MjAss=",
|
||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"__typename": "MultipleChoiceOption",
|
"__typename": "MultipleChoiceOption",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import getCategories from '../../utils/get-categories'
|
import getCategories from '../../utils/get-categories'
|
||||||
import getVendors, { Brands } from '../../utils/get-vendors'
|
import getVendors, { Brands } from '../../utils/get-vendors'
|
||||||
import { Provider, SwellConfig } from '../'
|
import { Provider, SwellConfig } from '../'
|
||||||
import { OperationContext } from '@commerce/api/operations'
|
import type { OperationContext } from '@commerce/api/operations'
|
||||||
import { Category } from '@commerce/types/site'
|
import type { Category } from '@commerce/types/site'
|
||||||
|
|
||||||
export type GetSiteInfoResult<
|
export type GetSiteInfoResult<
|
||||||
T extends { categories: any[]; brands: any[] } = {
|
T extends { categories: any[]; brands: any[] } = {
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import getCategories from '../utils/get-categories'
|
|
||||||
import getVendors, { Brands } from '../utils/get-vendors'
|
|
||||||
import { Category } from '@commerce/types'
|
|
||||||
import { getConfig, SwellConfig } from '../api'
|
|
||||||
|
|
||||||
export type GetSiteInfoResult<
|
|
||||||
T extends { categories: any[]; brands: any[] } = {
|
|
||||||
categories: Category[]
|
|
||||||
brands: Brands
|
|
||||||
}
|
|
||||||
> = T
|
|
||||||
|
|
||||||
const getSiteInfo = async (options?: {
|
|
||||||
variables?: any
|
|
||||||
config: SwellConfig
|
|
||||||
preview?: boolean
|
|
||||||
}): Promise<GetSiteInfoResult> => {
|
|
||||||
let { config } = options ?? {}
|
|
||||||
|
|
||||||
config = getConfig(config)
|
|
||||||
|
|
||||||
const categoriesPromise = getCategories(config)
|
|
||||||
const brandsPromise = getVendors(config)
|
|
||||||
const categories = await categoriesPromise
|
|
||||||
const brands = await brandsPromise
|
|
||||||
|
|
||||||
return {
|
|
||||||
categories,
|
|
||||||
brands,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default getSiteInfo
|
|
BIN
public/assets/lightweight-jacket-0.png
Normal file
After Width: | Height: | Size: 1.8 MiB |
BIN
public/assets/lightweight-jacket-1.png
Normal file
After Width: | Height: | Size: 7.5 MiB |
BIN
public/assets/lightweight-jacket-2.png
Normal file
After Width: | Height: | Size: 5.1 MiB |
BIN
public/assets/lightweight-jacket-3.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
BIN
public/assets/lightweight-jacket-4.png
Normal file
After Width: | Height: | Size: 4.9 MiB |
BIN
public/assets/lightweight-jacket-5.png
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
public/assets/t-shirt-0.png
Normal file
After Width: | Height: | Size: 406 KiB |
BIN
public/assets/t-shirt-1.png
Normal file
After Width: | Height: | Size: 330 KiB |
BIN
public/assets/t-shirt-2.png
Normal file
After Width: | Height: | Size: 420 KiB |
BIN
public/assets/t-shirt-3.png
Normal file
After Width: | Height: | Size: 972 KiB |
BIN
public/assets/t-shirt-4.png
Normal file
After Width: | Height: | Size: 356 KiB |
BIN
public/assets/t-shirt-5.png
Normal file
After Width: | Height: | Size: 839 KiB |
Before Width: | Height: | Size: 754 KiB |
@ -22,15 +22,15 @@
|
|||||||
"@components/*": ["components/*"],
|
"@components/*": ["components/*"],
|
||||||
"@commerce": ["framework/commerce"],
|
"@commerce": ["framework/commerce"],
|
||||||
"@commerce/*": ["framework/commerce/*"],
|
"@commerce/*": ["framework/commerce/*"],
|
||||||
"@framework": ["framework/shopify"],
|
"@framework": ["framework/swell"],
|
||||||
"@framework/*": ["framework/shopify/*"]
|
"@framework/*": ["framework/swell/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"./framework/bigcommerce",
|
"./framework/bigcommerce",
|
||||||
"./framework/swell",
|
"./framework/shopify",
|
||||||
"./framework/vendure",
|
"./framework/vendure",
|
||||||
"./framework/saleor"
|
"./framework/saleor"
|
||||||
]
|
]
|
||||||
|