Skip to content

Commit 0048df1

Browse files
committed
fix: remove the need to pass sku to buyer portal
1 parent 0223f2c commit 0048df1

6 files changed

Lines changed: 15 additions & 29 deletions

File tree

core/app/[locale]/(default)/product/[slug]/page-data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ const ProductQuery = graphql(
171171
query ProductQuery($entityId: Int!) {
172172
site {
173173
product(entityId: $entityId) {
174-
sku
175174
entityId
176175
name
177176
description

core/app/[locale]/(default)/product/[slug]/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ export default async function Product(props: Props) {
304304
incrementLabel={t('ProductDetails.increaseQuantity')}
305305
prefetch={true}
306306
product={{
307-
sku: baseProduct.sku,
308307
id: baseProduct.entityId.toString(),
309308
title: baseProduct.name,
310309
description: <div dangerouslySetInnerHTML={{ __html: baseProduct.description }} />,

core/b2b/types.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export interface B2BProfile {
4040
companyRoleName: string;
4141
}
4242

43+
interface LineItem {
44+
productEntityId: number;
45+
quantity?: number;
46+
selectedOptions?: B2BProductOption[];
47+
}
48+
4349
declare global {
4450
interface Window {
4551
b2b?: {
@@ -53,27 +59,15 @@ declare global {
5359
quote?: {
5460
getQuoteConfigs: () => QuoteConfigProps[];
5561
addProductsFromCartId: (cartId: string) => Promise<void>;
56-
addProducts: (
57-
products: Array<{
58-
sku: string;
59-
productEntityId: number;
60-
quantity?: number;
61-
selectedOptions?: B2BProductOption[];
62-
}>,
63-
) => Promise<void>;
62+
addProducts: (products: LineItem[]) => Promise<void>;
6463
};
6564
shoppingList?: {
66-
addProductFromPage: (product: {
67-
sku: string;
68-
productEntityId: number;
69-
quantity?: number;
70-
selectedOptions?: B2BProductOption[];
71-
}) => Promise<void>;
65+
addProductFromPage: (product: LineItem) => Promise<void>;
7266
};
7367
cart?: {
7468
getEntityId: () => string;
7569
setEntityId: (cartId: string) => void;
76-
}
70+
};
7771
};
7872
callbacks?: {
7973
addEventListener: {
@@ -86,7 +80,10 @@ declare global {
8680
(event: 'on-logout', callback: (props: { data: Record<string, string> }) => void): void;
8781
(event: 'on-cart-created', callback: (props: { data: { cartId: string } }) => void): void;
8882
};
89-
removeEventListener: (event: 'on-logout' | 'on-registered' | 'on-cart-created', callback: unknown) => void;
83+
removeEventListener: (
84+
event: 'on-logout' | 'on-registered' | 'on-cart-created',
85+
callback: unknown,
86+
) => void;
9087
dispatchEvent: (event: string) => void;
9188
};
9289
};

core/b2b/use-product-details.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ interface ProductOption {
1717

1818
interface Data {
1919
productId: string;
20-
sku: string;
2120
quantity: number;
2221
selectedOptions: ProductOption[];
2322
}
@@ -27,13 +26,12 @@ export const useAddToQuote = () => {
2726
const [isAddingToQuote, setLoading] = useState(false);
2827
const sdk = useSDK();
2928

30-
const addProductsToQuote = async ({ selectedOptions, productId, quantity, sku }: Data) => {
29+
const addProductsToQuote = async ({ selectedOptions, productId, quantity }: Data) => {
3130
setLoading(true);
3231

3332
try {
3433
await sdk?.utils?.quote?.addProducts([
3534
{
36-
sku,
3735
productEntityId: Number(productId),
3836
quantity,
3937
selectedOptions: selectedOptions.map(mapToB2BProductOptions),
@@ -56,12 +54,11 @@ export const useAddToShoppingList = () => {
5654
const [isAddingToShoppingList, setLoading] = useState(false);
5755
const sdk = useSDK();
5856

59-
const addProductToShoppingList = async ({ selectedOptions, productId, quantity, sku }: Data) => {
57+
const addProductToShoppingList = async ({ selectedOptions, productId, quantity }: Data) => {
6058
setLoading(true);
6159

6260
try {
6361
await sdk?.utils?.shoppingList?.addProductFromPage({
64-
sku,
6562
productEntityId: Number(productId),
6663
quantity,
6764
selectedOptions: selectedOptions.map(mapToB2BProductOptions),

core/vibes/soul/sections/product-detail/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Field } from './schema';
1313

1414
interface ProductDetailProduct {
1515
id: string;
16-
sku: string;
1716
title: string;
1817
href: string;
1918
images: Streamable<Array<{ src: string; alt: string }>>;
@@ -158,7 +157,6 @@ export function ProductDetail<F extends Field>({
158157
prefetch={prefetch}
159158
productId={product.id}
160159
quantityLabel={quantityLabel}
161-
sku={product.sku}
162160
/>
163161
)}
164162
</Stream>

core/vibes/soul/sections/product-detail/product-detail-form.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export interface ProductDetailFormProps<F extends Field> {
4949
fields: F[];
5050
action: ProductDetailFormAction<F>;
5151
productId: string;
52-
sku: string;
5352
ctaLabel?: string;
5453
quantityLabel?: string;
5554
incrementLabel?: string;
@@ -72,7 +71,6 @@ export function ProductDetailForm<F extends Field>({
7271
ctaDisabled = false,
7372
prefetch = false,
7473
additionalActions,
75-
sku,
7674
}: ProductDetailFormProps<F>) {
7775
const router = useRouter();
7876
const pathname = usePathname();
@@ -152,14 +150,12 @@ export function ProductDetailForm<F extends Field>({
152150
if (formData.get('intent') === 'add-to-quote') {
153151
void addProductsToQuote({
154152
productId,
155-
sku,
156153
quantity: Number(submission.value.quantity),
157154
selectedOptions,
158155
});
159156
} else if (formData.get('intent') === 'add-to-shopping-list') {
160157
void addProductToShoppingList({
161158
productId,
162-
sku,
163159
quantity: Number(submission.value.quantity),
164160
selectedOptions,
165161
});

0 commit comments

Comments
 (0)