diy-template-components 0.1.7 → 0.1.10

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/build/index.es.js CHANGED
@@ -6788,7 +6788,7 @@ const SingleVideoSlide$1 = props => {
6788
6788
  discount
6789
6789
  }) => {
6790
6790
  console.log('discountxx', props.data.price, props.data.discount);
6791
- return ((price - discount) / price * 100).toFixed(2);
6791
+ return (discount / price * 100).toFixed(2);
6792
6792
  };
6793
6793
 
6794
6794
  const classes = useWebinarPromotionPage();
@@ -6852,7 +6852,7 @@ const SingleVideoSlide$1 = props => {
6852
6852
  className: classes.priceContainer
6853
6853
  }, /*#__PURE__*/React.createElement("div", {
6854
6854
  className: classes.offerPrice
6855
- }, "\u20B9", data?.discount), /*#__PURE__*/React.createElement("p", {
6855
+ }, "\u20B9", data?.effectivePrice), /*#__PURE__*/React.createElement("p", {
6856
6856
  style: {
6857
6857
  fontSize: '20px',
6858
6858
  marginTop: '0px'
@@ -7458,6 +7458,54 @@ const FormPage = ({
7458
7458
  payload: formResponse
7459
7459
  };
7460
7460
  postApiCallForm(baseURLs, data, extraProps);
7461
+ setFormData({});
7462
+ };
7463
+
7464
+ const handleOnClick = (e, item, option) => {
7465
+ // if the checkbox is checked
7466
+ if (!e.target.checked) {
7467
+ // if the checkbox is checked and the solution array is empty
7468
+ if (!formData[item._id]?.solutionArray?.length) {
7469
+ setFormData({ ...formData,
7470
+ [item._id]: {
7471
+ questionName: item.text,
7472
+ solutionArray: [option.value],
7473
+ questionType: 'MC'
7474
+ }
7475
+ });
7476
+ } // if the checkbox is checked and the solution array is not empty and the value is already in the array remove it
7477
+ else if (formData[item._id]?.solutionArray?.includes(option.value)) {
7478
+ // if only one value is in the array remove it
7479
+ setFormData({ ...formData,
7480
+ [item._id]: {
7481
+ questionName: item.text,
7482
+ solutionArray: formData[item._id]?.solutionArray?.filter(item => item !== option.value),
7483
+ questionType: 'MC'
7484
+ }
7485
+ });
7486
+ }
7487
+ } // if the checkbox is unchecked
7488
+ else {
7489
+ // if the checkbox is unchecked and the solution array is empty
7490
+ if (typeof formData[item._id]?.solutionArray?.length === 'undefined') {
7491
+ setFormData({ ...formData,
7492
+ [item._id]: {
7493
+ questionName: item.text,
7494
+ solutionArray: [option.value],
7495
+ questionType: 'MC'
7496
+ }
7497
+ });
7498
+ } // if the checkbox is unchecked and the solution array is not empty and the value is not in the array add it
7499
+ else if (!formData[item._id]?.solutionArray?.includes(option.value)) {
7500
+ setFormData({ ...formData,
7501
+ [item._id]: {
7502
+ questionName: item.text,
7503
+ solutionArray: [...formData[item._id]?.solutionArray, option.value],
7504
+ questionType: 'MC'
7505
+ }
7506
+ });
7507
+ }
7508
+ }
7461
7509
  };
7462
7510
 
7463
7511
  return /*#__PURE__*/React.createElement("section", {
@@ -7480,6 +7528,7 @@ const FormPage = ({
7480
7528
  className: classes.inputFieldControl,
7481
7529
  required: item.isRequired,
7482
7530
  type: "text",
7531
+ value: formData[item._id]?.solutionArray?.[0] || '',
7483
7532
  placeholder: "Short answer",
7484
7533
  name: item._id,
7485
7534
  onChange: e => {
@@ -7501,33 +7550,9 @@ const FormPage = ({
7501
7550
  value: option.value,
7502
7551
  type: "checkbox",
7503
7552
  name: option.value,
7553
+ checked: formData[item._id]?.solutionArray?.includes(option.value),
7504
7554
  id: option.value,
7505
- onChange: e => {
7506
- setFormData({ ...formData,
7507
- [item._id]: {
7508
- questionName: item.text,
7509
- solutionArray: [],
7510
- questionType: 'SA'
7511
- }
7512
- });
7513
- },
7514
- onBlur: e => {
7515
- let newSolArray = [];
7516
-
7517
- if (formData[item._id]) {
7518
- if (!formData[item._id].solutionArray?.find(el => el === option.value)) {
7519
- newSolArray.push(e.target.value);
7520
- }
7521
- }
7522
-
7523
- setFormData({ ...formData,
7524
- [item._id]: {
7525
- questionName: item.text,
7526
- solutionArray: [...newSolArray],
7527
- questionType: 'SA'
7528
- }
7529
- });
7530
- }
7555
+ onClick: e => handleOnClick(e, item, option)
7531
7556
  }), /*#__PURE__*/React.createElement("label", {
7532
7557
  htmlFor: option.value
7533
7558
  }, option.value)))), item.type === 'SC' && /*#__PURE__*/React.createElement("div", {
@@ -7540,14 +7565,16 @@ const FormPage = ({
7540
7565
  // value={option.value}
7541
7566
  type: "radio",
7542
7567
  name: "text",
7543
- required: item.isRequired // name={option.value}
7568
+ required: item.isRequired,
7569
+ value: option.value,
7570
+ checked: formData[item._id]?.solutionArray?.[0] === option.value // name={option.value}
7544
7571
  // id={option.value}
7545
7572
  ,
7546
- onChange: e => {
7573
+ onClick: e => {
7547
7574
  setFormData({ ...formData,
7548
7575
  [item._id]: {
7549
7576
  questionName: item.text,
7550
- solutionArray: [item.text],
7577
+ solutionArray: [option.value],
7551
7578
  questionType: 'SC'
7552
7579
  }
7553
7580
  });