Skip to content

Commit

Permalink
feat: #49 (theme) update vue components
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Aug 21, 2021
1 parent 61bfd68 commit 7187b4c
Show file tree
Hide file tree
Showing 7 changed files with 784 additions and 2 deletions.
21 changes: 21 additions & 0 deletions packages/api-client/src/fragments/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ export const AssetFragment = `
}
`;

export const OrderAddressFragment = `
fragment OrderAddress on OrderAddress {
fullName
company
streetLine1
streetLine2
city
province
postalCode
country
phoneNumber
}
`;

export const CartFragment = `
${AssetFragment}
${OrderAddressFragment}
fragment Cart on Order {
id
Expand Down Expand Up @@ -57,6 +72,12 @@ export const CartFragment = `
total
totalWithTax
shipping
shippingAddress {
...OrderAddress
}
billingAddress {
...OrderAddress
}
shippingWithTax
shippingLines {
priceWithTax
Expand Down
2 changes: 1 addition & 1 deletion packages/composables/src/composables/useBilling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const params: UseBillingParams<OrderAddress, AddParams> = {
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
load: async (context: Context, { customQuery }) => {
if (!context.cart.cart?.value?.billingAddress) {
if (!context.cart?.cart?.value?.billingAddress) {
await context.cart.load({ customQuery });
}
return context.cart.cart.value.billingAddress;
Expand Down
2 changes: 1 addition & 1 deletion packages/composables/src/composables/useShipping/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const params: UseShippingParams<OrderAddress, AddParams> = {
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
load: async (context: Context, { customQuery }) => {
if (!context.cart.cart?.value?.shippingAddress) {
if (!context.cart?.cart?.value?.shippingAddress) {
await context.cart.load({ customQuery });
}
return context.cart.cart.value.shippingAddress;
Expand Down
1 change: 1 addition & 0 deletions packages/theme/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './category';
export * from './checkout';
export * from './shipping-billing';
22 changes: 22 additions & 0 deletions packages/theme/helpers/shipping-billing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { OrderAddress } from "~/../api-client/lib";

interface AddressForm {
firstName: string,
lastName: string,
streetName: string,
apartment: string,
city: string,
state: string,
country: string,
postalCode: string,
phone: string
}

export const mapAddressFormToOrderAddress = (addressForm: AddressForm): OrderAddress => ({
fullName: `${addressForm.firstName} ${addressForm.lastName}`,
streetLine1: `${addressForm.streetName} ${addressForm.apartment}`,
city: addressForm.city,
postalCode: addressForm.postalCode,
countryCode: addressForm.country,
phoneNumber: addressForm.phone,
})
Loading

0 comments on commit 7187b4c

Please sign in to comment.