rerobe-js-orm 3.3.0 → 3.3.2
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/lib/factories/Product/ProductFromFormState.js +35 -33
- package/lib/form-states/Product/ProductFormState.js +2 -0
- package/lib/helpers/Utilities.d.ts +1 -0
- package/lib/helpers/Utilities.js +20 -0
- package/lib/models/Product.d.ts +6 -1
- package/lib/models/Product.js +137 -62
- package/lib/types/rerobe-product-types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ const ProductFactory_1 = require("./ProductFactory");
|
|
|
4
4
|
const Product_1 = require("../../models/Product");
|
|
5
5
|
class ProductFromFormState extends ProductFactory_1.default {
|
|
6
6
|
createProduct(props) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
8
8
|
const productAttributes = {
|
|
9
9
|
availableForSale: props.fields.availableForSale.selectedValue,
|
|
10
10
|
description: props.fields.description.inputValue,
|
|
@@ -33,9 +33,11 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
33
33
|
editorAuthorizations: props.fields.editorAuthorizations.selectedValue,
|
|
34
34
|
rfidTag: props.fields.rfidTag.inputValue || '',
|
|
35
35
|
sku: props.fields.sku.inputValue || '',
|
|
36
|
+
metaDataDescription: ((_o = props.fields.metaDataTitle) === null || _o === void 0 ? void 0 : _o.inputValue) || '',
|
|
37
|
+
metaDataTitle: ((_p = props.fields.metaDataTitle) === null || _p === void 0 ? void 0 : _p.inputValue) || '',
|
|
36
38
|
};
|
|
37
39
|
const productFilterAttributes = {
|
|
38
|
-
documentId: (
|
|
40
|
+
documentId: (_q = props.props) === null || _q === void 0 ? void 0 : _q.documentId,
|
|
39
41
|
brand: props.fields.brand.selectedValue,
|
|
40
42
|
measurementCategory: props.fields.measurementCategory.selectedValue,
|
|
41
43
|
size: props.fields.size.selectedValue,
|
|
@@ -56,7 +58,7 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
56
58
|
tags: props.fields.tags.selectedValues || [],
|
|
57
59
|
};
|
|
58
60
|
const consignmentAttributes = {
|
|
59
|
-
sellRequestId: ((
|
|
61
|
+
sellRequestId: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.sellRequestId) || '',
|
|
60
62
|
publishType: props.fields.publishType.selectedValue,
|
|
61
63
|
conditionRemarks: props.fields.conditionRemarks.inputValue,
|
|
62
64
|
productRemarks: props.fields.productRemarks.inputValue,
|
|
@@ -69,47 +71,47 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
69
71
|
nextAvailableSeason: props.fields.nextAvailableSeason.selectedValue,
|
|
70
72
|
notesForProductionTeam: props.fields.notesForProductionTeam.inputValue,
|
|
71
73
|
reviewedBy: props.fields.reviewedBy.selectedValue,
|
|
72
|
-
sellRequestImageUrls: ((
|
|
74
|
+
sellRequestImageUrls: ((_s = props.props) === null || _s === void 0 ? void 0 : _s.sellRequestImageUrls) || [],
|
|
73
75
|
salesChannel: props.fields.salesChannel.selectedValues || [],
|
|
74
76
|
sizeComment: props.fields.sizeComment.selectedValue,
|
|
75
|
-
salePrice: ((
|
|
77
|
+
salePrice: ((_t = props.props) === null || _t === void 0 ? void 0 : _t.salePrice) || '',
|
|
76
78
|
isOnSale: props.fields.isOnSale.selectedValue || '',
|
|
77
79
|
discountType: props.fields.discountType.selectedValue || '',
|
|
78
80
|
discountValue: props.fields.discountValue.inputValue || '',
|
|
79
|
-
selectedForClearance: ((
|
|
81
|
+
selectedForClearance: ((_u = props.props) === null || _u === void 0 ? void 0 : _u.selectedForClearance) || '',
|
|
80
82
|
locationIds: props.fields.locationIds.selectedValues || [],
|
|
81
83
|
inventoryLocations: props.fields.inventoryLocations.selectedValues || [],
|
|
82
84
|
majorDefects: props.fields.majorDefects.selectedValues || [],
|
|
83
85
|
minorDefects: props.fields.minorDefects.selectedValues || [],
|
|
84
86
|
};
|
|
85
87
|
const timestampAttributes = {
|
|
86
|
-
createdAtTimestamp: (
|
|
87
|
-
updatedAtTimestamp: (
|
|
88
|
-
sellRequestReviewTimestamp: (
|
|
89
|
-
sellRequestReviewDraftTimestamp: (
|
|
90
|
-
rejectedTimestamp: (
|
|
91
|
-
holdTimestamp: (
|
|
92
|
-
acceptedTimestamp: (
|
|
93
|
-
sellerToDropOffTimestamp: (
|
|
94
|
-
sellerToShipTimestamp: (
|
|
95
|
-
sellerToGetPickUpTimestamp: (
|
|
96
|
-
qualityControlTimestamp: (
|
|
97
|
-
pendingPublicationTimestamp: (
|
|
98
|
-
listedTimestamp: (
|
|
99
|
-
clearanceTimestamp: (
|
|
100
|
-
reservedTimestamp: (
|
|
101
|
-
soldTimestamp: (
|
|
102
|
-
returnedTimestamp: (
|
|
103
|
-
soldSellerToBePaidTimestamp: (
|
|
104
|
-
soldSellerPaidTimestamp: (
|
|
105
|
-
sellerSelfRejectTimestamp: (
|
|
106
|
-
liquidationRequestedTimestamp: (
|
|
107
|
-
sellerLiquidatedTimestamp: (
|
|
108
|
-
archivedTimestamp: (
|
|
109
|
-
liquidationReadyTimestamp: (
|
|
110
|
-
sellerDonatedTimestamp: (
|
|
111
|
-
merchantDonatedTimestamp: (
|
|
112
|
-
draftTimestamp: (
|
|
88
|
+
createdAtTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.createdAtTimestamp,
|
|
89
|
+
updatedAtTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.updatedAtTimestamp,
|
|
90
|
+
sellRequestReviewTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.sellRequestReviewTimestamp,
|
|
91
|
+
sellRequestReviewDraftTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.sellRequestReviewDraftTimestamp,
|
|
92
|
+
rejectedTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.rejectedTimestamp,
|
|
93
|
+
holdTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.holdTimestamp,
|
|
94
|
+
acceptedTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.acceptedTimestamp,
|
|
95
|
+
sellerToDropOffTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.sellerToDropOffTimestamp,
|
|
96
|
+
sellerToShipTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.sellerToShipTimestamp,
|
|
97
|
+
sellerToGetPickUpTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.sellerToGetPickUpTimestamp,
|
|
98
|
+
qualityControlTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.qualityControlTimestamp,
|
|
99
|
+
pendingPublicationTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.pendingPublicationTimestamp,
|
|
100
|
+
listedTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.listedTimestamp,
|
|
101
|
+
clearanceTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.clearanceTimestamp,
|
|
102
|
+
reservedTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.reservedTimestamp,
|
|
103
|
+
soldTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.soldTimestamp,
|
|
104
|
+
returnedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.returnedTimestamp,
|
|
105
|
+
soldSellerToBePaidTimestamp: (_12 = props.props) === null || _12 === void 0 ? void 0 : _12.soldSellerToBePaidTimestamp,
|
|
106
|
+
soldSellerPaidTimestamp: (_13 = props.props) === null || _13 === void 0 ? void 0 : _13.soldSellerPaidTimestamp,
|
|
107
|
+
sellerSelfRejectTimestamp: (_14 = props.props) === null || _14 === void 0 ? void 0 : _14.sellerSelfRejectTimestamp,
|
|
108
|
+
liquidationRequestedTimestamp: (_15 = props.props) === null || _15 === void 0 ? void 0 : _15.liquidationRequestedTimestamp,
|
|
109
|
+
sellerLiquidatedTimestamp: (_16 = props.props) === null || _16 === void 0 ? void 0 : _16.sellerLiquidatedTimestamp,
|
|
110
|
+
archivedTimestamp: (_17 = props.props) === null || _17 === void 0 ? void 0 : _17.archivedTimestamp,
|
|
111
|
+
liquidationReadyTimestamp: (_18 = props.props) === null || _18 === void 0 ? void 0 : _18.liquidationReadyTimestamp,
|
|
112
|
+
sellerDonatedTimestamp: (_19 = props.props) === null || _19 === void 0 ? void 0 : _19.sellerDonatedTimestamp,
|
|
113
|
+
merchantDonatedTimestamp: (_20 = props.props) === null || _20 === void 0 ? void 0 : _20.merchantDonatedTimestamp,
|
|
114
|
+
draftTimestamp: (_21 = props.props) === null || _21 === void 0 ? void 0 : _21.draftTimestamp,
|
|
113
115
|
};
|
|
114
116
|
return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
|
|
115
117
|
}
|
|
@@ -78,6 +78,8 @@ class ProductFormState extends FormState_1.default {
|
|
|
78
78
|
this.fields.featuredCollections = this.fieldFactory('multiSelect', 'featuredCollections');
|
|
79
79
|
this.fields.primaryAgeCategory = this.fieldFactory('singleSelect', 'primaryAgeCategory');
|
|
80
80
|
this.fields.tags = this.fieldFactory('multiSelect', 'tags');
|
|
81
|
+
this.fields.metaDataTitle = this.fieldFactory('textInput', 'metaDataTitle');
|
|
82
|
+
this.fields.metaDataDescription = this.fieldFactory('textInput', 'metaDataDescription');
|
|
81
83
|
}
|
|
82
84
|
autoCreateTitle() {
|
|
83
85
|
return this.createProduct().autoCreateTitle();
|
package/lib/helpers/Utilities.js
CHANGED
|
@@ -175,5 +175,25 @@ class Utilities {
|
|
|
175
175
|
const result = str.replace(/([A-Z])/g, ' $1');
|
|
176
176
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
177
177
|
}
|
|
178
|
+
singularizeProductType(word) {
|
|
179
|
+
const irregulars = {
|
|
180
|
+
Blazers: 'Blazer',
|
|
181
|
+
Jumpsuits: 'Jumpsuit',
|
|
182
|
+
Skirts: 'Skirt',
|
|
183
|
+
Tops: 'Top',
|
|
184
|
+
Dresses: 'Dress',
|
|
185
|
+
'Suit Jacket': '',
|
|
186
|
+
'Shirts & Blouses': '',
|
|
187
|
+
Outerwear: '',
|
|
188
|
+
// ... potentially more irregulars
|
|
189
|
+
};
|
|
190
|
+
if (irregulars.hasOwnProperty(word)) {
|
|
191
|
+
return irregulars[word];
|
|
192
|
+
}
|
|
193
|
+
if (word.endsWith('s')) {
|
|
194
|
+
return word.slice(0, -1);
|
|
195
|
+
}
|
|
196
|
+
return word;
|
|
197
|
+
}
|
|
178
198
|
}
|
|
179
199
|
exports.default = Utilities;
|
package/lib/models/Product.d.ts
CHANGED
|
@@ -14,7 +14,12 @@ export default class Product extends Base {
|
|
|
14
14
|
toObjForTypesense(): TypesenseProductObj;
|
|
15
15
|
updateSelfFromTranslatedTextArray(translatedTextArray?: string[]): void;
|
|
16
16
|
autoCreateTitle(): string;
|
|
17
|
-
|
|
17
|
+
autoCreateMetaDataTitle(): string;
|
|
18
|
+
autoCreateDescriptionHTML(t?: (text: string) => string, additionalSections?: {
|
|
19
|
+
title: string;
|
|
20
|
+
attributes: string[];
|
|
21
|
+
}[]): string;
|
|
22
|
+
autoCreateMetaDescription(): string;
|
|
18
23
|
generateSchemaForTypesense(name?: string): {
|
|
19
24
|
default_sorting_field: string;
|
|
20
25
|
fields: ({
|
package/lib/models/Product.js
CHANGED
|
@@ -35,6 +35,8 @@ class Product extends Base_1.default {
|
|
|
35
35
|
editorAuthorizations: (props === null || props === void 0 ? void 0 : props.editorAuthorizations) || {},
|
|
36
36
|
rfidTag: (props === null || props === void 0 ? void 0 : props.rfidTag) || '',
|
|
37
37
|
sku: (props === null || props === void 0 ? void 0 : props.sku) || '',
|
|
38
|
+
metaDataTitle: (props === null || props === void 0 ? void 0 : props.metaDataTitle) || '',
|
|
39
|
+
metaDataDescription: (props === null || props === void 0 ? void 0 : props.metaDataDescription) || '',
|
|
38
40
|
};
|
|
39
41
|
this.filterAttributes = {
|
|
40
42
|
documentId: (props === null || props === void 0 ? void 0 : props.documentId) || this.utilities.makeRandId(28),
|
|
@@ -405,78 +407,151 @@ class Product extends Base_1.default {
|
|
|
405
407
|
});
|
|
406
408
|
}
|
|
407
409
|
autoCreateTitle() {
|
|
408
|
-
const color = this.filterAttributes
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (['Blazers', 'Jumpsuits', 'Skirts', 'Tops'].includes(productType)) {
|
|
416
|
-
productType = productType.substring(0, productType.length - 1);
|
|
417
|
-
}
|
|
418
|
-
if (productType === 'Dresses') {
|
|
419
|
-
productType = 'Dress';
|
|
420
|
-
}
|
|
421
|
-
let result;
|
|
422
|
-
if (brand.includes('Vintage')) {
|
|
423
|
-
if (productType !== '') {
|
|
424
|
-
if (productStyle.length === 0) {
|
|
425
|
-
result = `${color.trim()} ${brand.trim()} ${productType.trim()}`;
|
|
426
|
-
}
|
|
427
|
-
result = `${color.trim()} ${brand.trim()} ${productStyle.trim()} ${productType.trim()}`;
|
|
410
|
+
const { color, productType, productStyle } = this.filterAttributes;
|
|
411
|
+
const singularProductType = this.utilities.singularizeProductType(productType);
|
|
412
|
+
// Function to build the title without brand and size
|
|
413
|
+
const buildTitle = (includeProductType) => {
|
|
414
|
+
const parts = [color.trim()];
|
|
415
|
+
if (productStyle && productStyle.length > 0) {
|
|
416
|
+
parts.push(productStyle.join(', ').trim());
|
|
428
417
|
}
|
|
429
|
-
|
|
430
|
-
|
|
418
|
+
if (includeProductType && singularProductType) {
|
|
419
|
+
parts.push(singularProductType.trim());
|
|
431
420
|
}
|
|
432
|
-
return
|
|
421
|
+
return parts.join(' ');
|
|
422
|
+
};
|
|
423
|
+
// Generate the result
|
|
424
|
+
let result = buildTitle(true);
|
|
425
|
+
if (!singularProductType) {
|
|
426
|
+
// If product type should not be included in the title
|
|
427
|
+
result = buildTitle(false);
|
|
433
428
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
429
|
+
return this.utilities.capitalizeString(result).trim();
|
|
430
|
+
}
|
|
431
|
+
autoCreateMetaDataTitle() {
|
|
432
|
+
const { color, productType, productStyle, brand, size } = this.filterAttributes;
|
|
433
|
+
// Singularize the product type
|
|
434
|
+
const singularProductType = this.utilities.singularizeProductType(productType);
|
|
435
|
+
// Function to build the title
|
|
436
|
+
const buildTitle = (includeProductType) => {
|
|
437
|
+
const parts = [color.trim(), brand.trim()];
|
|
438
|
+
if (productStyle && productStyle.length > 0) {
|
|
439
|
+
parts.push(productStyle.join(', ').trim());
|
|
437
440
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
if (includeProductType && singularProductType) {
|
|
442
|
+
parts.push(singularProductType.trim());
|
|
443
|
+
}
|
|
444
|
+
const baseTitle = parts.join(' ');
|
|
445
|
+
const titleWithBrand = brand.includes('Vintage') ? baseTitle : `${baseTitle} by ${brand.trim()}`;
|
|
446
|
+
// Add size to the end of the title if it's available
|
|
447
|
+
return size && size.trim() !== '' ? `${titleWithBrand}, Size ${size.trim()}` : titleWithBrand;
|
|
448
|
+
};
|
|
449
|
+
// Generate the result
|
|
450
|
+
let result = buildTitle(true);
|
|
451
|
+
if (!singularProductType) {
|
|
452
|
+
// If product type should not be included in the title
|
|
453
|
+
result = buildTitle(false);
|
|
442
454
|
}
|
|
443
455
|
return this.utilities.capitalizeString(result).trim();
|
|
444
456
|
}
|
|
445
|
-
autoCreateDescriptionHTML() {
|
|
457
|
+
autoCreateDescriptionHTML(t = (str) => str, additionalSections = []) {
|
|
446
458
|
var _a;
|
|
447
|
-
const
|
|
448
|
-
const color = this.filterAttributes
|
|
449
|
-
const
|
|
450
|
-
const productRemarks = this.consignmentAttributes.productRemarks;
|
|
451
|
-
const conditionRemarks = this.consignmentAttributes.conditionRemarks;
|
|
452
|
-
const condition = this.filterAttributes.condition;
|
|
453
|
-
const priceNew = this.consignmentAttributes.purchasePrice;
|
|
454
|
-
const yearPurchased = this.consignmentAttributes.yearPurchased;
|
|
455
|
-
const materials = this.materialCompJoinedString();
|
|
456
|
-
const sizeComment = this.consignmentAttributes.sizeComment;
|
|
459
|
+
const { compareAtPrice } = this.attributes;
|
|
460
|
+
const { color, productCategory, productType, productStyle, condition, size, gender } = this.filterAttributes;
|
|
461
|
+
const { productRemarks, conditionRemarks, purchasePrice, yearPurchased, sizeComment, majorDefects, minorDefects } = this.consignmentAttributes;
|
|
457
462
|
const measurements = this.measurementsJoinedString(this.filterAttributes.measurements);
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
463
|
+
const materials = this.materialCompJoinedString();
|
|
464
|
+
const fit = ((_a = options_1.sizeCommentOptions.find((option) => option.value === sizeComment)) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
465
|
+
const joinedProductStyle = productStyle.join(', ');
|
|
466
|
+
const joinedMajorDefects = majorDefects.join(', ');
|
|
467
|
+
const joinedMinorDefects = minorDefects.join(', ');
|
|
468
|
+
// Group the base attributes
|
|
469
|
+
const baseAttributeSections = [
|
|
470
|
+
{
|
|
471
|
+
title: 'Product Details',
|
|
472
|
+
attributes: [
|
|
473
|
+
productCategory && `${t('Category')}: ${t(productCategory)}`,
|
|
474
|
+
productType && `${t('Type')}: ${t(productType)}`,
|
|
475
|
+
size && `${t('Size')}: ${t(size)}`,
|
|
476
|
+
gender && `${t('Gender')}: ${t(gender)}`,
|
|
477
|
+
].filter(Boolean),
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
title: 'Style & Condition',
|
|
481
|
+
attributes: [
|
|
482
|
+
fit && `${t('Fit')}: ${t(fit)}`,
|
|
483
|
+
condition && `${t('Condition')}: ${t(condition)}`,
|
|
484
|
+
conditionRemarks && `${t('Condition Remarks')}: ${t(conditionRemarks)}`,
|
|
485
|
+
color && `${t('Color')}: ${t(color)}`,
|
|
486
|
+
productStyle.length > 0 && `${t('Style')}: ${t(joinedProductStyle)}`,
|
|
487
|
+
].filter(Boolean),
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
title: 'Material & Measurements',
|
|
491
|
+
attributes: [
|
|
492
|
+
materials && `${t('Material')}: ${t(materials)}`,
|
|
493
|
+
measurements && `${t('Measurements')}: ${t(measurements)}`,
|
|
494
|
+
].filter(Boolean),
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
title: 'Purchase Details',
|
|
498
|
+
attributes: [
|
|
499
|
+
compareAtPrice && `${t('Original price')}: ${t(purchasePrice)}`,
|
|
500
|
+
purchasePrice && `${t('Purchase price')}: ${t(purchasePrice)}`,
|
|
501
|
+
yearPurchased && `${t('Year purchased')}: ${t(yearPurchased)}`,
|
|
502
|
+
].filter(Boolean),
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
title: 'Additional Remarks',
|
|
506
|
+
attributes: [
|
|
507
|
+
productRemarks && `${t('Remarks')}: ${t(productRemarks)}`,
|
|
508
|
+
majorDefects.length > 0 && `${t('Major Defects')}: ${t(joinedMajorDefects)}`,
|
|
509
|
+
minorDefects.length > 0 && `${t('Minor Defects')}: ${t(joinedMinorDefects)}`,
|
|
510
|
+
].filter(Boolean),
|
|
511
|
+
},
|
|
512
|
+
];
|
|
513
|
+
let descriptionHTML = '';
|
|
514
|
+
// Generate HTML for base attribute sections
|
|
515
|
+
baseAttributeSections.forEach((section) => {
|
|
516
|
+
const sectionHTML = section.attributes
|
|
517
|
+
.map((attribute) => (attribute ? `<li>${attribute}</li>` : ''))
|
|
518
|
+
.filter(Boolean) // Removes any falsey values
|
|
519
|
+
.join('\n');
|
|
520
|
+
descriptionHTML += sectionHTML ? `<h3>${t(section.title)}</h3>\n<ul>\n${sectionHTML}\n</ul>` : '';
|
|
521
|
+
});
|
|
522
|
+
// Generate HTML for additional sections
|
|
523
|
+
additionalSections.forEach((section) => {
|
|
524
|
+
if (section.title && section.attributes && section.attributes.length > 0) {
|
|
525
|
+
const sectionHTML = section.attributes
|
|
526
|
+
.map((attribute) => (attribute ? `<li>${t(attribute)}</li>` : ''))
|
|
527
|
+
.filter(Boolean) // Removes any falsey values
|
|
528
|
+
.join('\n');
|
|
529
|
+
descriptionHTML += sectionHTML ? `<h3>${t(section.title)}</h3>\n<ul>\n${sectionHTML}\n</ul>` : '';
|
|
477
530
|
}
|
|
478
|
-
|
|
479
|
-
|
|
531
|
+
});
|
|
532
|
+
return t(this.attributes.description) + (descriptionHTML ? `\n${descriptionHTML}` : '');
|
|
533
|
+
}
|
|
534
|
+
autoCreateMetaDescription() {
|
|
535
|
+
var _a;
|
|
536
|
+
const { color, productType, productStyle, condition, size, brand } = this.filterAttributes;
|
|
537
|
+
const { productRemarks, sizeComment } = this.consignmentAttributes;
|
|
538
|
+
const materials = this.materialCompJoinedString();
|
|
539
|
+
const fit = ((_a = options_1.sizeCommentOptions.find((option) => option.value === sizeComment)) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
540
|
+
const joinedProductStyle = productStyle.join(', ');
|
|
541
|
+
const elements = [
|
|
542
|
+
brand && `Brand: ${brand}`,
|
|
543
|
+
size && `Size: ${size}`,
|
|
544
|
+
color && `Color: ${color}`,
|
|
545
|
+
productType && `Type: ${productType}`,
|
|
546
|
+
productStyle.length > 0 && `Style: ${joinedProductStyle}`,
|
|
547
|
+
condition && `Condition: ${condition}`,
|
|
548
|
+
materials && `Material: ${materials}`,
|
|
549
|
+
fit && `Fit: ${fit}`,
|
|
550
|
+
productRemarks && `Remarks: ${productRemarks}`,
|
|
551
|
+
].filter(Boolean); // Removes any falsey values
|
|
552
|
+
const baseDescription = elements.join(', ').slice(0, 157);
|
|
553
|
+
const ellipsis = baseDescription.length >= 157 ? '...' : '';
|
|
554
|
+
return baseDescription + ellipsis;
|
|
480
555
|
}
|
|
481
556
|
generateSchemaForTypesense(name = 'prod_products_20220503') {
|
|
482
557
|
return {
|
|
@@ -26,6 +26,8 @@ declare type ProductAttributes = {
|
|
|
26
26
|
editorAuthorizations?: EditorAuthorization;
|
|
27
27
|
rfidTag?: string;
|
|
28
28
|
sku?: string;
|
|
29
|
+
metaDataTitle?: string;
|
|
30
|
+
metaDataDescription?: string;
|
|
29
31
|
};
|
|
30
32
|
declare type ProductFilterAttributes = {
|
|
31
33
|
documentId: string;
|
|
@@ -161,6 +163,8 @@ declare type ProductAttributesFormFields = {
|
|
|
161
163
|
vendorName: SingleSelectFormField<string>;
|
|
162
164
|
rfidTag: TextInputFormField<string>;
|
|
163
165
|
sku: TextInputFormField<string>;
|
|
166
|
+
metaDataTitle: TextInputFormField<string>;
|
|
167
|
+
metaDataDescription: TextInputFormField<string>;
|
|
164
168
|
};
|
|
165
169
|
declare type ProductFilterAttributesFormFields = {
|
|
166
170
|
brand: SingleSelectFormField<string>;
|