4
0
forked from crowetic/commerce
This commit is contained in:
cond0r 2021-02-25 11:16:44 +02:00
parent f242f3c588
commit e6792d6dd0
10 changed files with 19 additions and 28 deletions

View File

@ -15,8 +15,6 @@ import { setCustomerToken } from '@framework/utils'
export default useLogin as UseLogin<typeof handler>
const getErrorMessage = ({ code, message }: CustomerUserError) => {
console.log(code)
switch (code) {
case 'UNIDENTIFIED_CUSTOMER':
message = 'Cannot find an account that matches the provided credentials'

View File

@ -25,14 +25,12 @@ const getAllPages = async (options?: {
}): Promise<ReturnType> => {
let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config)
const { data } = await config.fetch(getAllPagesQuery, { variables })
const edges = data.pages?.edges
const pages = edges?.map(
({ node: { title: name, handle: url, ...node } }: PageEdge) => ({
const pages = data.pages?.edges?.map(
({ node: { title: name, handle, ...node } }: PageEdge) => ({
...node,
url,
url: `/${handle}`,
name,
})
)

View File

@ -22,7 +22,7 @@ const getPage = async (options: {
variables,
})
const page = data.pageByHandle
const { pageByHandle: page } = data
return {
page: page

View File

@ -8,4 +8,7 @@ module.exports = {
images: {
domains: ['cdn.shopify.com'],
},
typescript: {
ignoreBuildErrors: true,
},
}

View File

@ -1,10 +1,6 @@
import { GraphQLFetcherResult } from '@commerce/api'
import { getConfig, ShopifyConfig } from '../api'
import { Product } from '../schema'
import getProductQuery from '../utils/queries/get-product-query'
import { normalizeProduct } from '@framework/utils/normalize'
export type ProductNode = Product
import { normalizeProduct, getProductQuery } from '../utils'
type Variables = {
slug: string

View File

@ -41,7 +41,6 @@ const normalizeProductImages = ({ edges }: ImageConnection) =>
}))
const normalizeProductVariants = ({ edges }: ProductVariantConnection) => {
console.log(edges)
return edges?.map(({ node: { id, selectedOptions } }) => ({
id,
options: selectedOptions.map(({ name, value }: SelectedOption) =>

View File

@ -1,5 +1,5 @@
export const getAllPagesQuery = /* GraphQL */ `
query($first: Int!) {
query getAllPages($first: Int = 250) {
pages(first: $first) {
edges {
node {

View File

@ -1,5 +1,5 @@
const getAllProductsPathsQuery = /* GraphQL */ `
query getAllProductPaths($first: Int!, $cursor: String) {
query getAllProductPaths($first: Int = 250, $cursor: String) {
products(first: $first, after: $cursor) {
pageInfo {
hasNextPage

View File

@ -1,15 +1,12 @@
export const getPageQuery = /* GraphQL */ `
query($first: Int!) {
pages(first: $first) {
edges {
node {
id
title
handle
body
url
}
}
query getPageBySlug($slug: String!) {
pageByHandle(handle: $slug) {
id
title
handle
body
bodySummary
url
}
}
`

View File

@ -1,5 +1,5 @@
export { default as getSiteCollectionsQuery } from './get-all-collections-query'
export { default as getProductQuery } from './get-all-products-paths-query'
export { default as getProductQuery } from './get-product-query'
export { default as getAllProductsQuery } from './get-all-products-query'
export { default as getAllProductsPathtsQuery } from './get-all-products-paths-query'
export { default as getAllProductVendors } from './get-all-product-vendors-query'