From 66a0830ef255fdbb39fbced8f1dc974ae042e7be Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 4 Mar 2023 23:03:30 +0100 Subject: [PATCH] feat(frontend): support new fields --- frontend/components/Editable.tsx | 52 ++++++++---------- frontend/pages/edit/profile.tsx | 94 ++++++++++---------------------- 2 files changed, 51 insertions(+), 95 deletions(-) diff --git a/frontend/components/Editable.tsx b/frontend/components/Editable.tsx index 7c4ab7b..bfd9a10 100644 --- a/frontend/components/Editable.tsx +++ b/frontend/components/Editable.tsx @@ -12,19 +12,12 @@ import Card from "./Card"; import TextInput from "./TextInput"; import Button, { ButtonStyle } from "./Button"; import { useState } from "react"; +import { WordStatus } from "../lib/api-fetch"; export interface EditField { id: number; name: string; - pronouns: Record; -} - -export enum PronounChoice { - favourite, - okay, - jokingly, - friendsOnly, - avoid, + values: Array<{ value: string; status: WordStatus }>; } type EditableCardProps = { @@ -32,15 +25,15 @@ type EditableCardProps = { onChangeName: React.ChangeEventHandler; onChangePronoun: React.ChangeEventHandler; onAddPronoun(pronoun: string): void; - onDeletePronoun(e: React.MouseEvent, entry: string): void; + onDeletePronoun(e: React.MouseEvent, index: number): void; onChangeFavourite( e: React.MouseEvent, - entry: string + index: number ): void; - onChangeOkay(e: React.MouseEvent, entry: string): void; - onChangeJokingly(e: React.MouseEvent, entry: string): void; - onChangeFriends(e: React.MouseEvent, entry: string): void; - onChangeAvoid(e: React.MouseEvent, entry: string): void; + onChangeOkay(e: React.MouseEvent, index: number): void; + onChangeJokingly(e: React.MouseEvent, index: number): void; + onChangeFriends(e: React.MouseEvent, index: number): void; + onChangeAvoid(e: React.MouseEvent, index: number): void; onClickDelete: React.MouseEventHandler; }; @@ -76,21 +69,20 @@ export function EditableCard(props: EditableCardProps) { return (
    - {Object.keys(props.field.pronouns).map((pronoun, index) => { - const choice = props.field.pronouns[pronoun]; + {props.field.values.map((value, index) => { return (