feat: add required field validation and error handling in file upload component

- Introduced a `required` prop in the `FileUpload` component to enforce mandatory file uploads.
- Enhanced error handling by implementing a modal for displaying error messages related to missing required fields and upload issues.
- Updated the `+page.svelte` file to integrate the new error modal and improve user feedback during form submissions.
- Ensured that all relevant file upload sections now validate the presence of documents before allowing form submission.
This commit is contained in:
2025-11-04 03:37:22 -03:00
parent c6c88f85a7
commit 6d613fe618
3 changed files with 444 additions and 287 deletions

View File

@@ -0,0 +1,54 @@
<script lang="ts">
interface Props {
open: boolean;
title?: string;
message: string;
details?: string;
onClose: () => void;
}
let {
open = $bindable(false),
title = "Erro",
message,
details,
onClose,
}: Props = $props();
</script>
{#if open}
<div class="modal modal-open">
<div class="modal-box">
<h3 class="font-bold text-lg text-error mb-4 flex items-center gap-2">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
{title}
</h3>
<p class="py-4 text-base-content">{message}</p>
{#if details}
<div class="bg-base-200 rounded-lg p-3 mb-4">
<p class="text-sm text-base-content/70 font-mono">{details}</p>
</div>
{/if}
<div class="modal-action">
<button class="btn btn-primary" onclick={() => { open = false; onClose(); }}>
Fechar
</button>
</div>
</div>
<div class="modal-backdrop" onclick={() => { open = false; onClose(); }}></div>
</div>
{/if}