Fix sos page

This commit is contained in:
Samantha Kellow
2023-09-13 21:02:59 +01:00
parent 95a77f1cb8
commit f571d7fab3
7 changed files with 161 additions and 113 deletions

View File

@@ -1,13 +1,7 @@
import { baseArtworkNumber, collectionsSKUs, colorSKUs, customisationSKUs, garmentHandleKeys, garmentSKUs, garmentSizes, sizeSKUs } from "constants/sku";
import { collectionsSKUs, colorSKUs, customisationSKUs, garmentHandleKeys, garmentSKUs, garmentSizes, sizeSKUs } from "constants/sku";
type TitleInfo = Awaited<ReturnType<typeof extractInfoFromTitle>>;
const artworkNumberCompiler = (artworkNumber: string) => {
const length = artworkNumber.length
const slice = baseArtworkNumber.slice(0, length + 1)
return slice + artworkNumber
}
const garmentHandleKeyMapper = (garmentKeys: string[]) => {
const garmentTitle = garmentKeys.join(' ');
const garmentKey = garmentHandleKeys[garmentTitle as keyof typeof garmentHandleKeys]
@@ -30,7 +24,7 @@ const extractInfoFromTitle = (productTitle: string) => {
const collectionSKUMapper = (titleInfo: TitleInfo) => {
const collectionSKU = collectionsSKUs[titleInfo.collectionKey as keyof typeof collectionsSKUs];
const artworkSKU = artworkNumberCompiler(titleInfo.artworkNumber!);
const artworkSKU = titleInfo.artworkNumber!.padStart(4, "0");
const garmentSKU = garmentHandleKeyMapper(titleInfo.garmentKeys);
return `SCSQ${collectionSKU}${artworkSKU}_${garmentSKU}`;