@ppg_pl/tinting 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/modal-header_9.cjs.entry.js +12 -1
- package/dist/cjs/modal-header_9.cjs.entry.js.map +1 -1
- package/dist/collection/components/api/services.js +12 -1
- package/dist/collection/components/api/services.js.map +1 -1
- package/dist/components/index2.js +12 -1
- package/dist/components/index2.js.map +1 -1
- package/dist/esm/modal-header_9.entry.js +12 -1
- package/dist/esm/modal-header_9.entry.js.map +1 -1
- package/dist/tinting/{p-1028bea2.entry.js → p-d9e19fea.entry.js} +3 -3
- package/dist/tinting/p-d9e19fea.entry.js.map +1 -0
- package/dist/tinting/tinting.esm.js +1 -1
- package/dist/types/components/api/services.d.ts +1 -1
- package/package.json +1 -1
- package/www/build/{p-1028bea2.entry.js → p-d9e19fea.entry.js} +3 -3
- package/www/build/p-d9e19fea.entry.js.map +1 -0
- package/www/build/tinting.esm.js +1 -1
- package/dist/tinting/p-1028bea2.entry.js.map +0 -1
- package/www/build/p-1028bea2.entry.js.map +0 -1
|
@@ -43,10 +43,21 @@ export const fetchColors = async (filters) => {
|
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
+
const getSampleSortForProduct = (sample, productId) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const link = (_a = sample === null || sample === void 0 ? void 0 : sample.Products) === null || _a === void 0 ? void 0 : _a.find((p) => p.Product_id === productId);
|
|
49
|
+
// put null/undefined at the end
|
|
50
|
+
return (_b = link === null || link === void 0 ? void 0 : link.sort) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
|
|
51
|
+
};
|
|
46
52
|
export const fetchSamplesColors = async (filters) => {
|
|
47
53
|
try {
|
|
54
|
+
// you already include Products.* in the query
|
|
55
|
+
const { id: productId } = filters;
|
|
48
56
|
const response = await ApiService.getData(`items/Sample?${fetchColorsQuery(Object.assign({}, filters))}`);
|
|
49
|
-
|
|
57
|
+
const data = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
58
|
+
// order by junction sort
|
|
59
|
+
const ordered = [...data].sort((a, b) => getSampleSortForProduct(a, productId) - getSampleSortForProduct(b, productId));
|
|
60
|
+
return ordered;
|
|
50
61
|
}
|
|
51
62
|
catch (error) {
|
|
52
63
|
console.error('Error fetching samples colors:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../src/components/api/services.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAG/B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAC;AAEzB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAA4B,EAAE,EAAE;EAC/D,MAAM,EAAE,SAAS,KAAqB,OAAO,EAAvB,WAAW,UAAK,OAAO,EAAvC,aAA6B,CAAU,CAAC;EAE9C,OAAO,EAAE,CAAC,SAAS,CACjB;IACE,MAAM,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IAClD,MAAM,EAAE;MACN,IAAI,EAAE;QACJ,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,C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KAAK,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC;GACb;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,IAAI,EAAE;;EAC3C,IAAI;IACF,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEtE,OAAO,CAAA,MAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,IAAI,0CAAE,OAAO,0CAAE,OAAO,KAAI,EAAE,CAAC;GACrD;EAAC,OAAO,KAAK,EAAE;IACd,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,EAAE,CAAC;GACX;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA4B,EAAE,SAA8B,EAAE,EAAE;EAC5F,uCAAY,OAAO,GAAK,SAAS,EAAG;AACtC,CAAC,CAAC","sourcesContent":["import qs from 'qs';\nimport { ApiService } from '.';\nimport { ProductShopRelation } from '../../types';\n\nexport const limit = 200;\n\nexport const fetchColorsQuery = (filters: Record<string, any>) => {\n const { sortByHex, ...restFilters } = filters;\n\n return qs.stringify(\n {\n fields: ['*', 'Products.*', 'Samples.*'].join(','),\n filter: {\n _and: [\n ...(restFilters.id ? [{ Products: { Product_id: { _eq: restFilters.id } } }] : []),\n ...(restFilters.sampleId ? [{ Samples: { Sample_id: { _eq: restFilters.sampleId } } }] : []),\n ...(restFilters.colorNumber ? [{ number: { _contains: restFilters.colorNumber } }] : []),\n ...(restFilters.colorName ? [{ name: { _icontains: restFilters.colorName } }] : []),\n ...(restFilters.colorFamily ? [{ colorFamily: { _eq: restFilters.colorFamily } }] : []),\n ],\n },\n sort: sortByHex === 'desc' ? '-hex' : sortByHex === 'asc' ? 'hex' : undefined,\n meta: '*',\n page: restFilters.page !== undefined ? restFilters.page : 1,\n limit: restFilters.colorName ? 200 : limit,\n },\n { encodeValuesOnly: true },\n );\n};\n\nexport const fetchColors = async (filters: Record<string, any>) => {\n try {\n const query = fetchColorsQuery({ ...filters, sortByHex: 'desc' });\n const response = await ApiService.getData(`items/Color?${query}`);\n return response?.data || [];\n } catch (error) {\n console.error('Error fetching colors:', error);\n return [];\n }\n};\n\nconst getSampleSortForProduct = (sample: any, productId: number) => {\n const link = sample?.Products?.find((p: any) => p.Product_id === productId);\n // put null/undefined at the end\n return link?.sort ?? Number.POSITIVE_INFINITY;\n};\n\nexport const fetchSamplesColors = async (filters: Record<string, any>) => {\n try {\n // you already include Products.* in the query\n const { id: productId } = filters;\n const response = await ApiService.getData(`items/Sample?${fetchColorsQuery({ ...filters })}`);\n const data = response?.data || [];\n\n // order by junction sort\n const ordered = [...data].sort((a, b) => getSampleSortForProduct(a, productId) - getSampleSortForProduct(b, productId));\n\n return ordered;\n } catch (error) {\n console.error('Error fetching samples colors:', error);\n return [];\n }\n};\n\nexport const fetchProductData = async (filters: Record<string, any>) => {\n try {\n // Fetch shop details\n const shopResponse = await ApiService.getData(`items/Shop?filter[name][_eq]=${filters.shopName}`);\n const shop = shopResponse?.data?.[0];\n\n if (!shop?.id) {\n console.error('Shop not found');\n return null;\n }\n\n // Fetch product details\n const response = await ApiService.getData(`items/Product?filter[name][_eq]=${filters.productName}&fields=*,images.*,Shop.*,Category.*.*.*.*`);\n const product = response?.data?.[0];\n\n // fetch product samples\n const productSamples = await fetchSamplesColors({ id: product.id, page: 0 });\n\n if (product && product.Shop.some((s: ProductShopRelation) => s.Shop_id === shop.id)) {\n return { ...product, id: product.id, productSamples };\n }\n\n console.error('Product not found or does not belong to the shop');\n return null;\n } catch (error) {\n console.error('Error fetching product data:', error);\n return null;\n }\n};\n\nexport const fetchColorFamilies = async () => {\n try {\n const response = await ApiService.getData(`fields/Color/colorFamily`);\n\n return response?.data?.meta?.options?.choices || [];\n } catch (error) {\n console.error('Error fetching color families:', error);\n return [];\n }\n};\n\nexport const updateFilters = (filters: Record<string, any>, newFilter: Record<string, any>) => {\n return { ...filters, ...newFilter };\n};\n"]}
|
|
@@ -2545,10 +2545,21 @@ const fetchColors = async (filters) => {
|
|
|
2545
2545
|
return [];
|
|
2546
2546
|
}
|
|
2547
2547
|
};
|
|
2548
|
+
const getSampleSortForProduct = (sample, productId) => {
|
|
2549
|
+
var _a, _b;
|
|
2550
|
+
const link = (_a = sample === null || sample === void 0 ? void 0 : sample.Products) === null || _a === void 0 ? void 0 : _a.find((p) => p.Product_id === productId);
|
|
2551
|
+
// put null/undefined at the end
|
|
2552
|
+
return (_b = link === null || link === void 0 ? void 0 : link.sort) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
|
|
2553
|
+
};
|
|
2548
2554
|
const fetchSamplesColors = async (filters) => {
|
|
2549
2555
|
try {
|
|
2556
|
+
// you already include Products.* in the query
|
|
2557
|
+
const { id: productId } = filters;
|
|
2550
2558
|
const response = await ApiService.getData(`items/Sample?${fetchColorsQuery(Object.assign({}, filters))}`);
|
|
2551
|
-
|
|
2559
|
+
const data = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
2560
|
+
// order by junction sort
|
|
2561
|
+
const ordered = [...data].sort((a, b) => getSampleSortForProduct(a, productId) - getSampleSortForProduct(b, productId));
|
|
2562
|
+
return ordered;
|
|
2552
2563
|
}
|
|
2553
2564
|
catch (error) {
|
|
2554
2565
|
console.error('Error fetching samples colors:', error);
|