Skip to content

Commit 49f09ab

Browse files
authored
✨ feat (App Frontend): State of debate stays prefilled after changing (#165)
branch: 163-prefill-committee-status-with-old-value
1 parent 8a5a1f2 commit 49f09ab

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

chase/backend/src/routes/conference.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ export const conference = new Elysia()
180180
)
181181
.post(
182182
"/conference/:conferenceId/populateMembers",
183-
async ({ body, params, permissions }) =>
184-
{return Promise.all(
183+
async ({ body, params, permissions }) => {
184+
return Promise.all(
185185
body.map((userData) =>
186186
db.$transaction(async (tx) => {
187187
const email = await tx.email.findFirst({
@@ -210,7 +210,9 @@ export const conference = new Elysia()
210210
// biome-ignore lint/style/noNonNullAssertion: <explanation>
211211
userId: user!.id,
212212
},
213-
AND: [permissions.allowDatabaseAccessTo("create").ConferenceMember]
213+
AND: [
214+
permissions.allowDatabaseAccessTo("create").ConferenceMember,
215+
],
214216
},
215217
create: {
216218
role: userData.role,
@@ -232,7 +234,8 @@ export const conference = new Elysia()
232234
});
233235
}),
234236
),
235-
)},
237+
);
238+
},
236239
{
237240
body: t.Array(
238241
t.Object({

chase/frontend/components/dashboard/chair/state_of_debate.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useContext } from "react";
1+
import React, { useState, useContext, useEffect } from "react";
22
import { useI18nContext } from "@/i18n/i18n-react";
33
import { useBackend } from "@/contexts/backend";
44
import ConfigWrapper from "@/components/dashboard/chair/config_wrapper";
@@ -38,14 +38,18 @@ export default function StateOfDebateWidget() {
3838
state: stateOfDebate,
3939
}),
4040
});
41-
setStateOfDebate("");
4241
} else throw new Error();
4342
})
4443
.catch((e) => {
4544
toastError(e);
4645
});
4746
}
4847

48+
useEffect(() => {
49+
if (stateOfDebate !== "") return;
50+
setStateOfDebate(committeeData?.stateOfDebate || "");
51+
}, [committeeData?.stateOfDebate]);
52+
4953
return (
5054
<>
5155
<ConfigWrapper

chase/frontend/contexts/speakers_list_miniature.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { createContext, useContext, useState } from "react";
22

3-
43
export const SpeakersListMiniatureContext = createContext(
54
{} as {
65
showSpeakersListMiniature: boolean;
@@ -9,7 +8,8 @@ export const SpeakersListMiniatureContext = createContext(
98
},
109
);
1110

12-
export const useSpeakersListMiniature = () => useContext(SpeakersListMiniatureContext);
11+
export const useSpeakersListMiniature = () =>
12+
useContext(SpeakersListMiniatureContext);
1313

1414
export const SpeakersListMiniatureProvider = ({ children }) => {
1515
const [showSpeakersListMiniature, setShowSpeakersListMiniature] =
@@ -21,7 +21,11 @@ export const SpeakersListMiniatureProvider = ({ children }) => {
2121

2222
return (
2323
<SpeakersListMiniatureContext.Provider
24-
value={{ showSpeakersListMiniature, setShowSpeakersListMiniature, toggleSpeakersListMiniature }}
24+
value={{
25+
showSpeakersListMiniature,
26+
setShowSpeakersListMiniature,
27+
toggleSpeakersListMiniature,
28+
}}
2529
>
2630
{children}
2731
</SpeakersListMiniatureContext.Provider>

chase/frontend/data/regional_groups.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,4 @@
203203
"gb",
204204
"us"
205205
]
206-
}
206+
}

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
"lint:error-only": "biome check . --apply --diagnostic-level=error",
1212
"test": "echo TODO"
1313
},
14-
"workspaces": [
15-
"chase/backend",
16-
"chase/frontend"
17-
],
14+
"workspaces": ["chase/backend", "chase/frontend"],
1815
"devDependencies": {
1916
"@biomejs/biome": "^1.6.3",
2017
"bun-types": "latest",

0 commit comments

Comments
 (0)