@visns-studio/visns-components 4.10.45 → 4.10.47
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/package.json +1 -1
- package/src/components/crm/Form.jsx +38 -70
package/package.json
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
78
78
|
},
|
|
79
79
|
"name": "@visns-studio/visns-components",
|
|
80
|
-
"version": "4.10.
|
|
80
|
+
"version": "4.10.47",
|
|
81
81
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
82
82
|
"main": "src/index.js",
|
|
83
83
|
"files": [
|
|
@@ -710,87 +710,55 @@ function Form({
|
|
|
710
710
|
});
|
|
711
711
|
}
|
|
712
712
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
async (file) => {
|
|
717
|
-
const toastId = toast.info(
|
|
718
|
-
`Uploading ${file.name}`,
|
|
719
|
-
{
|
|
720
|
-
progress: 0,
|
|
721
|
-
autoClose: false,
|
|
722
|
-
}
|
|
723
|
-
);
|
|
724
|
-
|
|
725
|
-
const fileRes = await Vapor.store(file, {
|
|
726
|
-
progress: (progress) => {
|
|
727
|
-
setUploadProgress(progress * 100);
|
|
728
|
-
toast.update(toastId, {
|
|
729
|
-
progress,
|
|
730
|
-
});
|
|
731
|
-
},
|
|
732
|
-
});
|
|
733
|
-
|
|
734
|
-
toast.update(toastId, {
|
|
735
|
-
render: `${file.name} uploaded successfully!`,
|
|
736
|
-
type: 'success',
|
|
737
|
-
autoClose: 3000,
|
|
738
|
-
});
|
|
713
|
+
const files = Array.isArray(formData[fileKey])
|
|
714
|
+
? formData[fileKey]
|
|
715
|
+
: [formData[fileKey]];
|
|
739
716
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
key: fileRes.key,
|
|
743
|
-
bucket: fileRes.bucket,
|
|
744
|
-
filename: file.name,
|
|
745
|
-
filesize: file.size,
|
|
746
|
-
extension: fileRes.extension,
|
|
747
|
-
file_relationship: fileKey,
|
|
748
|
-
fileable_field:
|
|
749
|
-
fileFieldSetting.fileable_field,
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
);
|
|
753
|
-
|
|
754
|
-
formData['uploadedFiles'] = await Promise.all(
|
|
755
|
-
uploadPromises
|
|
756
|
-
);
|
|
757
|
-
} else {
|
|
717
|
+
if (fileUpload && files.length > 0) {
|
|
718
|
+
const uploadPromises = files.map(async (file) => {
|
|
758
719
|
const toastId = toast.info(
|
|
759
|
-
`Uploading ${
|
|
720
|
+
`Uploading ${file.name}`,
|
|
760
721
|
{
|
|
761
722
|
progress: 0,
|
|
762
723
|
autoClose: false,
|
|
763
724
|
}
|
|
764
725
|
);
|
|
765
726
|
|
|
766
|
-
const fileRes = await Vapor.store(
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
progress
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
progress,
|
|
773
|
-
});
|
|
774
|
-
},
|
|
775
|
-
}
|
|
776
|
-
);
|
|
727
|
+
const fileRes = await Vapor.store(file, {
|
|
728
|
+
progress: (progress) => {
|
|
729
|
+
setUploadProgress(progress * 100);
|
|
730
|
+
toast.update(toastId, { progress });
|
|
731
|
+
},
|
|
732
|
+
});
|
|
777
733
|
|
|
778
734
|
toast.update(toastId, {
|
|
779
|
-
render: `${
|
|
735
|
+
render: `${file.name} uploaded successfully!`,
|
|
780
736
|
type: 'success',
|
|
781
737
|
autoClose: 3000,
|
|
782
738
|
});
|
|
783
739
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
740
|
+
return {
|
|
741
|
+
uuid: fileRes.uuid,
|
|
742
|
+
key: fileRes.key,
|
|
743
|
+
bucket: fileRes.bucket,
|
|
744
|
+
filename: file.name,
|
|
745
|
+
filesize: file.size,
|
|
746
|
+
extension: fileRes.extension,
|
|
747
|
+
file_relationship: fileKey,
|
|
748
|
+
fileable_field:
|
|
749
|
+
fileFieldSetting.fileable_field ||
|
|
750
|
+
fileFieldSetting.id,
|
|
751
|
+
};
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// Wait for all uploads to complete
|
|
755
|
+
const uploadedFiles = await Promise.all(uploadPromises);
|
|
756
|
+
|
|
757
|
+
// If there are multiple files, store them as an array, otherwise as a single object
|
|
758
|
+
formData['uploadedFiles'] =
|
|
759
|
+
uploadedFiles.length > 1
|
|
760
|
+
? uploadedFiles
|
|
761
|
+
: uploadedFiles[0];
|
|
794
762
|
}
|
|
795
763
|
|
|
796
764
|
// Transform keys with dots into nested objects
|
|
@@ -805,8 +773,6 @@ function Form({
|
|
|
805
773
|
return acc;
|
|
806
774
|
}, {});
|
|
807
775
|
|
|
808
|
-
console.info('Payload:', payload);
|
|
809
|
-
|
|
810
776
|
const res = await CustomFetch(url, method, payload);
|
|
811
777
|
|
|
812
778
|
if (res.data.error === '') {
|
|
@@ -891,7 +857,9 @@ function Form({
|
|
|
891
857
|
_formData[id] =
|
|
892
858
|
newValue instanceof Date
|
|
893
859
|
? newValue
|
|
894
|
-
:
|
|
860
|
+
: newValue !== undefined
|
|
861
|
+
? moment(newValue).toDate()
|
|
862
|
+
: '';
|
|
895
863
|
} else {
|
|
896
864
|
_formData[id] = newValue;
|
|
897
865
|
}
|