Skip to content

Commit

Permalink
fix(core): pass customer id to shipping mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Apr 5, 2024
1 parent ea5a690 commit fc688ad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-turtles-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Pass customer id to shipping mutation that were missing.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const ShippingInfo = ({
shippingId: shippingConsignment?.entityId ?? '',
});

if (status === 'error') {
if (status === 'failed') {
toast.error(t('errorMessage'), {
icon: <AlertCircle className="text-error-secondary" />,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const ShippingOptions = ({
const onSubmit = async (formData: FormData) => {
const { status } = await submitShippingCosts(formData, checkout.entityId, consignmentEntityId);

if (status === 'error') {
toast.error(t('errorMessage2'), {
if (status === 'failed') {
toast.error(t('errorMessage'), {
icon: <AlertCircle className="text-error-secondary" />,
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getSessionCustomerId } from '~/auth';

import { client } from '..';
import { graphql, VariablesOf } from '../graphql';

Expand Down Expand Up @@ -38,6 +40,8 @@ export const addCheckoutShippingConsignments = async ({
lineItems,
shouldSaveAddress = false,
}: AddCheckoutShippingConsignmentsProps) => {
const customerId = await getSessionCustomerId();

const response = await client.fetch({
document: ADD_CHECKOUT_SHIPPING_CONSIGNMENTS_MUTATION,
variables: {
Expand All @@ -59,6 +63,8 @@ export const addCheckoutShippingConsignments = async ({
},
},
},
customerId,
fetchOptions: { cache: 'no-store' },
});

const checkout = response.data.checkout.addCheckoutShippingConsignments?.checkout;
Expand Down
6 changes: 6 additions & 0 deletions apps/core/client/mutations/select-checkout-shipping-option.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getSessionCustomerId } from '~/auth';

import { client } from '..';
import { graphql } from '../graphql';

Expand All @@ -22,6 +24,8 @@ export const selectCheckoutShippingOption = async ({
consignmentEntityId: string;
shippingOptionEntityId: string;
}) => {
const customerId = await getSessionCustomerId();

const response = await client.fetch({
document: SELECT_CHECKOUT_SHIPPING_OPTION_MUTATION,
variables: {
Expand All @@ -33,6 +37,8 @@ export const selectCheckoutShippingOption = async ({
},
},
},
customerId,
fetchOptions: { cache: 'no-store' },
});

const shippingCosts = response.data.checkout.selectCheckoutShippingOption?.checkout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getSessionCustomerId } from '~/auth';

import { client } from '..';
import { graphql, VariablesOf } from '../graphql';

Expand Down Expand Up @@ -40,6 +42,8 @@ export const updateCheckoutShippingConsignment = async ({
lineItems,
shouldSaveAddress = false,
}: UpdateCheckoutShippingConsignmentProps) => {
const customerId = await getSessionCustomerId();

const response = await client.fetch({
document: UPDATE_CHECKOUT_SHIPPING_CONSIGNMENT,
variables: {
Expand All @@ -60,6 +64,8 @@ export const updateCheckoutShippingConsignment = async ({
},
},
},
customerId,
fetchOptions: { cache: 'no-store' },
});

const checkout = response.data.checkout.updateCheckoutShippingConsignment?.checkout;
Expand Down

0 comments on commit fc688ad

Please sign in to comment.