diff --git a/src/frontend/scripts/characters/edit.ts b/src/frontend/scripts/characters/edit.ts index ebea8f9..eef32bd 100644 --- a/src/frontend/scripts/characters/edit.ts +++ b/src/frontend/scripts/characters/edit.ts @@ -17,6 +17,12 @@ import * as api from "../api"; return id; } + const getTextValue = (selector: string) => + document.querySelector(selector)?.value ?? ""; + + const getIntValue = (selector: string) => + parseInt(document.querySelector(selector)?.value ?? "0") + function setupAttributes() { const attributeInputs = document.querySelectorAll('#attributes input[type="number"]'); @@ -71,15 +77,12 @@ import * as api from "../api"; async function updateInfo() { const params = new UpdateBasicInfoRequest(); - const name = document.querySelector("#characterName")?.value ?? ""; - console.log("name is", name); - params.setId(characterId()); - params.setName(name); - params.setAge(50); - params.setConcept("cool guy"); - params.setChronicle("the best one"); - params.setGender("apache attack helicopter"); + params.setName(getTextValue("#characterName")); + params.setAge(getIntValue("#age")); + params.setConcept(getTextValue("#concept")); + params.setChronicle(getTextValue("#chronicle")); + params.setGender(getTextValue("#gender")); let resp = await api.updateBasicInfo(params); console.log("got a response back", resp); diff --git a/src/frontend/templates/characters/edit_character.html.tera b/src/frontend/templates/characters/edit_character.html.tera index 753ebf7..2a69054 100644 --- a/src/frontend/templates/characters/edit_character.html.tera +++ b/src/frontend/templates/characters/edit_character.html.tera @@ -94,8 +94,29 @@ -

System: {{data_type}}

+
System: {{data_type}}
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
{{ macros::attribute(name="Intelligence", value=sheet.intelligence) }} diff --git a/src/routes/api/cofd.rs b/src/routes/api/cofd.rs index 24b5dd6..89d51b7 100644 --- a/src/routes/api/cofd.rs +++ b/src/routes/api/cofd.rs @@ -53,6 +53,8 @@ pub(super) async fn update_basic_info<'a>( sheet.name = req.name.clone(); sheet.gender = req.gender.clone(); sheet.concept = req.concept.clone(); + sheet.chronicle = req.chronicle.clone(); + sheet.age = req.age; character.update_data(&sheet)?; conn.update_character(&character).await?;