amending SKU factory to include printSizeSKUs

This commit is contained in:
Samantha Kellow 2023-11-23 11:26:26 +00:00
parent 3a8f04ed96
commit af3750c200
2 changed files with 25 additions and 5 deletions

View File

@ -68,3 +68,13 @@ export const sizeSKUs = {
xxxl: '3XL',
};
export const printSizeSKUs = {
[sizeSKUs.xxs]: 1,
[sizeSKUs.xs]: 1,
[sizeSKUs.s]: 2,
[sizeSKUs.m]: 2,
[sizeSKUs.l]: 3,
[sizeSKUs.xl]: 3,
[sizeSKUs.xxl]: 3,
[sizeSKUs.xxxl]: 3,
}

View File

@ -1,4 +1,13 @@
import { collectionsSKUs, colorSKUs, customisationSKUs, garmentHandleKeys, garmentSKUs, garmentSizes, sizeSKUs } from "constants/sku";
import {
collectionsSKUs,
colorSKUs,
customisationSKUs,
garmentHandleKeys,
garmentSKUs,
garmentSizes,
printSizeSKUs,
sizeSKUs,
} from "constants/sku";
type TitleInfo = Awaited<ReturnType<typeof extractInfoFromTitle>>;
@ -22,12 +31,13 @@ const extractInfoFromTitle = (productTitle: string) => {
}
}
const collectionSKUMapper = (titleInfo: TitleInfo) => {
const collectionSKUMapper = (titleInfo: TitleInfo, size: keyof typeof sizeSKUs) => {
const collectionSKU = collectionsSKUs[titleInfo.collectionKey as keyof typeof collectionsSKUs];
const artworkSKU = titleInfo.artworkNumber!.padStart(4, "0");
const garmentSKU = garmentHandleKeyMapper(titleInfo.garmentKeys);
const printSizeSKU = printSizeSKUs[size];
return `SCSQ${collectionSKU}${artworkSKU}_${garmentSKU}`;
return `SCSQ${collectionSKU}${artworkSKU}${printSizeSKU}_${garmentSKU}`;
}
const customisationSKUMapper = () =>
@ -41,8 +51,8 @@ export const createProductSKUs = (productTitle: string) => {
return getGarmentSizes?.map(size => {
const currentSizeSKU = sizeSKUs[size as keyof typeof sizeSKUs]
const collectionSKU = collectionSKUMapper(titleInfo)
const collectionSKU = collectionSKUMapper(titleInfo, currentSizeSKU as keyof typeof sizeSKUs)
return `${collectionSKU}_${currentSizeSKU}_${customisationSKUs}`
})
}