Use Readonly props and optional chaining/nullish coalescing

Mark component props as Readonly<> across 15 component files and
simplify edit-player-character field access with optional chaining
and nullish coalescing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-14 15:13:39 +01:00
parent 8efba288f7
commit 32b69f8df1
16 changed files with 43 additions and 41 deletions

View File

@@ -23,7 +23,7 @@ interface EditFields {
}
function validateFields(fields: EditFields): DomainError | null {
if (fields.name !== undefined && fields.name.trim() === "") {
if (fields.name?.trim() === "") {
return {
kind: "domain-error",
code: "invalid-name",
@@ -81,9 +81,9 @@ function applyFields(
): PlayerCharacter {
return {
id: existing.id,
name: fields.name === undefined ? existing.name : fields.name.trim(),
ac: fields.ac === undefined ? existing.ac : fields.ac,
maxHp: fields.maxHp === undefined ? existing.maxHp : fields.maxHp,
name: fields.name?.trim() ?? existing.name,
ac: fields.ac ?? existing.ac,
maxHp: fields.maxHp ?? existing.maxHp,
color:
fields.color === undefined
? existing.color