rerobe-js-orm 4.7.9 → 4.8.1

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.
@@ -4,6 +4,7 @@ const MerchantFactory_1 = require("./MerchantFactory");
4
4
  const Merchant_1 = require("../../models/Merchant");
5
5
  class MerchantFromFormState extends MerchantFactory_1.default {
6
6
  createMerchant(fs) {
7
+ var _a;
7
8
  const MerchantMutableData = {
8
9
  name: fs.fields.name.inputValue,
9
10
  type: fs.fields.type.selectedValue,
@@ -23,6 +24,11 @@ class MerchantFromFormState extends MerchantFactory_1.default {
23
24
  organizationNumber: fs.fields.organizationNumber.inputValue,
24
25
  returnPolicy: fs.fields.returnPolicy.inputValue,
25
26
  };
27
+ // Include organizationNumbers if it has entries
28
+ const orgNumbers = (_a = fs.fields.organizationNumbers) === null || _a === void 0 ? void 0 : _a.selectedValue;
29
+ if (orgNumbers && Object.keys(orgNumbers).length > 0) {
30
+ MerchantMutableData.organizationNumbers = orgNumbers;
31
+ }
26
32
  return new Merchant_1.default(Object.assign(Object.assign({}, fs.props), MerchantMutableData));
27
33
  }
28
34
  }
@@ -15,6 +15,7 @@ class MerchantFormState extends FormState_1.default {
15
15
  this.fields.industry = this.fieldFactory('singleSelect', 'industry', options_1.industryOptions);
16
16
  this.fields.legalName = this.fieldFactory('textInput', 'legalName');
17
17
  this.fields.organizationNumber = this.fieldFactory('textInput', 'organizationNumber');
18
+ this.fields.organizationNumbers = this.fieldFactory('singleSelect', 'organizationNumbers');
18
19
  this.fields.returnPolicy = this.fieldFactory('textInput', 'returnPolicy');
19
20
  this.fields.phone = this.fieldFactory('textInput', 'phone');
20
21
  this.fields.address = this.fieldFactory('singleSelect', 'address');
@@ -32,7 +33,11 @@ class MerchantFormState extends FormState_1.default {
32
33
  }
33
34
  fieldFactory(fieldType, fieldKey, fieldOptions) {
34
35
  const options = fieldOptions || [];
35
- if (fieldType === 'textInput' && fieldKey !== 'address' && fieldKey !== 'webhooks' && fieldKey !== 'socialLinks') {
36
+ if (fieldType === 'textInput' &&
37
+ fieldKey !== 'address' &&
38
+ fieldKey !== 'webhooks' &&
39
+ fieldKey !== 'socialLinks' &&
40
+ fieldKey !== 'organizationNumbers') {
36
41
  const inputValue = this.props[fieldKey] || '';
37
42
  const valid = !!this.props[fieldKey];
38
43
  let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
@@ -102,6 +107,10 @@ class MerchantFormState extends FormState_1.default {
102
107
  !!Object.keys(this.props.socialLinks).length &&
103
108
  !!Object.values(this.props.socialLinks).filter((item) => !!item).length;
104
109
  }
110
+ else if (fieldKey === 'organizationNumbers') {
111
+ selectedValue = this.props.organizationNumbers || {};
112
+ valid = true; // organizationNumbers is optional
113
+ }
105
114
  else if (fieldKey === 'unitSystem') {
106
115
  onChangeHandler = (val) => this.unitSystemSelectHandler(val);
107
116
  selectedValue = this.props[fieldKey] || '';
@@ -84,6 +84,7 @@ export default class Merchant extends Base {
84
84
  isZettleUser?: boolean;
85
85
  hasStripeBluetoothReader?: boolean;
86
86
  organizationNumber?: string;
87
+ organizationNumbers?: Record<string, string>;
87
88
  returnPolicy?: string;
88
89
  stripeRegion?: string;
89
90
  hasAutomatedPayouts?: boolean;
@@ -49,6 +49,9 @@ class Merchant extends Base_1.default {
49
49
  tiktok: '',
50
50
  };
51
51
  this.organizationNumber = (props === null || props === void 0 ? void 0 : props.organizationNumber) || '';
52
+ if ((props === null || props === void 0 ? void 0 : props.organizationNumbers) && typeof props.organizationNumbers === 'object') {
53
+ this.organizationNumbers = props.organizationNumbers;
54
+ }
52
55
  this.returnPolicy = (props === null || props === void 0 ? void 0 : props.returnPolicy) || '';
53
56
  this.subscriptionStatus = (props === null || props === void 0 ? void 0 : props.subscriptionStatus) || merchant_constants_1.SUBSCRIPTION_STATUSES.trialing;
54
57
  this.hasActiveWebshop = (props === null || props === void 0 ? void 0 : props.hasActiveWebshop) || false;
@@ -135,16 +138,20 @@ class Merchant extends Base_1.default {
135
138
  if (this.hasReceiptPrinter) {
136
139
  mObj.hasReceiptPrinter = this.hasReceiptPrinter;
137
140
  }
141
+ if (this.organizationNumbers && Object.keys(this.organizationNumbers).length > 0) {
142
+ mObj.organizationNumbers = this.organizationNumbers;
143
+ }
138
144
  return mObj;
139
145
  }
140
146
  toMerchantMutableData() {
141
- return {
147
+ const data = {
142
148
  name: this.name,
143
149
  type: this.type,
144
150
  contactEmail: this.contactEmail,
145
151
  senderEmail: this.senderEmail,
146
152
  industry: this.industry,
147
153
  legalName: this.legalName,
154
+ organizationNumber: this.organizationNumber,
148
155
  phone: this.phone,
149
156
  address: this.address,
150
157
  currency: this.currency,
@@ -155,6 +162,10 @@ class Merchant extends Base_1.default {
155
162
  webhooks: this.webhooks,
156
163
  socialLinks: this.socialLinks,
157
164
  };
165
+ if (this.organizationNumbers && Object.keys(this.organizationNumbers).length > 0) {
166
+ data.organizationNumbers = this.organizationNumbers;
167
+ }
168
+ return data;
158
169
  }
159
170
  }
160
171
  Merchant.MERCHANT_TYPES = merchant_constants_1.MERCHANT_TYPES;
@@ -23,6 +23,7 @@ type MerchantMutableData = {
23
23
  webhooks: MerchantWebHook[];
24
24
  socialLinks: SocialLinksType | null;
25
25
  organizationNumber?: string;
26
+ organizationNumbers?: Record<string, string>;
26
27
  returnPolicy?: string;
27
28
  };
28
29
  type MerchantSystemOnlyMutableData = {
@@ -85,6 +86,7 @@ type MerchantFormFields = {
85
86
  industry: SingleSelectFormField<string>;
86
87
  legalName: TextInputFormField<string>;
87
88
  organizationNumber: TextInputFormField<string>;
89
+ organizationNumbers: SingleSelectFormField<Record<string, string>>;
88
90
  returnPolicy: TextInputFormField<string>;
89
91
  phone: TextInputFormField<string>;
90
92
  address: SingleSelectFormField<AddressInput>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.7.9",
3
+ "version": "4.8.1",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "type": "git",
22
22
  "url": "git+https://github.com/ReRobe/rerobe-object-factories.git"
23
23
  },
24
- "keywords": [],
24
+ "keywords": ["ribbn"],
25
25
  "license": "ISC",
26
26
  "bugs": {
27
27
  "url": "https://github.com/ReRobe/rerobe-product/issues"