form-craft-package 1.1.7 → 1.1.9
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/form/2-details/index.tsx +1 -1
- package/src/components/form/layout-renderer/3-element/1-dynamic-button.tsx +12 -11
- package/src/components/form/layout-renderer/3-element/5-re-captcha.tsx +0 -1
- package/src/components/form/layout-renderer/3-element/7-file-upload.tsx +1 -1
- package/src/components/modals/form-data-loading.modal.tsx +2 -0
- package/src/functions/form.ts +1 -1
- package/src/functions/index.ts +2 -1
package/package.json
CHANGED
|
@@ -67,7 +67,7 @@ export default function FormDataDetailsComponent({
|
|
|
67
67
|
if (res.status === 200) {
|
|
68
68
|
const parsedData: IFormSchema | null = parseJSON(res.data.data)
|
|
69
69
|
if (parsedData) {
|
|
70
|
-
console.log({parsedData})
|
|
70
|
+
console.log({ parsedData })
|
|
71
71
|
const { layout, migrationRules, convertScreenToPdf = false } = parsedData.detailsConfig
|
|
72
72
|
|
|
73
73
|
if (isPublic) {
|
|
@@ -161,20 +161,19 @@ export const DynamicFormButtonRender = memo(
|
|
|
161
161
|
const generatePdfProof = useCallback(() => {
|
|
162
162
|
formRef?.validateFields().then((values) => {
|
|
163
163
|
const queryParams = objectToQueryParams(values)
|
|
164
|
-
console.log(queryParams)
|
|
165
164
|
const feDomainUrl = window.location.origin
|
|
166
|
-
const fullUrl = `${feDomainUrl}
|
|
167
|
-
|
|
168
|
-
const blobName = 'abc'
|
|
165
|
+
const fullUrl = encodeURIComponent(`${feDomainUrl}${location.pathname}?${queryParams}`)
|
|
166
|
+
|
|
167
|
+
const blobName = 'abc.pdf'
|
|
169
168
|
client
|
|
170
|
-
.post(`/api/attachment/pdf/${companyKey}/${
|
|
169
|
+
.post(`/api/attachment/pdf/${companyKey}/${blobName}?url=${fullUrl}`)
|
|
171
170
|
.then((res) => {
|
|
172
|
-
if (res.status < 300)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
if (res.status < 300) onCreateNewData(res.data)
|
|
172
|
+
})
|
|
173
|
+
.catch(() => {
|
|
174
|
+
closeModal()
|
|
175
|
+
error({ message: 'Error occured while generating PDF!' })
|
|
176
176
|
})
|
|
177
|
-
.catch(() => error({ message: 'Error occured while generating PDF!' }))
|
|
178
177
|
})
|
|
179
178
|
}, [formRef, location.pathname, companyKey])
|
|
180
179
|
|
|
@@ -229,6 +228,7 @@ export const DynamicFormButtonRender = memo(
|
|
|
229
228
|
case ButtonActionCategoryEnum.SaveDataChanges:
|
|
230
229
|
if (formRef) {
|
|
231
230
|
const signatureField = formRef.getFieldValue(FormPreservedItemKeys.HasSignature)
|
|
231
|
+
// to save the signature upon submission
|
|
232
232
|
if (!!signatureField) {
|
|
233
233
|
const signatureBase64 = formRef.getFieldValue(signatureField)
|
|
234
234
|
const blobName = await saveFile(base64ToBlob(signatureBase64), 'signature', isPublic ? companyKey : '')
|
|
@@ -237,7 +237,8 @@ export const DynamicFormButtonRender = memo(
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
if (formDataId === NEW_FORM_DATA_IDENTIFIER) {
|
|
240
|
-
if (convertScreenToPdf) {
|
|
240
|
+
if (isPublic && convertScreenToPdf) {
|
|
241
|
+
// pdf generate does not work when auth-ed
|
|
241
242
|
setDataLoadingType(FormLoadingModalTypeEnum.GeneratingPdf)
|
|
242
243
|
generatePdfProof()
|
|
243
244
|
} else onCreateNewData()
|
|
@@ -16,7 +16,6 @@ export default function LayoutRenderer_ReCaptcha({ formRef, fieldKey, elementPro
|
|
|
16
16
|
}
|
|
17
17
|
client.get(`/api/site/${formKey}/verifycaptcha/${token}`).then((res) => {
|
|
18
18
|
if (res.status < 300) {
|
|
19
|
-
console.log('re', res.data)
|
|
20
19
|
if (!res.data) formRef.setFieldValue(fieldKey, true)
|
|
21
20
|
else setTokenVerificationFailed(true)
|
|
22
21
|
}
|
|
@@ -39,7 +39,7 @@ export default function LayoutRenderer_FileUpload({
|
|
|
39
39
|
onChange: async (fileInfo: any) => {
|
|
40
40
|
if (fileInfo.file.status === 'done') {
|
|
41
41
|
setLoading(true)
|
|
42
|
-
const blobName = await saveFile(
|
|
42
|
+
const blobName = await saveFile(fileInfo.file.originFileObj, fileInfo.file.name, companyKey)
|
|
43
43
|
if (blobName) formRef.setFieldValue(fieldKey, blobName)
|
|
44
44
|
setLoading(false)
|
|
45
45
|
}
|
|
@@ -32,6 +32,8 @@ export default function FormDataLoadingIndicatorModal({
|
|
|
32
32
|
<Spin spinning size="large" />
|
|
33
33
|
{(() => {
|
|
34
34
|
switch (currentType) {
|
|
35
|
+
case FormLoadingModalTypeEnum.GeneratingPdf:
|
|
36
|
+
return <span className="text-primary">Generating PDF...</span>
|
|
35
37
|
case FormLoadingModalTypeEnum.SavingChanges:
|
|
36
38
|
return <span className="text-primary">Saving data...</span>
|
|
37
39
|
case FormLoadingModalTypeEnum.ErrorOccured:
|
package/src/functions/form.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from './axios-handler'
|
|
2
2
|
|
|
3
|
-
export const saveFile = async (file: any, fileName: string, companyKey
|
|
3
|
+
export const saveFile = async (file: any, fileName: string, companyKey?: string): Promise<string | null> => {
|
|
4
4
|
try {
|
|
5
5
|
const formData = new FormData()
|
|
6
6
|
formData.append('file', file, fileName)
|
package/src/functions/index.ts
CHANGED
|
@@ -98,7 +98,8 @@ export const base64ToBlob = (base64: string) => {
|
|
|
98
98
|
|
|
99
99
|
export const objectToQueryParams = (obj: Record<string, any>): string =>
|
|
100
100
|
Object.entries(obj)
|
|
101
|
-
.map(([key, value]) => `${
|
|
101
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
102
|
+
// .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
102
103
|
.join('&')
|
|
103
104
|
|
|
104
105
|
/** --------------------------------------------------------------------------------------------------------- */
|