add biological sex

This commit is contained in:
2025-04-26 22:25:06 +02:00
parent 73d593450e
commit 50971c8dde
6 changed files with 61 additions and 9 deletions

View File

@@ -531,6 +531,17 @@ export interface components {
could_make_it?: boolean | null;
};
Admin: {
id?: number;
first_name?: string;
adminSince?: number;
last_name?: string;
EndId?: number;
EndElementId?: string;
Props?: {
added?: number;
};
};
AdminRelationship: {
Id?: number;
Type?: string;
StartId?: number;
@@ -1670,7 +1681,7 @@ export interface operations {
};
content: {
"application/json": {
admins?: components["schemas"]["OptimizedPersonNode"][];
admins?: components["schemas"]["Admin"][];
};
};
};
@@ -1729,7 +1740,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Admin"];
"application/json": components["schemas"]["AdminRelationship"];
};
};
/** @description Bad request */
@@ -1787,7 +1798,7 @@ export interface operations {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Admin"];
"application/json": components["schemas"]["AdminRelationship"];
};
};
/** @description Bad request */
@@ -1903,7 +1914,7 @@ export interface operations {
};
content: {
"application/json": {
admins?: components["schemas"]["OptimizedPersonNode"][];
admins?: components["schemas"]["Admin"][];
};
};
};

View File

@@ -12,7 +12,8 @@ import {
mothers_first_name,
mothers_last_name,
born,
failed_to_create_user
failed_to_create_user,
biological_sex
} from '$lib/paraglide/messages';
import type { PageServerLoad, Actions, RequestEvent } from './$types';
@@ -154,6 +155,20 @@ async function register(event: RequestEvent) {
})
});
}
const bbiological_sex = data.get('biological_sex');
if (bbiological_sex === null || bbiological_sex === '') {
return fail(400, {
message: missing_field({
field: biological_sex()
})
});
} else if (!['male', 'female', 'intersex', 'unknown', 'other'].includes(bbiological_sex.toString())) {
return fail(400, {
message: `Invalid value for biological_sex. Must be one of "male", "female", "intersex", "unknown", or "other".`
});
}
const mothers_first_name_f = data.get('mothers_first_name');
if (mothers_first_name_f === null || mothers_first_name_f === '') {
return fail(400, {
@@ -179,6 +194,7 @@ async function register(event: RequestEvent) {
born: parsed_date.toISOString().split('T')[0],
mothers_first_name: mothers_first_name_f as string,
mothers_last_name: mothers_last_name_f as string,
biological_sex: bbiological_sex as components['schemas']['PersonRegistration']['biological_sex'],
limit: StorageLimit
};

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import type { PageProps } from './$types';
import type { PageData } from './$types';
import {
register,
title,
@@ -11,12 +11,24 @@
mothers_last_name,
last_name,
first_name,
email
email,
biological_sex,
male,
female,
other
} from '$lib/paraglide/messages';
import { onMount } from 'svelte';
import { enhance } from '$app/forms';
import FamilyTree from '../../highresolution_icon_no_background_croped.png';
let { data, form }: PageProps = $props();
let {
data,
form
}: {
data: PageData;
form: {
message: string;
};
} = $props();
let birth_date: HTMLInputElement;
let birth_date_value: HTMLInputElement;
@@ -121,6 +133,17 @@
bind:this={birth_date}
/>
<input type="text" class="hidden" name="birth_date" bind:this={birth_date_value} />
<label class="fieldset-label" for="biological_sex">{biological_sex()}</label>
<select
name="biological_sex"
class="select select-bordered w-full max-w-xs"
id="biological_sex"
placeholder={biological_sex()}
>
<option value="male">{male()} </option>
<option value="female">{female()} </option>
<option value="other">{other()} </option>
</select>
<label class="fieldset-label" for="mothers_last_name">{mothers_last_name()}</label>
<input
type="text"