diff --git a/messages/en.json b/messages/en.json index 5bb51c51..f26f9873 100644 --- a/messages/en.json +++ b/messages/en.json @@ -41,6 +41,7 @@ "Get_this_credential": "Get this credential", "Decline": "Decline", "Scan": "Scan", + "We_are_generating_this_credential": "We are generating this credential", "Nothing_in_your_wallet": "Nothing in your wallet", "Start_getting_your_first_credential": "Start getting your first credential", "See_issuance_services": "See issuance services" diff --git a/src/lib/JSONSchemaForms/JSONSchemaForm.svelte b/src/lib/JSONSchemaForms/JSONSchemaForm.svelte index 4cde3749..d7f52e54 100644 --- a/src/lib/JSONSchemaForms/JSONSchemaForm.svelte +++ b/src/lib/JSONSchemaForms/JSONSchemaForm.svelte @@ -6,11 +6,12 @@ import { Form, FormError } from '$lib/forms'; import ErrorDisplay from '$lib/components/errorDisplay.svelte'; import { objectSchemaToSuperformsValidators } from './errors'; - import { m } from '$lib/i18n'; + import { unlockApp } from '$lib/preferences/locked'; // export let schema: ObjectSchema; + export let id: string; export let onSubmit: (data: Record) => Promise | void = () => {}; // @@ -24,7 +25,9 @@ validators: objectSchemaToSuperformsValidators(schema), onUpdate: async ({ form }) => { try { + await unlockApp(); await onSubmit(form.data); + } catch (e) { setError(form, parseFormException(e)); } @@ -40,7 +43,7 @@ } -
+
{#each Object.entries(schema.properties) as [fieldName, field]} {@const required = schema.required?.includes(fieldName)} @@ -50,9 +53,5 @@ - -
- {m.Submit()} -
diff --git a/src/lib/JSONSchemaForms/utils.ts b/src/lib/JSONSchemaForms/utils.ts index a0e8c9dd..7af80327 100644 --- a/src/lib/JSONSchemaForms/utils.ts +++ b/src/lib/JSONSchemaForms/utils.ts @@ -1,12 +1,14 @@ -import Ajv, { type Options } from 'ajv'; +import { type Options } from 'ajv'; import addFormats from 'ajv-formats'; import type { SuperValidated, ZodValidation } from 'sveltekit-superforms'; import type z from 'zod'; +import Ajv2020 from 'ajv/dist/2020'; + // -export function createAjv(options: Options = {}): Ajv { - const ajv = new Ajv(options); +export function createAjv(options: Options = {}): Ajv2020 { + const ajv = new Ajv2020(options); addFormats(ajv); return ajv; } diff --git a/src/lib/forms/form.svelte b/src/lib/forms/form.svelte index 64a5f8f4..d726e394 100644 --- a/src/lib/forms/form.svelte +++ b/src/lib/forms/form.svelte @@ -52,11 +52,12 @@ -
+ diff --git a/src/routes/[[lang]]/(protected)/[id]/credential-offer/+page.svelte b/src/routes/[[lang]]/(protected)/[id]/credential-offer/+page.svelte index 2046684b..f60a37cf 100644 --- a/src/routes/[[lang]]/(protected)/[id]/credential-offer/+page.svelte +++ b/src/routes/[[lang]]/(protected)/[id]/credential-offer/+page.svelte @@ -46,6 +46,11 @@ }, 3000); }, 5000); }; + + const cleanSchema = () => { + const schema = credential.expand.templates[0].schema; + schema; + };
{m.Credential_offer()}
@@ -69,15 +74,16 @@ - - {}} /> - - - - -
{credential.expand.templates[0].schema}
+
+ + + + + + +
- {m.Get_this_credential()} {m.Decline()} @@ -88,7 +94,7 @@
{#if !isCredentialVerified} - We are generating this credential + {m.We_are_generating_this_credential()}