form-craft-package 1.1.3 → 1.1.5
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
CHANGED
|
@@ -37,6 +37,7 @@ export const DynamicFormButtonRender = memo(
|
|
|
37
37
|
const formValues = Form.useWatch([], { form: formRef, preserve: true })
|
|
38
38
|
const formId = Form.useWatch(FormPreservedItemKeys.FormId, { form: formRef, preserve: true }) // for public use
|
|
39
39
|
const formKey = Form.useWatch(FormPreservedItemKeys.FormKey, { form: formRef, preserve: true }) // for public use
|
|
40
|
+
const companyKey = Form.useWatch(FormPreservedItemKeys.CompanyKey, { form: formRef, preserve: true }) // for public use
|
|
40
41
|
const convertScreenToPdf = Form.useWatch(FormPreservedItemKeys.ConvertScreenToPDF, {
|
|
41
42
|
form: formRef,
|
|
42
43
|
preserve: true,
|
|
@@ -161,7 +162,8 @@ export const DynamicFormButtonRender = memo(
|
|
|
161
162
|
formRef?.validateFields().then((values) => {
|
|
162
163
|
const queryParams = objectToQueryParams(values)
|
|
163
164
|
console.log(queryParams)
|
|
164
|
-
const
|
|
165
|
+
const feDomainUrl = window.location.origin
|
|
166
|
+
const fullUrl = `${feDomainUrl}/${location.pathname}?${queryParams}`
|
|
165
167
|
console.log(fullUrl)
|
|
166
168
|
const blobName = 'abc'
|
|
167
169
|
client
|
|
@@ -228,17 +230,17 @@ export const DynamicFormButtonRender = memo(
|
|
|
228
230
|
if (formRef) {
|
|
229
231
|
const signatureField = formRef.getFieldValue(FormPreservedItemKeys.HasSignature)
|
|
230
232
|
if (!!signatureField) {
|
|
231
|
-
setDataLoadingType(FormLoadingModalTypeEnum.GeneratingPdf)
|
|
232
|
-
|
|
233
233
|
const signatureBase64 = formRef.getFieldValue(signatureField)
|
|
234
|
-
const blobName = await saveFile(base64ToBlob(signatureBase64), 'signature')
|
|
234
|
+
const blobName = await saveFile(base64ToBlob(signatureBase64), 'signature', isPublic ? companyKey : '')
|
|
235
235
|
|
|
236
236
|
if (!!blobName) formRef.setFieldValue(signatureField, blobName)
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
if (formDataId === NEW_FORM_DATA_IDENTIFIER) {
|
|
240
|
-
if (convertScreenToPdf)
|
|
241
|
-
|
|
240
|
+
if (convertScreenToPdf) {
|
|
241
|
+
setDataLoadingType(FormLoadingModalTypeEnum.GeneratingPdf)
|
|
242
|
+
generatePdfProof()
|
|
243
|
+
} else onCreateNewData()
|
|
242
244
|
} else onSaveExistingData()
|
|
243
245
|
} else error({ message: CUSTOM_ERROR_MESSAGES.FormInstanceNotFound })
|
|
244
246
|
|
|
@@ -266,7 +268,7 @@ export const DynamicFormButtonRender = memo(
|
|
|
266
268
|
warning({ message: errorMessage })
|
|
267
269
|
return
|
|
268
270
|
}
|
|
269
|
-
}, [btnProps, baseDynamicUrl, formDataId, convertScreenToPdf])
|
|
271
|
+
}, [btnProps, baseDynamicUrl, formDataId, convertScreenToPdf, companyKey])
|
|
270
272
|
|
|
271
273
|
return (
|
|
272
274
|
<>
|
|
@@ -30,7 +30,6 @@ export default function LayoutRenderer_Signature({ formRef, fieldKey, elementPro
|
|
|
30
30
|
const sigBase64 = sigCanvasRef.current?.toDataURL()
|
|
31
31
|
if (sigBase64)
|
|
32
32
|
formRef.setFieldsValue({ [fieldKey]: sigBase64, [FormPreservedItemKeys.HasSignature]: fieldKey })
|
|
33
|
-
// saveSignature(sigBase64)
|
|
34
33
|
}}
|
|
35
34
|
/>
|
|
36
35
|
)}
|
|
@@ -7,6 +7,7 @@ import { IFileUploadElementRules } from '../../../../types'
|
|
|
7
7
|
import { useNotification } from '../../../common/custom-hooks'
|
|
8
8
|
import { FaTrashAlt } from 'react-icons/fa'
|
|
9
9
|
import { saveFile } from '../../../../functions/form'
|
|
10
|
+
import { FormPreservedItemKeys } from '../../../../enums'
|
|
10
11
|
|
|
11
12
|
export default function LayoutRenderer_FileUpload({
|
|
12
13
|
formRef,
|
|
@@ -17,6 +18,7 @@ export default function LayoutRenderer_FileUpload({
|
|
|
17
18
|
const { warningModal, confirmModal } = useNotification()
|
|
18
19
|
const [loading, setLoading] = useState(false)
|
|
19
20
|
const savedSignatureBlobName = Form.useWatch(fieldKey, formRef)
|
|
21
|
+
const companyKey = Form.useWatch(FormPreservedItemKeys.CompanyKey, { form: formRef, preserve: true }) // for public use
|
|
20
22
|
|
|
21
23
|
const deleteSavedFile = useCallback((blobName: string) => {
|
|
22
24
|
setLoading(true)
|
|
@@ -37,7 +39,7 @@ export default function LayoutRenderer_FileUpload({
|
|
|
37
39
|
onChange: async (fileInfo: any) => {
|
|
38
40
|
if (fileInfo.file.status === 'done') {
|
|
39
41
|
setLoading(true)
|
|
40
|
-
const blobName = await saveFile(fileInfo.file.originFileObj, fileInfo.file.name)
|
|
42
|
+
const blobName = await saveFile(companyKey, fileInfo.file.originFileObj, fileInfo.file.name)
|
|
41
43
|
if (blobName) formRef.setFieldValue(fieldKey, blobName)
|
|
42
44
|
setLoading(false)
|
|
43
45
|
}
|
package/src/functions/form.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import client from './axios-handler'
|
|
2
2
|
|
|
3
|
-
export const saveFile = async (file: any, fileName: string): Promise<string | null> => {
|
|
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)
|
|
7
|
-
const
|
|
7
|
+
const endpoint = companyKey ? `/api/attachment/create/${companyKey}` : '/api/attachment'
|
|
8
|
+
const response = await client.post(endpoint, formData)
|
|
8
9
|
if (response.status < 300) return response.data
|
|
9
10
|
|
|
10
11
|
return null
|