Merge branch 'main' into ordercloud-provider-checkout

This commit is contained in:
goncy
2021-09-24 13:45:24 -03:00
16 changed files with 49 additions and 43 deletions

View File

@@ -85,25 +85,29 @@ const CartItem = ({
<div className="flex flex-row space-x-4 py-4"> <div className="flex flex-row space-x-4 py-4">
<div className="w-16 h-16 bg-violet relative overflow-hidden cursor-pointer z-0"> <div className="w-16 h-16 bg-violet relative overflow-hidden cursor-pointer z-0">
<Link href={`/product/${item.path}`}> <Link href={`/product/${item.path}`}>
<Image <a>
onClick={() => closeSidebarIfPresent()} <Image
className={s.productImage} onClick={() => closeSidebarIfPresent()}
width={150} className={s.productImage}
height={150} width={150}
src={item.variant.image!.url} height={150}
alt={item.variant.image!.altText} src={item.variant.image!.url}
unoptimized alt={item.variant.image!.altText}
/> unoptimized
/>
</a>
</Link> </Link>
</div> </div>
<div className="flex-1 flex flex-col text-base"> <div className="flex-1 flex flex-col text-base">
<Link href={`/product/${item.path}`}> <Link href={`/product/${item.path}`}>
<span <a>
className={s.productName} <span
onClick={() => closeSidebarIfPresent()} className={s.productName}
> onClick={() => closeSidebarIfPresent()}
{item.name} >
</span> {item.name}
</span>
</a>
</Link> </Link>
{options && options.length > 0 && ( {options && options.length > 0 && (
<div className="flex items-center pb-1"> <div className="flex items-center pb-1">

View File

@@ -74,9 +74,11 @@ const CartSidebarView: FC = () => {
<> <>
<div className="px-4 sm:px-6 flex-1"> <div className="px-4 sm:px-6 flex-1">
<Link href="/cart"> <Link href="/cart">
<Text variant="sectionHeading" onClick={handleClose}> <a>
My Cart <Text variant="sectionHeading" onClick={handleClose}>
</Text> My Cart
</Text>
</a>
</Link> </Link>
<ul className={s.lineItemsList}> <ul className={s.lineItemsList}>
{data!.lineItems.map((item: any) => ( {data!.lineItems.map((item: any) => (

View File

@@ -44,7 +44,9 @@ const CheckoutSidebarView: FC = () => {
> >
<div className="px-4 sm:px-6 flex-1"> <div className="px-4 sm:px-6 flex-1">
<Link href="/cart"> <Link href="/cart">
<Text variant="sectionHeading">Checkout</Text> <a>
<Text variant="sectionHeading">Checkout</Text>
</a>
</Link> </Link>
<PaymentWidget <PaymentWidget

View File

@@ -5,7 +5,7 @@ import { uuid } from 'uuidv4'
const fullCheckout = true const fullCheckout = true
const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
req, req,
res, res,
config, config,
@@ -87,4 +87,4 @@ const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({
res.end() res.end()
} }
export default submitCheckout export default getCheckout

View File

@@ -2,13 +2,13 @@ import { GetAPISchema, createEndpoint } from '@commerce/api'
import checkoutEndpoint from '@commerce/api/endpoints/checkout' import checkoutEndpoint from '@commerce/api/endpoints/checkout'
import type { CheckoutSchema } from '../../../types/checkout' import type { CheckoutSchema } from '../../../types/checkout'
import type { BigcommerceAPI } from '../..' import type { BigcommerceAPI } from '../..'
import submitCheckout from './submit-checkout' import getCheckout from './get-checkout'
export type CheckoutAPI = GetAPISchema<BigcommerceAPI, CheckoutSchema> export type CheckoutAPI = GetAPISchema<BigcommerceAPI, CheckoutSchema>
export type CheckoutEndpoint = CheckoutAPI['endpoint'] export type CheckoutEndpoint = CheckoutAPI['endpoint']
export const handlers: CheckoutEndpoint['handlers'] = { submitCheckout } export const handlers: CheckoutEndpoint['handlers'] = { getCheckout }
const checkoutApi = createEndpoint<CheckoutAPI>({ const checkoutApi = createEndpoint<CheckoutAPI>({
handler: checkoutEndpoint, handler: checkoutEndpoint,

View File

@@ -53,7 +53,7 @@ export default function getCustomerWishlistOperation({
if (ids?.length) { if (ids?.length) {
const graphqlData = await commerce.getAllProducts({ const graphqlData = await commerce.getAllProducts({
variables: { first: 100, ids }, variables: { first: 50, ids },
config, config,
}) })
// Put the products in an object that we can use to get them by id // Put the products in an object that we can use to get them by id

View File

@@ -26,11 +26,11 @@ const checkoutEndpoint: GetAPISchema<
// Create checkout // Create checkout
if (req.method === 'GET') { if (req.method === 'GET') {
const body = { ...req.body, cartId } const body = { ...req.body, cartId }
return await handlers['getCheckout']?.({ ...ctx, body }) return await handlers['getCheckout']({ ...ctx, body })
} }
// Create checkout // Create checkout
if (req.method === 'POST') { if (req.method === 'POST' && handlers['submitCheckout']) {
const body = { ...req.body, cartId } const body = { ...req.body, cartId }
return await handlers['submitCheckout']({ ...ctx, body }) return await handlers['submitCheckout']({ ...ctx, body })
} }

View File

@@ -3,7 +3,7 @@ import type { Address } from './customer/address'
import type { Card } from './customer/card' import type { Card } from './customer/card'
// Index // Index
export type Checkout = unknown; export type Checkout = any
export type CheckoutTypes = { export type CheckoutTypes = {
card?: Card card?: Card
@@ -45,8 +45,8 @@ export type SubmitCheckoutHandler<T extends CheckoutTypes = CheckoutTypes> =
} }
export type CheckoutHandlers<T extends CheckoutTypes = CheckoutTypes> = { export type CheckoutHandlers<T extends CheckoutTypes = CheckoutTypes> = {
getCheckout?: GetCheckoutHandler<T> getCheckout: GetCheckoutHandler<T>
submitCheckout: SubmitCheckoutHandler<T> submitCheckout?: SubmitCheckoutHandler<T>
} }
export type CheckoutSchema<T extends CheckoutTypes = CheckoutTypes> = { export type CheckoutSchema<T extends CheckoutTypes = CheckoutTypes> = {

View File

@@ -6,7 +6,7 @@ export type CheckoutAPI = GetAPISchema<CommerceAPI, CheckoutSchema>
export type CheckoutEndpoint = CheckoutAPI['endpoint'] export type CheckoutEndpoint = CheckoutAPI['endpoint']
const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({ req, res, config }) => { const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({ req, res, config }) => {
try { try {
const html = ` const html = `
<!DOCTYPE html> <!DOCTYPE html>
@@ -43,7 +43,7 @@ const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({
} }
} }
export const handlers: CheckoutEndpoint['handlers'] = { submitCheckout } export const handlers: CheckoutEndpoint['handlers'] = { getCheckout }
const checkoutApi = createEndpoint<CheckoutAPI>({ const checkoutApi = createEndpoint<CheckoutAPI>({
handler: checkoutEndpoint, handler: checkoutEndpoint,

View File

@@ -1,7 +1,6 @@
{ {
"provider": "saleor", "provider": "saleor",
"features": { "features": {
"wishlist": false, "wishlist": false
"customCheckout": true
} }
} }

View File

@@ -6,7 +6,7 @@ import {
import associateCustomerWithCheckoutMutation from '../../../utils/mutations/associate-customer-with-checkout' import associateCustomerWithCheckoutMutation from '../../../utils/mutations/associate-customer-with-checkout'
import type { CheckoutEndpoint } from '.' import type { CheckoutEndpoint } from '.'
const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
req, req,
res, res,
config, config,
@@ -35,4 +35,4 @@ const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({
} }
} }
export default submitCheckout export default getCheckout

View File

@@ -2,13 +2,13 @@ import { GetAPISchema, createEndpoint } from '@commerce/api'
import checkoutEndpoint from '@commerce/api/endpoints/checkout' import checkoutEndpoint from '@commerce/api/endpoints/checkout'
import type { CheckoutSchema } from '../../../types/checkout' import type { CheckoutSchema } from '../../../types/checkout'
import type { ShopifyAPI } from '../..' import type { ShopifyAPI } from '../..'
import submitCheckout from './submit-checkout' import getCheckout from './get-checkout'
export type CheckoutAPI = GetAPISchema<ShopifyAPI, CheckoutSchema> export type CheckoutAPI = GetAPISchema<ShopifyAPI, CheckoutSchema>
export type CheckoutEndpoint = CheckoutAPI['endpoint'] export type CheckoutEndpoint = CheckoutAPI['endpoint']
export const handlers: CheckoutEndpoint['handlers'] = { submitCheckout } export const handlers: CheckoutEndpoint['handlers'] = { getCheckout }
const checkoutApi = createEndpoint<CheckoutAPI>({ const checkoutApi = createEndpoint<CheckoutAPI>({
handler: checkoutEndpoint, handler: checkoutEndpoint,

View File

@@ -3,7 +3,7 @@ import { CheckoutSchema } from '@commerce/types/checkout'
import { SWELL_CHECKOUT_URL_COOKIE } from '../../../const' import { SWELL_CHECKOUT_URL_COOKIE } from '../../../const'
import checkoutEndpoint from '@commerce/api/endpoints/checkout' import checkoutEndpoint from '@commerce/api/endpoints/checkout'
const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
req, req,
res, res,
config, config,
@@ -17,7 +17,7 @@ const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({
res.redirect('/cart') res.redirect('/cart')
} }
} }
export const handlers: CheckoutEndpoint['handlers'] = { submitCheckout } export const handlers: CheckoutEndpoint['handlers'] = { getCheckout }
export type CheckoutAPI = GetAPISchema<CommerceAPI, CheckoutSchema> export type CheckoutAPI = GetAPISchema<CommerceAPI, CheckoutSchema>
export type CheckoutEndpoint = CheckoutAPI['endpoint'] export type CheckoutEndpoint = CheckoutAPI['endpoint']

View File

@@ -3,7 +3,7 @@ import { CommerceAPI, createEndpoint, GetAPISchema } from '@commerce/api'
import { CheckoutSchema } from '@commerce/types/checkout' import { CheckoutSchema } from '@commerce/types/checkout'
import checkoutEndpoint from '@commerce/api/endpoints/checkout' import checkoutEndpoint from '@commerce/api/endpoints/checkout'
const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
req, req,
res, res,
config, config,
@@ -48,7 +48,7 @@ export type CheckoutAPI = GetAPISchema<CommerceAPI, CheckoutSchema>
export type CheckoutEndpoint = CheckoutAPI['endpoint'] export type CheckoutEndpoint = CheckoutAPI['endpoint']
export const handlers: CheckoutEndpoint['handlers'] = { submitCheckout } export const handlers: CheckoutEndpoint['handlers'] = { getCheckout }
const checkoutApi = createEndpoint<CheckoutAPI>({ const checkoutApi = createEndpoint<CheckoutAPI>({
handler: checkoutEndpoint, handler: checkoutEndpoint,

View File

@@ -3,7 +3,6 @@ export const searchResultFragment = /* GraphQL */ `
productId productId
productName productName
description description
description
slug slug
sku sku
currencyCode currencyCode

View File

@@ -19,7 +19,7 @@ module.exports = withCommerceConfig({
}, },
rewrites() { rewrites() {
return [ return [
(isBC || isShopify || isSwell || isVendure) && { (isBC || isShopify || isSwell || isVendure || isSaleor) && {
source: '/checkout', source: '/checkout',
destination: '/api/checkout', destination: '/api/checkout',
}, },