import { Head, useForm } from '@inertiajs/react'; import { Mails, Save } from 'lucide-react'; import type { FormEvent } from 'react'; import InputError from '@/components/input-error'; import { PageHeading } from '@/components/page-heading'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; type Template = { subject: string; message: string }; type Definition = Template & { label: string }; export default function NotificationTemplates({ definitions, templates, variables, }: { definitions: Record; templates: Record; variables: string[]; }) { const form = useForm({ templates }); function submit(event: FormEvent) { event.preventDefault(); form.put('/administracao/notificacoes/modelos', { preserveScroll: true, }); } function update(eventName: string, field: keyof Template, value: string) { form.setData('templates', { ...form.data.templates, [eventName]: { ...form.data.templates[eventName], [field]: value }, }); } return ( <>

Variáveis disponíveis:{' '} {variables.map((variable) => ( {variable} ))}

{Object.entries(definitions).map( ([eventName, definition]) => ( {definition.label}