@@ -8,14 +8,22 @@ import { DefaultService, OpenAPI } from '@formswizard/api';
88OpenAPI . BASE = 'http://localhost:4000' ;
99const { getProjectStateCryptedData, getProjectStateSchema } = DefaultService ;
1010
11+ function useFormId ( ) {
12+ const hash = typeof location != 'undefined' ? location . hash . slice ( 1 ) : '' ;
13+ const hashParameters = ! hash ? { } : Object . fromEntries ( new URLSearchParams ( hash ) as any ) ;
14+ const { formId } = hashParameters ;
15+ return formId
16+ }
17+
1118export function DecryptAndImportLastNewSubmission ( ) {
1219 const dispatch = useAppDispatch ( ) ;
20+ const formId = useFormId ( ) ;
1321 const jsonSchema = useAppSelector ( selectJsonSchema ) ;
1422
1523 const cryptedData = useAppSelector ( selectCryptedData ) ;
1624 useEffect ( ( ) => {
1725 async function loadCryptedData ( ) {
18- const { cryptedData } = await getProjectStateCryptedData ( ) ;
26+ const { cryptedData } = await getProjectStateCryptedData ( formId ) ;
1927 const latestCryptedDatum = cryptedData ?. length && cryptedData [ cryptedData . length - 1 ] ;
2028 latestCryptedDatum && dispatch ( setCryptedData ( latestCryptedDatum ) ) ;
2129 }
@@ -39,11 +47,13 @@ export function DecryptAndImportLastNewSubmission() {
3947
4048export function useSchema ( ) {
4149 const dispatch = useAppDispatch ( ) ;
50+ const formId = useFormId ( ) ;
4251 const jsonSchema = useAppSelector ( selectJsonSchema ) ;
4352 const uiSchema = useAppSelector ( selectUiSchema ) ;
53+
4454 useEffect ( ( ) => {
4555 async function loadSchema ( ) {
46- const { schema } = await getProjectStateSchema ( ) ;
56+ const { schema } = await getProjectStateSchema ( formId ) ;
4757 const { jsonSchema, uiSchema } = schema || { } ;
4858 jsonSchema && dispatch ( setJsonSchema ( jsonSchema ) )
4959 jsonSchema && dispatch ( setUiSchema ( uiSchema ) )
0 commit comments