forked from crowetic/commerce
Updates
This commit is contained in:
parent
f242f3c588
commit
e6792d6dd0
@ -15,8 +15,6 @@ import { setCustomerToken } from '@framework/utils'
|
|||||||
export default useLogin as UseLogin<typeof handler>
|
export default useLogin as UseLogin<typeof handler>
|
||||||
|
|
||||||
const getErrorMessage = ({ code, message }: CustomerUserError) => {
|
const getErrorMessage = ({ code, message }: CustomerUserError) => {
|
||||||
console.log(code)
|
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'UNIDENTIFIED_CUSTOMER':
|
case 'UNIDENTIFIED_CUSTOMER':
|
||||||
message = 'Cannot find an account that matches the provided credentials'
|
message = 'Cannot find an account that matches the provided credentials'
|
||||||
|
@ -25,14 +25,12 @@ const getAllPages = async (options?: {
|
|||||||
}): Promise<ReturnType> => {
|
}): Promise<ReturnType> => {
|
||||||
let { config, variables = { first: 250 } } = options ?? {}
|
let { config, variables = { first: 250 } } = options ?? {}
|
||||||
config = getConfig(config)
|
config = getConfig(config)
|
||||||
|
|
||||||
const { data } = await config.fetch(getAllPagesQuery, { variables })
|
const { data } = await config.fetch(getAllPagesQuery, { variables })
|
||||||
const edges = data.pages?.edges
|
|
||||||
|
|
||||||
const pages = edges?.map(
|
const pages = data.pages?.edges?.map(
|
||||||
({ node: { title: name, handle: url, ...node } }: PageEdge) => ({
|
({ node: { title: name, handle, ...node } }: PageEdge) => ({
|
||||||
...node,
|
...node,
|
||||||
url,
|
url: `/${handle}`,
|
||||||
name,
|
name,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ const getPage = async (options: {
|
|||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
|
|
||||||
const page = data.pageByHandle
|
const { pageByHandle: page } = data
|
||||||
|
|
||||||
return {
|
return {
|
||||||
page: page
|
page: page
|
||||||
|
@ -8,4 +8,7 @@ module.exports = {
|
|||||||
images: {
|
images: {
|
||||||
domains: ['cdn.shopify.com'],
|
domains: ['cdn.shopify.com'],
|
||||||
},
|
},
|
||||||
|
typescript: {
|
||||||
|
ignoreBuildErrors: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import { GraphQLFetcherResult } from '@commerce/api'
|
import { GraphQLFetcherResult } from '@commerce/api'
|
||||||
import { getConfig, ShopifyConfig } from '../api'
|
import { getConfig, ShopifyConfig } from '../api'
|
||||||
import { Product } from '../schema'
|
import { normalizeProduct, getProductQuery } from '../utils'
|
||||||
import getProductQuery from '../utils/queries/get-product-query'
|
|
||||||
import { normalizeProduct } from '@framework/utils/normalize'
|
|
||||||
|
|
||||||
export type ProductNode = Product
|
|
||||||
|
|
||||||
type Variables = {
|
type Variables = {
|
||||||
slug: string
|
slug: string
|
||||||
|
@ -41,7 +41,6 @@ const normalizeProductImages = ({ edges }: ImageConnection) =>
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
const normalizeProductVariants = ({ edges }: ProductVariantConnection) => {
|
const normalizeProductVariants = ({ edges }: ProductVariantConnection) => {
|
||||||
console.log(edges)
|
|
||||||
return edges?.map(({ node: { id, selectedOptions } }) => ({
|
return edges?.map(({ node: { id, selectedOptions } }) => ({
|
||||||
id,
|
id,
|
||||||
options: selectedOptions.map(({ name, value }: SelectedOption) =>
|
options: selectedOptions.map(({ name, value }: SelectedOption) =>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const getAllPagesQuery = /* GraphQL */ `
|
export const getAllPagesQuery = /* GraphQL */ `
|
||||||
query($first: Int!) {
|
query getAllPages($first: Int = 250) {
|
||||||
pages(first: $first) {
|
pages(first: $first) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const getAllProductsPathsQuery = /* GraphQL */ `
|
const getAllProductsPathsQuery = /* GraphQL */ `
|
||||||
query getAllProductPaths($first: Int!, $cursor: String) {
|
query getAllProductPaths($first: Int = 250, $cursor: String) {
|
||||||
products(first: $first, after: $cursor) {
|
products(first: $first, after: $cursor) {
|
||||||
pageInfo {
|
pageInfo {
|
||||||
hasNextPage
|
hasNextPage
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
export const getPageQuery = /* GraphQL */ `
|
export const getPageQuery = /* GraphQL */ `
|
||||||
query($first: Int!) {
|
query getPageBySlug($slug: String!) {
|
||||||
pages(first: $first) {
|
pageByHandle(handle: $slug) {
|
||||||
edges {
|
id
|
||||||
node {
|
title
|
||||||
id
|
handle
|
||||||
title
|
body
|
||||||
handle
|
bodySummary
|
||||||
body
|
url
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export { default as getSiteCollectionsQuery } from './get-all-collections-query'
|
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 getAllProductsQuery } from './get-all-products-query'
|
||||||
export { default as getAllProductsPathtsQuery } from './get-all-products-paths-query'
|
export { default as getAllProductsPathtsQuery } from './get-all-products-paths-query'
|
||||||
export { default as getAllProductVendors } from './get-all-product-vendors-query'
|
export { default as getAllProductVendors } from './get-all-product-vendors-query'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user