feat(persons): surface personType + title in forms and detail card #333

Merged
marcel merged 27 commits from feat/issue-218-person-title-type-fields into main 2026-04-26 13:37:40 +02:00
Showing only changes of commit e54240ea1b - Show all commits

View File

@@ -30,6 +30,12 @@ export async function load({ params, fetch, locals }) {
export const actions = {
update: async ({ request, params, fetch }) => {
const formData = await request.formData();
const personType = (formData.get('personType')?.toString() ?? 'PERSON') as
| 'PERSON'
| 'INSTITUTION'
| 'GROUP'
| 'UNKNOWN';
const title = formData.get('title')?.toString().trim() || undefined;
const firstName = formData.get('firstName')?.toString().trim();
const lastName = formData.get('lastName')?.toString().trim();
const alias = formData.get('alias')?.toString().trim() || undefined;
@@ -39,15 +45,20 @@ export const actions = {
const birthYear = birthYearStr ? parseInt(birthYearStr, 10) : undefined;
const deathYear = deathYearStr ? parseInt(deathYearStr, 10) : undefined;
if (!firstName || !lastName) {
return fail(400, { updateError: 'Vor- und Nachname sind Pflichtfelder.' });
if (!lastName) {
return fail(400, { updateError: 'Nachname ist Pflichtfeld.' });
}
if (personType === 'PERSON' && !firstName) {
return fail(400, { updateError: 'Vorname ist Pflichtfeld.' });
}
const api = createApiClient(fetch);
const result = await api.PUT('/api/persons/{id}', {
params: { path: { id: params.id } },
body: {
firstName,
personType,
...(title ? { title } : {}),
...(firstName ? { firstName } : {}),
lastName,
...(alias ? { alias } : {}),
...(notes ? { notes } : {}),