mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
Requested changes
This commit is contained in:
parent
d1fa1c950a
commit
8203a5b21e
@ -34,7 +34,9 @@ const getLoggedInCustomer: CustomerEndpoint['handlers']['getLoggedInCustomer'] =
|
|||||||
getLoggedInCustomerQuery,
|
getLoggedInCustomerQuery,
|
||||||
undefined,
|
undefined,
|
||||||
{
|
{
|
||||||
|
headers: {
|
||||||
cookie: `${config.customerCookie}=${token}`,
|
cookie: `${config.customerCookie}=${token}`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const { customer } = data
|
const { customer } = data
|
||||||
|
@ -48,9 +48,9 @@ export default function getCustomerWishlistOperation({
|
|||||||
if (includeProducts && wishlist?.items?.length) {
|
if (includeProducts && wishlist?.items?.length) {
|
||||||
const ids = []
|
const ids = []
|
||||||
|
|
||||||
for (let i = 0; i < wishlist.items.length; i++) {
|
for (const wishlistItem of wishlist.items) {
|
||||||
if (wishlist.items[i].product_id) {
|
if (wishlistItem.product_id) {
|
||||||
ids.push(String(wishlist.items[i]?.product_id))
|
ids.push(String(wishlistItem.product_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import type {
|
|||||||
import type { LoginOperation } from '@vercel/commerce/types/login'
|
import type { LoginOperation } from '@vercel/commerce/types/login'
|
||||||
import type { LoginMutation } from '../../../schema'
|
import type { LoginMutation } from '../../../schema'
|
||||||
import type { RecursivePartial } from '../utils/types'
|
import type { RecursivePartial } from '../utils/types'
|
||||||
import concatHeader from '../utils/concat-cookie'
|
|
||||||
import type { BigcommerceConfig, Provider } from '..'
|
import type { BigcommerceConfig, Provider } from '..'
|
||||||
|
|
||||||
export const loginMutation = /* GraphQL */ `
|
export const loginMutation = /* GraphQL */ `
|
||||||
|
@ -7,7 +7,7 @@ const fetchGraphqlApi: (getConfig: () => BigcommerceConfig) => GraphQLFetcher =
|
|||||||
async (
|
async (
|
||||||
query: string,
|
query: string,
|
||||||
{ variables, preview } = {},
|
{ variables, preview } = {},
|
||||||
headers?: HeadersInit
|
options: { headers?: HeadersInit } = {}
|
||||||
): Promise<any> => {
|
): Promise<any> => {
|
||||||
// log.warn(query)
|
// log.warn(query)
|
||||||
const config = getConfig()
|
const config = getConfig()
|
||||||
@ -16,7 +16,7 @@ const fetchGraphqlApi: (getConfig: () => BigcommerceConfig) => GraphQLFetcher =
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${config.apiToken}`,
|
Authorization: `Bearer ${config.apiToken}`,
|
||||||
...headers,
|
...options.headers,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
@ -20,7 +20,9 @@ async function getCustomerId({
|
|||||||
getCustomerIdQuery,
|
getCustomerIdQuery,
|
||||||
undefined,
|
undefined,
|
||||||
{
|
{
|
||||||
|
headers: {
|
||||||
cookie: `${config.customerCookie}=${customerToken}`,
|
cookie: `${config.customerCookie}=${customerToken}`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -165,7 +165,9 @@ export interface CommerceAPIConfig {
|
|||||||
fetch<Data = any, Variables = any>(
|
fetch<Data = any, Variables = any>(
|
||||||
query: string,
|
query: string,
|
||||||
queryData?: CommerceAPIFetchOptions<Variables>,
|
queryData?: CommerceAPIFetchOptions<Variables>,
|
||||||
headers?: HeadersInit
|
options?: {
|
||||||
|
headers: HeadersInit
|
||||||
|
}
|
||||||
): Promise<GraphQLFetcherResult<Data>>
|
): Promise<GraphQLFetcherResult<Data>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ export const getCustomerAddressBodySchema = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const customerSchema = z.object({
|
export const customerSchema = z.object({
|
||||||
customer: z.object({
|
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
firstName: z.string(),
|
firstName: z.string(),
|
||||||
lastName: z.string(),
|
lastName: z.string(),
|
||||||
@ -14,7 +13,6 @@ export const customerSchema = z.object({
|
|||||||
company: z.string().optional(),
|
company: z.string().optional(),
|
||||||
notes: z.string().optional(),
|
notes: z.string().optional(),
|
||||||
acceptsMarketing: z.boolean().optional(),
|
acceptsMarketing: z.boolean().optional(),
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const addressSchema = z.object({
|
export const addressSchema = z.object({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FC, useEffect, useState, useCallback } from 'react'
|
import { useEffect, useState, useCallback } from 'react'
|
||||||
import { Logo, Button, Input } from '@components/ui'
|
import { Logo, Button, Input } from '@components/ui'
|
||||||
import useLogin from '@framework/auth/use-login'
|
import useLogin from '@framework/auth/use-login'
|
||||||
import { useUI } from '@components/ui/context'
|
import { useUI } from '@components/ui/context'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user