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
2 changed files with 8 additions and 7 deletions
Showing only changes of commit d97cd06f70 - Show all commits

View File

@@ -2,6 +2,12 @@ import { error, fail, redirect } from '@sveltejs/kit';
import { createApiClient } from '$lib/api.server';
import { getErrorMessage } from '$lib/errors';
type PersonType = 'PERSON' | 'INSTITUTION' | 'GROUP' | 'UNKNOWN' | 'SKIP';
export function normalizePersonType(raw: string | undefined | null): Exclude<PersonType, 'SKIP'> {
return raw === 'SKIP' ? 'UNKNOWN' : ((raw ?? 'PERSON') as Exclude<PersonType, 'SKIP'>);
}
export async function load({ params, fetch, locals }) {
const canWrite =
(locals.user as { groups?: { permissions: string[] }[] } | undefined)?.groups?.some((g) =>
@@ -23,7 +29,7 @@ export async function load({ params, fetch, locals }) {
}
const person = result.data!;
const personType = person.personType === 'SKIP' ? 'UNKNOWN' : person.personType;
const personType = normalizePersonType(person.personType);
return { person: { ...person, personType }, aliases: aliasesResult.data ?? [] };
}

View File

@@ -1,10 +1,5 @@
import { describe, it, expect } from 'vitest';
type PersonType = 'PERSON' | 'INSTITUTION' | 'GROUP' | 'UNKNOWN' | 'SKIP';
function normalizePersonType(raw: string | undefined | null): PersonType {
return raw === 'SKIP' ? 'UNKNOWN' : ((raw ?? 'PERSON') as PersonType);
}
import { normalizePersonType } from './+page.server';
describe('edit load — SKIP → UNKNOWN normalization', () => {
it('maps SKIP to UNKNOWN', () => {