Adding more to the Local Provider (#366)

* Adding more data

* Adding more data
This commit is contained in:
B 2021-06-14 22:52:05 -03:00 committed by GitHub
parent e0da7f4261
commit 74dda1aa55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 489 additions and 741 deletions

View File

@ -17,9 +17,9 @@ export default function getAllProductsOperation({
config?: Partial<LocalConfig>
preview?: boolean
} = {}): Promise<{ products: Product[] | any[] }> {
return Promise.resolve({
return {
products: data.products,
})
}
}
return getAllProducts
}

View File

@ -1,5 +1,6 @@
export type Page = any
export type GetPageResult = { page?: Page }
export type PageVariables = {
id: number
}

View File

@ -17,9 +17,9 @@ export default function getProductOperation({
config?: Partial<LocalConfig>
preview?: boolean
} = {}): Promise<Product | {} | any> {
return Promise.resolve({
product: data.products[0],
})
return {
product: data.products.find(({ slug }) => slug === variables!.slug),
}
}
return getProduct

View File

@ -21,7 +21,20 @@ export default function getSiteInfoOperation({}: OperationContext<any>) {
preview?: boolean
} = {}): Promise<GetSiteInfoResult> {
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: [],
})
}

View File

@ -80,42 +80,54 @@
]
},
{
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
"name": "New Short Sleeve T-Shirt",
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9ksdWN0LzU0NDczMjUwMjQ0MjA=",
"name": "Lightweight Jacket",
"vendor": "Next.js",
"path": "/new-short-sleeve-t-shirt",
"slug": "new-short-sleeve-t-shirt",
"price": { "value": 25, "currencyCode": "USD" },
"path": "/lightweight-jacket",
"slug": "lightweight-jacket",
"price": { "value": 249.99, "currencyCode": "USD" },
"descriptionHtml": "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;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!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
"images": [
{
"url": "/assets/drop-shirt-0.png",
"altText": "Shirt",
"url": "/assets/lightweight-jacket-0.png",
"altText": "Lightweight Jacket",
"width": 1000,
"height": 1000
},
{
"url": "/assets/drop-shirt-1.png",
"altText": "Shirt",
"url": "/assets/lightweight-jacket-1.png",
"altText": "Lightweight Jacket",
"width": 1000,
"height": 1000
},
{
"url": "/assets/drop-shirt-2.png",
"altText": "Shirt",
"url": "/assets/lightweight-jacket-2.png",
"altText": "Lightweight Jacket",
"width": 1000,
"height": 1000
},
{
"url": "/assets/drop-shirt-3.png",
"altText": "Shirt",
"url": "/assets/lightweight-jacket-3.png",
"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,
"height": 1000
}
],
"variants": [
{
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
"id": "Z2lkOid8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
"options": [
{
"__typename": "MultipleChoiceOption",
@ -159,34 +171,46 @@
]
},
{
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
"name": "New Short Sleeve T-Shirt",
"id": "Z2lkOis8vc2hvcGlmsddeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjA=",
"name": "Shirt",
"vendor": "Next.js",
"path": "/new-short-sleeve-t-shirt",
"slug": "new-short-sleeve-t-shirt",
"path": "/shirt",
"slug": "shirt",
"price": { "value": 25, "currencyCode": "USD" },
"descriptionHtml": "<p><span>Show off your love for Next.js and Vercel with this unique,&nbsp;</span><strong>limited edition</strong><span>&nbsp;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!&nbsp;</span><strong>All proceeds will be donated to charity.</strong></p>",
"images": [
{
"url": "/assets/drop-shirt-0.png",
"url": "/assets/t-shirt-0.png",
"altText": "Shirt",
"width": 1000,
"height": 1000
},
{
"url": "/assets/drop-shirt-1.png",
"url": "/assets/t-shirt-1.png",
"altText": "Shirt",
"width": 1000,
"height": 1000
},
{
"url": "/assets/drop-shirt-2.png",
"url": "/assets/t-shirt-2.png",
"altText": "Shirt",
"width": 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",
"width": 1000,
"height": 1000
@ -194,7 +218,7 @@
],
"variants": [
{
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NDczMjUwMjQ0MjAss=",
"id": "Z2lkOi8vc2hvcGlmeS9Qcms9kdWN0LzU0NDczMjUwMjQ0MjAss=",
"options": [
{
"__typename": "MultipleChoiceOption",

View File

@ -1,8 +1,8 @@
import getCategories from '../../utils/get-categories'
import getVendors, { Brands } from '../../utils/get-vendors'
import { Provider, SwellConfig } from '../'
import { OperationContext } from '@commerce/api/operations'
import { Category } from '@commerce/types/site'
import type { OperationContext } from '@commerce/api/operations'
import type { Category } from '@commerce/types/site'
export type GetSiteInfoResult<
T extends { categories: any[]; brands: any[] } = {

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
public/assets/t-shirt-0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

BIN
public/assets/t-shirt-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

BIN
public/assets/t-shirt-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

BIN
public/assets/t-shirt-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 KiB

BIN
public/assets/t-shirt-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

BIN
public/assets/t-shirt-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 754 KiB

View File

@ -22,15 +22,15 @@
"@components/*": ["components/*"],
"@commerce": ["framework/commerce"],
"@commerce/*": ["framework/commerce/*"],
"@framework": ["framework/shopify"],
"@framework/*": ["framework/shopify/*"]
"@framework": ["framework/swell"],
"@framework/*": ["framework/swell/*"]
}
},
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": [
"node_modules",
"./framework/bigcommerce",
"./framework/swell",
"./framework/shopify",
"./framework/vendure",
"./framework/saleor"
]

1091
yarn.lock

File diff suppressed because it is too large Load Diff