rerobe-js-orm 3.0.6 → 3.0.7
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 +3 -2
- package/lib/form-states/Product/ProductFormState.d.ts +1 -0
- package/lib/form-states/Product/ProductFormState.js +38 -11
- package/lib/form-states/Product/options.d.ts +4 -0
- package/lib/form-states/Product/options.js +40 -1
- package/lib/models/Product.js +7 -0
- package/lib/types/rerobe-product-types.d.ts +7 -4
- package/package.json +1 -1
|
@@ -33,17 +33,18 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
33
33
|
const productFilterAttributes = {
|
|
34
34
|
documentId: (_m = props.props) === null || _m === void 0 ? void 0 : _m.documentId,
|
|
35
35
|
brand: props.fields.brand.selectedValue,
|
|
36
|
+
size: props.fields.size.selectedValue,
|
|
36
37
|
clothingSize: props.fields.clothingSize.selectedValues,
|
|
38
|
+
jeanSize: props.fields.jeanSize.selectedValue,
|
|
39
|
+
shoeSize: props.fields.shoeSize.selectedValue,
|
|
37
40
|
color: props.fields.color.selectedValue,
|
|
38
41
|
condition: props.fields.condition.selectedValue,
|
|
39
42
|
gender: props.fields.gender.selectedValue,
|
|
40
|
-
jeanSize: props.fields.jeanSize.selectedValue,
|
|
41
43
|
materialComposition: props.fields.materialComposition.selectedValue,
|
|
42
44
|
priceRange: props.fields.priceRange.inputValue,
|
|
43
45
|
productCategory: props.fields.productCategory.selectedValue,
|
|
44
46
|
productType: props.fields.productType.selectedValue,
|
|
45
47
|
productStyle: props.fields.productStyle.selectedValues,
|
|
46
|
-
shoeSize: props.fields.shoeSize.selectedValue,
|
|
47
48
|
measurements: props.fields.measurements.selectedValue || {},
|
|
48
49
|
featuredCollections: props.fields.featuredCollections.selectedValues || [],
|
|
49
50
|
tags: props.fields.tags.selectedValues || [],
|
|
@@ -27,19 +27,21 @@ class ProductFormState extends FormState_1.default {
|
|
|
27
27
|
this.fields.measurements = this.fieldFactory('singleSelect', 'measurements');
|
|
28
28
|
// ProductFilterAttributesFormFields
|
|
29
29
|
this.fields.brand = this.fieldFactory('singleSelect', 'brand', options_1.brands);
|
|
30
|
-
this.fields.
|
|
30
|
+
this.fields.size = this.fieldFactory('singleSelect', 'size', options_1.clothingSizeOptions);
|
|
31
31
|
this.fields.color = this.fieldFactory('singleSelect', 'color', options_1.colors);
|
|
32
32
|
this.fields.condition = this.fieldFactory('singleSelect', 'condition', options_1.conditions);
|
|
33
33
|
this.fields.majorDefects = this.fieldFactory('multiSelect', 'majorDefects', options_1.majorDefectOptions);
|
|
34
34
|
this.fields.minorDefects = this.fieldFactory('multiSelect', 'minorDefects', options_1.minorDefectOptions);
|
|
35
35
|
this.fields.gender = this.fieldFactory('singleSelect', 'gender', options_1.gender);
|
|
36
|
-
this.fields.jeanSize = this.fieldFactory('singleSelect', 'jeanSize', options_1.jeanSizes);
|
|
37
36
|
this.fields.materialComposition = this.fieldFactory('singleSelect', 'materialComposition', options_1.clothingMaterials);
|
|
38
37
|
this.fields.priceRange = this.fieldFactory('textInput', 'priceRange');
|
|
39
38
|
this.fields.productCategory = this.fieldFactory('singleSelect', 'productCategory', options_1.productCategories);
|
|
40
39
|
this.fields.productType = this.fieldFactory('singleSelect', 'productType');
|
|
41
40
|
this.fields.productStyle = this.fieldFactory('multiSelect', 'productStyle');
|
|
41
|
+
// Deprecated soon
|
|
42
|
+
this.fields.clothingSize = this.fieldFactory('multiSelect', 'clothingSize', options_1.clothingSizeOptions);
|
|
42
43
|
this.fields.shoeSize = this.fieldFactory('singleSelect', 'shoeSize', options_1.shoeSizes);
|
|
44
|
+
this.fields.jeanSize = this.fieldFactory('singleSelect', 'jeanSize', options_1.jeanSizes);
|
|
43
45
|
// ProductConsignmentAttributesFormFields
|
|
44
46
|
this.fields.previousSellers = this.fieldFactory('multiSelect', 'previousSellers');
|
|
45
47
|
this.fields.publishType = this.fieldFactory('singleSelect', 'publishType', options_1.publishTypeOptions);
|
|
@@ -141,6 +143,10 @@ class ProductFormState extends FormState_1.default {
|
|
|
141
143
|
this.fields.shoeSize.hidden = true;
|
|
142
144
|
this.fields.shoeSize.valid = false;
|
|
143
145
|
this.fields.shoeSize.selectedValue = '';
|
|
146
|
+
// Reset size fields except options
|
|
147
|
+
this.fields.size.hidden = false;
|
|
148
|
+
this.fields.size.valid = false;
|
|
149
|
+
this.fields.size.selectedValue = '';
|
|
144
150
|
}
|
|
145
151
|
conditionSelectHandler(value) {
|
|
146
152
|
// Mutate condition selectedValue and valid prop
|
|
@@ -176,6 +182,10 @@ class ProductFormState extends FormState_1.default {
|
|
|
176
182
|
this.fields.shoeSize.hidden = true;
|
|
177
183
|
this.fields.shoeSize.selectedValue = '';
|
|
178
184
|
this.fields.shoeSize.valid = false;
|
|
185
|
+
// Reset Size
|
|
186
|
+
this.fields.size.hidden = false;
|
|
187
|
+
this.fields.size.selectedValue = '';
|
|
188
|
+
this.fields.size.valid = false;
|
|
179
189
|
}
|
|
180
190
|
productTypeSelectHandler(value) {
|
|
181
191
|
// Mutate productType selectedValue and valid prop
|
|
@@ -199,6 +209,10 @@ class ProductFormState extends FormState_1.default {
|
|
|
199
209
|
this.fields.shoeSize.selectedValue = '';
|
|
200
210
|
this.fields.shoeSize.valid = false;
|
|
201
211
|
this.fields.shoeSize.hidden = !value || this.fields.productCategory.selectedValue !== 'Shoes';
|
|
212
|
+
// Reset size
|
|
213
|
+
this.fields.size.selectedValue = '';
|
|
214
|
+
this.fields.size.valid = false;
|
|
215
|
+
this.fields.size.hidden = false;
|
|
202
216
|
}
|
|
203
217
|
setPriceRangeFromPrice(value) {
|
|
204
218
|
if (Number(value) > 0 && Number(value) <= 500) {
|
|
@@ -413,7 +427,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
413
427
|
}
|
|
414
428
|
}
|
|
415
429
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
416
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
430
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
417
431
|
let options = fieldOptions || [];
|
|
418
432
|
let hidden = false;
|
|
419
433
|
if (fieldType === 'singleSelect') {
|
|
@@ -477,6 +491,19 @@ class ProductFormState extends FormState_1.default {
|
|
|
477
491
|
hidden = !this.props.productCategory;
|
|
478
492
|
onChangeHandler = (val) => this.productTypeSelectHandler(val);
|
|
479
493
|
}
|
|
494
|
+
if (fieldKey === 'size') {
|
|
495
|
+
let selectedSizeOptions = [];
|
|
496
|
+
if (this.props.size) {
|
|
497
|
+
selectedSizeOptions = [{ label: this.props.size, value: this.props.size }];
|
|
498
|
+
if (!options.map((o) => o.value).includes(this.props.size)) {
|
|
499
|
+
options.splice(0, 0, ...selectedSizeOptions);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if ((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.sizes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
503
|
+
const sizesOptions = this.opts.sizes.map((t) => ({ label: t, value: t }));
|
|
504
|
+
options = this.utilities.uniqObjArray([...selectedSizeOptions, ...sizesOptions], 'value');
|
|
505
|
+
}
|
|
506
|
+
}
|
|
480
507
|
if (fieldKey === 'jeanSize') {
|
|
481
508
|
hidden = this.props.productCategory !== 'Clothing' || this.props.productType !== 'Jeans';
|
|
482
509
|
let selectedJeanSizeOptions = [];
|
|
@@ -486,7 +513,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
486
513
|
options.splice(0, 0, ...selectedJeanSizeOptions);
|
|
487
514
|
}
|
|
488
515
|
}
|
|
489
|
-
if ((
|
|
516
|
+
if ((_d = (_c = this.opts) === null || _c === void 0 ? void 0 : _c.jeanSizes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
490
517
|
const jeanSizesOptions = this.opts.jeanSizes.map((t) => ({ label: t, value: t }));
|
|
491
518
|
options = this.utilities.uniqObjArray([...selectedJeanSizeOptions, ...jeanSizesOptions], 'value');
|
|
492
519
|
}
|
|
@@ -500,7 +527,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
500
527
|
options.splice(0, 0, ...selectedShoeSizeOptions);
|
|
501
528
|
}
|
|
502
529
|
}
|
|
503
|
-
if ((
|
|
530
|
+
if ((_f = (_e = this.opts) === null || _e === void 0 ? void 0 : _e.shoeSizes) === null || _f === void 0 ? void 0 : _f.length) {
|
|
504
531
|
const shoeSizesOptions = this.opts.shoeSizes.map((t) => ({ label: t, value: t }));
|
|
505
532
|
options = this.utilities.uniqObjArray([...selectedShoeSizeOptions, ...shoeSizesOptions], 'value');
|
|
506
533
|
}
|
|
@@ -513,7 +540,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
513
540
|
options.splice(0, 0, ...selectedBrandOptions);
|
|
514
541
|
}
|
|
515
542
|
}
|
|
516
|
-
if ((
|
|
543
|
+
if ((_h = (_g = this.opts) === null || _g === void 0 ? void 0 : _g.brands) === null || _h === void 0 ? void 0 : _h.length) {
|
|
517
544
|
const brandsOptions = this.opts.brands.map((t) => ({ label: t, value: t }));
|
|
518
545
|
options = this.utilities.uniqObjArray([...selectedBrandOptions, ...brandsOptions], 'value');
|
|
519
546
|
}
|
|
@@ -526,13 +553,13 @@ class ProductFormState extends FormState_1.default {
|
|
|
526
553
|
options.splice(0, 0, ...selectedColorOptions);
|
|
527
554
|
}
|
|
528
555
|
}
|
|
529
|
-
if ((
|
|
556
|
+
if ((_k = (_j = this.opts) === null || _j === void 0 ? void 0 : _j.colors) === null || _k === void 0 ? void 0 : _k.length) {
|
|
530
557
|
const colorsOptions = this.opts.colors.map((t) => ({ label: t, value: t }));
|
|
531
558
|
options = this.utilities.uniqObjArray([...selectedColorOptions, ...colorsOptions], 'value');
|
|
532
559
|
}
|
|
533
560
|
}
|
|
534
561
|
if (fieldKey === 'condition') {
|
|
535
|
-
if ((
|
|
562
|
+
if ((_m = (_l = this.opts) === null || _l === void 0 ? void 0 : _l.conditions) === null || _m === void 0 ? void 0 : _m.length) {
|
|
536
563
|
const conditionsOptions = this.opts.conditions.map((t) => ({
|
|
537
564
|
label: t.label || '',
|
|
538
565
|
value: t.value || '',
|
|
@@ -587,7 +614,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
587
614
|
if (this.props.gender === 'Man') {
|
|
588
615
|
options = options_1.manClothingSizeOptions;
|
|
589
616
|
}
|
|
590
|
-
if ((
|
|
617
|
+
if ((_p = (_o = this.opts) === null || _o === void 0 ? void 0 : _o.clothingSizes) === null || _p === void 0 ? void 0 : _p.length) {
|
|
591
618
|
const clothingSizesOptions = this.opts.clothingSizes.map((t) => ({ label: t, value: t }));
|
|
592
619
|
options = this.utilities.uniqObjArray(clothingSizesOptions, 'value');
|
|
593
620
|
}
|
|
@@ -599,7 +626,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
599
626
|
selectedMajorDefectsOptions = this.props.majorDefects.map((t) => ({ label: t, value: t }));
|
|
600
627
|
}
|
|
601
628
|
let majorDefectsOptions = [];
|
|
602
|
-
if ((
|
|
629
|
+
if ((_r = (_q = this.opts) === null || _q === void 0 ? void 0 : _q.majorDefects) === null || _r === void 0 ? void 0 : _r.length) {
|
|
603
630
|
majorDefectsOptions = this.opts.majorDefects.map((t) => ({ label: t, value: t }));
|
|
604
631
|
}
|
|
605
632
|
options = this.utilities.uniqObjArray([...selectedMajorDefectsOptions, ...majorDefectsOptions], 'value');
|
|
@@ -610,7 +637,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
610
637
|
selectedMinorDefectsOptions = this.props.minorDefects.map((t) => ({ label: t, value: t }));
|
|
611
638
|
}
|
|
612
639
|
let minorDefectsOptions = [];
|
|
613
|
-
if ((
|
|
640
|
+
if ((_t = (_s = this.opts) === null || _s === void 0 ? void 0 : _s.minorDefects) === null || _t === void 0 ? void 0 : _t.length) {
|
|
614
641
|
minorDefectsOptions = this.opts.minorDefects.map((t) => ({ label: t, value: t }));
|
|
615
642
|
}
|
|
616
643
|
options = this.utilities.uniqObjArray([...selectedMinorDefectsOptions, ...minorDefectsOptions], 'value');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.gender = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
3
|
+
exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.gender = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.sizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
4
4
|
const product_constants_1 = require("../../constants/product-constants");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const availableForSaleOptions = [
|
|
@@ -34,6 +34,45 @@ const statusOptions = Object.values(product_constants_1.PRODUCT_STATES).map((val
|
|
|
34
34
|
value: val,
|
|
35
35
|
}));
|
|
36
36
|
exports.statusOptions = statusOptions;
|
|
37
|
+
const sizeOptions = [
|
|
38
|
+
{
|
|
39
|
+
label: 'No Size',
|
|
40
|
+
value: 'No Size',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'XXS',
|
|
44
|
+
value: 'XXS',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'XS',
|
|
48
|
+
value: 'XS',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: 'S',
|
|
52
|
+
value: 'S',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'M',
|
|
56
|
+
value: 'M',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: 'L',
|
|
60
|
+
value: 'L',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: 'XL',
|
|
64
|
+
value: 'XL',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: 'XXL',
|
|
68
|
+
value: 'XXL',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: 'XXXL',
|
|
72
|
+
value: 'XXXL',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
exports.sizeOptions = sizeOptions;
|
|
37
76
|
const clothingSizeOptions = [
|
|
38
77
|
{
|
|
39
78
|
label: 'No Size',
|
package/lib/models/Product.js
CHANGED
|
@@ -42,6 +42,7 @@ class Product extends Base_1.default {
|
|
|
42
42
|
clothingSize: (props === null || props === void 0 ? void 0 : props.clothingSize) || [],
|
|
43
43
|
jeanSize: (props === null || props === void 0 ? void 0 : props.jeanSize) || '',
|
|
44
44
|
shoeSize: (props === null || props === void 0 ? void 0 : props.shoeSize) || '',
|
|
45
|
+
size: (props === null || props === void 0 ? void 0 : props.size) || '',
|
|
45
46
|
productCategory: (props === null || props === void 0 ? void 0 : props.productCategory) || '',
|
|
46
47
|
productType: (props === null || props === void 0 ? void 0 : props.productType) || '',
|
|
47
48
|
productStyle: (props === null || props === void 0 ? void 0 : props.productStyle) || [],
|
|
@@ -279,6 +280,7 @@ class Product extends Base_1.default {
|
|
|
279
280
|
toObjForTypesense() {
|
|
280
281
|
const stagedObj = {
|
|
281
282
|
brand: this.utilities.sanitizeString(this.filterAttributes.brand),
|
|
283
|
+
size: this.utilities.sanitizeString(this.filterAttributes.size),
|
|
282
284
|
clothingSize: this.utilities.sanitzeStringArr(this.filterAttributes.clothingSize),
|
|
283
285
|
jeanSize: this.utilities.sanitizeString(this.filterAttributes.jeanSize),
|
|
284
286
|
shoeSize: this.utilities.sanitizeString(this.filterAttributes.shoeSize),
|
|
@@ -472,6 +474,11 @@ class Product extends Base_1.default {
|
|
|
472
474
|
name: 'brand',
|
|
473
475
|
type: 'string',
|
|
474
476
|
},
|
|
477
|
+
{
|
|
478
|
+
facet: true,
|
|
479
|
+
name: 'size',
|
|
480
|
+
type: 'string',
|
|
481
|
+
},
|
|
475
482
|
{
|
|
476
483
|
facet: true,
|
|
477
484
|
name: 'clothingSize',
|
|
@@ -26,17 +26,18 @@ declare type ProductAttributes = {
|
|
|
26
26
|
declare type ProductFilterAttributes = {
|
|
27
27
|
documentId: string;
|
|
28
28
|
brand: string;
|
|
29
|
+
size: string;
|
|
29
30
|
clothingSize: string[];
|
|
31
|
+
shoeSize: string;
|
|
32
|
+
jeanSize: string;
|
|
30
33
|
color: string;
|
|
31
34
|
condition: string;
|
|
32
35
|
gender: string;
|
|
33
|
-
jeanSize: string;
|
|
34
36
|
materialComposition: MaterialComposition;
|
|
35
37
|
priceRange: string;
|
|
36
38
|
productCategory: string;
|
|
37
39
|
productType: string;
|
|
38
40
|
productStyle: string[];
|
|
39
|
-
shoeSize: string;
|
|
40
41
|
measurements: Measurements;
|
|
41
42
|
featuredCollections?: string[];
|
|
42
43
|
tags?: string[];
|
|
@@ -156,17 +157,18 @@ declare type ProductAttributesFormFields = {
|
|
|
156
157
|
};
|
|
157
158
|
declare type ProductFilterAttributesFormFields = {
|
|
158
159
|
brand: SingleSelectFormField<string>;
|
|
160
|
+
size: SingleSelectFormField<string>;
|
|
159
161
|
clothingSize: MultiSelectFormField<string>;
|
|
162
|
+
jeanSize: SingleSelectFormField<string>;
|
|
163
|
+
shoeSize: SingleSelectFormField<string>;
|
|
160
164
|
color: SingleSelectFormField<string>;
|
|
161
165
|
condition: SingleSelectFormField<string>;
|
|
162
166
|
gender: SingleSelectFormField<string>;
|
|
163
|
-
jeanSize: SingleSelectFormField<string>;
|
|
164
167
|
materialComposition: SingleSelectFormField<MaterialComposition>;
|
|
165
168
|
priceRange: TextInputFormField<string>;
|
|
166
169
|
productCategory: SingleSelectFormField<string>;
|
|
167
170
|
productType: SingleSelectFormField<string>;
|
|
168
171
|
productStyle: MultiSelectFormField<string>;
|
|
169
|
-
shoeSize: SingleSelectFormField<string>;
|
|
170
172
|
featuredCollections: MultiSelectFormField<string>;
|
|
171
173
|
tags: MultiSelectFormField<string>;
|
|
172
174
|
};
|
|
@@ -239,6 +241,7 @@ declare type InventoryLocation = {
|
|
|
239
241
|
};
|
|
240
242
|
declare type TypesenseProductObj = {
|
|
241
243
|
brand: string;
|
|
244
|
+
size: string;
|
|
242
245
|
clothingSize: string[];
|
|
243
246
|
jeanSize: string;
|
|
244
247
|
shoeSize: string;
|