setup custom fetcher and auth hooks

This commit is contained in:
Greg Hoskin
2021-03-27 15:54:32 -06:00
parent 753234dc51
commit ee1d8ed461
37 changed files with 299 additions and 103 deletions

View File

@@ -1,4 +1,5 @@
import { Product } from '@commerce/types'
import { Customer } from '@commerce/types'
import {
Product as ShopifyProduct,
@@ -11,7 +12,7 @@ import {
ProductOption,
} from '../schema'
import type { Cart, LineItem } from '../types'
import type { Cart, LineItem, SwellCustomer } from '../types'
const money = ({ amount, currencyCode }: MoneyV2) => {
return {
@@ -121,6 +122,15 @@ export function normalizeCart(checkout: Checkout): Cart {
}
}
export function normalizeCustomer(customer: SwellCustomer): Customer {
const { first_name: firstName, last_name: lastName } = customer
return {
...customer,
firstName,
lastName,
}
}
function normalizeLineItem({
node: { id, title, variant, quantity },
}: CheckoutLineItemEdge): LineItem {