@visns-studio/visns-components 3.0.0 → 3.0.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.
- package/components/crm/Form.jsx +57 -57
- package/package.json +1 -1
package/components/crm/Form.jsx
CHANGED
|
@@ -236,68 +236,68 @@ function Form({
|
|
|
236
236
|
...prevState,
|
|
237
237
|
[id]: e.target.checked,
|
|
238
238
|
}));
|
|
239
|
+
}
|
|
239
240
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const updatePostalData = (checked) => {
|
|
248
|
-
const postalData = checked
|
|
249
|
-
? {
|
|
250
|
-
postal_address1: formData.address1,
|
|
251
|
-
postal_address2: formData.address2,
|
|
252
|
-
postal_suburb: formData.suburb,
|
|
253
|
-
postal_postcode: formData.postcode,
|
|
254
|
-
postal_state: formData.state,
|
|
255
|
-
postal_country: formData.country,
|
|
256
|
-
}
|
|
257
|
-
: {
|
|
258
|
-
postal_address1: '',
|
|
259
|
-
postal_address2: '',
|
|
260
|
-
postal_suburb: '',
|
|
261
|
-
postal_postcode: '',
|
|
262
|
-
postal_state: '',
|
|
263
|
-
postal_country: '',
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
updateFormData(postalData);
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
if (id === 'same_address') {
|
|
270
|
-
updatePostalData(e.target.checked);
|
|
271
|
-
}
|
|
241
|
+
const updateFormData = (dataToUpdate) => {
|
|
242
|
+
setFormData((prevState) => ({
|
|
243
|
+
...prevState,
|
|
244
|
+
...dataToUpdate,
|
|
245
|
+
}));
|
|
246
|
+
};
|
|
272
247
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
248
|
+
const updatePostalData = (checked) => {
|
|
249
|
+
const postalData = checked
|
|
250
|
+
? {
|
|
251
|
+
postal_address1: formData.address1,
|
|
252
|
+
postal_address2: formData.address2,
|
|
253
|
+
postal_suburb: formData.suburb,
|
|
254
|
+
postal_postcode: formData.postcode,
|
|
255
|
+
postal_state: formData.state,
|
|
256
|
+
postal_country: formData.country,
|
|
257
|
+
}
|
|
258
|
+
: {
|
|
259
|
+
postal_address1: '',
|
|
260
|
+
postal_address2: '',
|
|
261
|
+
postal_suburb: '',
|
|
262
|
+
postal_postcode: '',
|
|
263
|
+
postal_state: '',
|
|
264
|
+
postal_country: '',
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
updateFormData(postalData);
|
|
268
|
+
};
|
|
277
269
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
showObject.value.length > 0
|
|
287
|
-
) {
|
|
288
|
-
field.hide = !showObject.value.includes(
|
|
289
|
-
e.target.checked
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
return field;
|
|
293
|
-
});
|
|
270
|
+
if (id === 'same_address') {
|
|
271
|
+
updatePostalData(e.target.checked);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (e.target.dataset.show) {
|
|
275
|
+
const _show = e.target.dataset.show
|
|
276
|
+
? JSON.parse(e.target.dataset.show)
|
|
277
|
+
: [];
|
|
294
278
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
279
|
+
if (_show.length > 0) {
|
|
280
|
+
const updatedFields = formSettings.fields.map((field) => {
|
|
281
|
+
const showObject = _show.find(
|
|
282
|
+
(showItem) => showItem.id === field.id
|
|
283
|
+
);
|
|
284
|
+
if (
|
|
285
|
+
showObject &&
|
|
286
|
+
showObject.value &&
|
|
287
|
+
showObject.value.length > 0
|
|
288
|
+
) {
|
|
289
|
+
field.hide = !showObject.value.includes(
|
|
290
|
+
e.target.checked
|
|
291
|
+
);
|
|
300
292
|
}
|
|
293
|
+
return field;
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
if (updateForm) {
|
|
297
|
+
updateForm((prevState) => ({
|
|
298
|
+
...prevState,
|
|
299
|
+
fields: updatedFields,
|
|
300
|
+
}));
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
}
|
package/package.json
CHANGED