mirror of
https://github.com/vercel/commerce.git
synced 2025-03-28 08:15:54 +00:00
Progress, Changes types, readme and restoring functionality
This commit is contained in:
parent
ab16960ddb
commit
0d4355b431
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,6 +25,7 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
|
.env
|
||||||
.env.local
|
.env.local
|
||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
|
@ -124,3 +124,11 @@ Main folder and its exposed functions
|
|||||||
|
|
||||||
- `config.json`
|
- `config.json`
|
||||||
- README.md
|
- README.md
|
||||||
|
|
||||||
|
#### Example of correct usage of Commece Framework
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { useUI } from '@components/ui'
|
||||||
|
import { useCustomer } from '@framework/customer'
|
||||||
|
import { useAddItem, useWishlist, useRemoveItem } from '@framework/wishlist'
|
||||||
|
```
|
||||||
|
@ -10,3 +10,4 @@ export { default as Skeleton } from './Skeleton'
|
|||||||
export { default as Modal } from './Modal'
|
export { default as Modal } from './Modal'
|
||||||
export { default as Text } from './Text'
|
export { default as Text } from './Text'
|
||||||
export { default as Input } from './Input'
|
export { default as Input } from './Input'
|
||||||
|
export { useUI } from './context'
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
import React, { FC, useState } from 'react'
|
import React, { FC, useState } from 'react'
|
||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
import { Heart } from '@components/icons'
|
import { Heart } from '@components/icons'
|
||||||
import { useUI } from '@components/ui/context'
|
|
||||||
|
|
||||||
import type { ProductNode } from '@framework/api/operations/get-all-products'
|
import { useUI } from '@components/ui'
|
||||||
import useCustomer from '@framework/customer/use-customer'
|
import { useCustomer } from '@framework/customer'
|
||||||
import useAddItem from '@framework/wishlist/use-add-item'
|
import { useAddItem, useWishlist, useRemoveItem } from '@framework/wishlist'
|
||||||
import useWishlist from '@framework/wishlist/use-wishlist'
|
|
||||||
import useRemoveItem from '@framework/wishlist/use-remove-item'
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
productId: Product['id']
|
productId: Product['id']
|
||||||
|
@ -21,10 +21,10 @@ export type ItemBody = {
|
|||||||
|
|
||||||
export type AddItemBody = { item: ItemBody }
|
export type AddItemBody = { item: ItemBody }
|
||||||
|
|
||||||
export type RemoveItemBody = { itemId: string }
|
export type RemoveItemBody = { itemId: Product['id'] }
|
||||||
|
|
||||||
export type WishlistBody = {
|
export type WishlistBody = {
|
||||||
customer_id: number
|
customer_id: Customer['id']
|
||||||
is_public: number
|
is_public: number
|
||||||
name: string
|
name: string
|
||||||
items: any[]
|
items: any[]
|
||||||
|
@ -16,7 +16,7 @@ export interface UseWishlistOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UseWishlistInput extends UseWishlistOptions {
|
export interface UseWishlistInput extends UseWishlistOptions {
|
||||||
customerId?: number
|
customerId?: Customer['id']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetcher: HookFetcher<Wishlist | null, UseWishlistInput> = (
|
export const fetcher: HookFetcher<Wishlist | null, UseWishlistInput> = (
|
||||||
|
4
framework/types.d.ts
vendored
4
framework/types.d.ts
vendored
@ -2,11 +2,11 @@ interface Product {
|
|||||||
id: string | number
|
id: string | number
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
|
slug: string
|
||||||
|
path?: string
|
||||||
images: ProductImage[]
|
images: ProductImage[]
|
||||||
variants: ProductVariant[]
|
variants: ProductVariant[]
|
||||||
prices: ProductPrice[]
|
prices: ProductPrice[]
|
||||||
slug: string
|
|
||||||
path?: string
|
|
||||||
}
|
}
|
||||||
interface ProductImage {
|
interface ProductImage {
|
||||||
url: string
|
url: string
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
||||||
"find:unused": "next-unused",
|
"find:unused": "next-unused",
|
||||||
"generate": "graphql-codegen",
|
"generate": "graphql-codegen",
|
||||||
"generate:definitions": "node framework/bigcommerce/scripts/generate-definitions.js"
|
"generate:definitions": "node framework/bigcommerce/lib/generate-definitions.js"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"semi": false,
|
"semi": false,
|
||||||
|
@ -9,8 +9,6 @@ import getAllProducts from '@framework/api/operations/get-all-products'
|
|||||||
import getSiteInfo from '@framework/api/operations/get-site-info'
|
import getSiteInfo from '@framework/api/operations/get-site-info'
|
||||||
import getAllPages from '@framework/api/operations/get-all-pages'
|
import getAllPages from '@framework/api/operations/get-all-pages'
|
||||||
|
|
||||||
// Outputs from providers should already be normalized
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
export async function getStaticProps({
|
||||||
preview,
|
preview,
|
||||||
locale,
|
locale,
|
||||||
|
@ -26,6 +26,6 @@
|
|||||||
"@framework": ["framework/bigcommerce"]
|
"@framework": ["framework/bigcommerce"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user