diff --git a/src/lib/components/MyProfile/LinkForm.svelte b/src/lib/components/MyProfile/LinkForm.svelte index 4ad020c..94e792f 100644 --- a/src/lib/components/MyProfile/LinkForm.svelte +++ b/src/lib/components/MyProfile/LinkForm.svelte @@ -4,15 +4,19 @@ import { linksSchema, type LinksSchema } from '$lib/schemas/links'; import { type SuperValidated, type Infer, superForm } from 'sveltekit-superforms'; import { zodClient } from 'sveltekit-superforms/adapters'; + import type { Link } from '@prisma/client'; export let data: SuperValidated>; export let linksLength: number; + export let links: Link[] = []; + let isLimitReached = false; + $: isLimitReached = links.length >= 15; const form = superForm(data, { validators: zodClient(linksSchema) }); - const { form: formData, enhance } = form; + const { form: formData, enhance, message } = form; $: $formData.order = linksLength; @@ -49,5 +53,11 @@ - Add + Add + +{#if isLimitReached} +

You have reached the maximum limit of 15 links.

+{:else if $message} +

{$message}

+{/if} \ No newline at end of file diff --git a/src/lib/components/MyProfile/SkillsForm.svelte b/src/lib/components/MyProfile/SkillsForm.svelte index 20d1ce8..8bb40b1 100644 --- a/src/lib/components/MyProfile/SkillsForm.svelte +++ b/src/lib/components/MyProfile/SkillsForm.svelte @@ -5,10 +5,13 @@ import { Select } from 'bits-ui'; import { type SuperValidated, type Infer, superForm } from 'sveltekit-superforms'; import { zodClient } from 'sveltekit-superforms/adapters'; + import type { Skill } from '@prisma/client'; export let data: SuperValidated>; export let skillsLength: number; - + export let skills: Skill[] = []; + let isLimitReached = false; + $: isLimitReached = skills.length >= 15; const form = superForm(data, { validators: zodClient(skillsSchema), resetForm: false, @@ -20,7 +23,7 @@ } }); - const { form: formData, enhance } = form; + const { form: formData, enhance ,message} = form; $: $formData.order = skillsLength; $: selectedLevel = $formData.level @@ -81,5 +84,11 @@ - Add + Add + +{#if isLimitReached} +

You have reached the maximum limit of 15 links.

+{:else if $message} +

{$message}

+{/if} \ No newline at end of file