Skip to content

Commit 0a6851a

Browse files
committed
done
1 parent d39cc83 commit 0a6851a

2 files changed

Lines changed: 58 additions & 22 deletions

File tree

frontend/src/api/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ export class ApiClient {
182182
allowProfileFormUntil: this.reviveDate(
183183
settings.application.allowProfileFormUntil,
184184
),
185+
acceptanceDeadline: this.reviveDate(
186+
settings.application.acceptanceDeadline,
187+
),
188+
confirmSpotUntil: this.reviveDate(
189+
settings.application.confirmSpotUntil,
190+
),
185191
},
186192
};
187193
}

frontend/src/components/settings/application/application-settings.tsx

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,32 @@ export const ApplicationSettings = () => {
4040
[settings],
4141
);
4242

43-
const handleAllowProfileFormFromChange = useCallback(
44-
(value: string) => {
45-
setAllowProfileFormFrom(value);
46-
const date = new Date(value);
47-
48-
if (!isValidDate(date)) {
49-
return;
50-
}
43+
const [allowProfileFormUntil, setAllowProfileFormUntil] = useDerivedState(
44+
() => settings.application.allowProfileFormUntil.toISOString(),
45+
[settings],
46+
);
5147

52-
updateApplicationSettings({
53-
allowProfileFormFrom: date,
54-
});
55-
},
56-
[updateApplicationSettings],
48+
const [acceptanceDeadline, setAcceptanceDeadline] = useDerivedState(
49+
() => settings.application.acceptanceDeadline.toISOString(),
50+
[settings],
5751
);
5852

59-
const [allowProfileFormUntil, setAllowProfileFormUntil] = useDerivedState(
60-
() => settings.application.allowProfileFormUntil.toISOString(),
53+
const [confirmSpotUntil, setConfirmSpotUntil] = useDerivedState(
54+
() => settings.application.confirmSpotUntil.toISOString(),
6155
[settings],
6256
);
6357

64-
const handleAllowProfileFormUntilChange = useCallback(
65-
(value: string) => {
66-
setAllowProfileFormUntil(value);
58+
const handleDateChange = useCallback(
59+
(value: string, setter, key: string) => {
60+
setter(value);
6761
const date = new Date(value);
6862

6963
if (!isValidDate(date)) {
7064
return;
7165
}
7266

7367
updateApplicationSettings({
74-
allowProfileFormUntil: date,
68+
[key]: date,
7569
});
7670
},
7771
[updateApplicationSettings],
@@ -112,11 +106,16 @@ export const ApplicationSettings = () => {
112106
placeholder="keep it fair, e.g. 240 for 10 days"
113107
/>
114108
</FlexRowColumnContainer>
115-
<Spacer />
109+
</FlexRowContainer>
110+
<FlexRowContainer>
116111
<FlexRowColumnContainer>
117112
<TextInput
118113
value={allowProfileFormFrom}
119-
onChange={handleAllowProfileFormFromChange}
114+
onChange={(value) => handleDateChange(
115+
value,
116+
setAllowProfileFormFrom,
117+
"allowProfileFormFrom"
118+
)}
120119
title="Open registration on"
121120
placeholder="1970-01-01 00:00:00"
122121
/>
@@ -125,12 +124,43 @@ export const ApplicationSettings = () => {
125124
<FlexRowColumnContainer>
126125
<TextInput
127126
value={allowProfileFormUntil}
128-
onChange={handleAllowProfileFormUntilChange}
127+
onChange={(value) => handleDateChange(
128+
value,
129+
setAllowProfileFormUntil,
130+
"allowProfileFormUntil"
131+
)}
129132
title="Close registration on"
130133
placeholder="1970-01-01 00:00:00"
131134
/>
132135
</FlexRowColumnContainer>
133136
</FlexRowContainer>
137+
<FlexRowContainer>
138+
<FlexRowColumnContainer>
139+
<TextInput
140+
value={acceptanceDeadline}
141+
onChange={(value) => handleDateChange(
142+
value,
143+
setAcceptanceDeadline,
144+
"acceptanceDeadline"
145+
)}
146+
title="When we will accept people"
147+
placeholder="1970-01-01 00:00:00"
148+
/>
149+
</FlexRowColumnContainer>
150+
<Spacer />
151+
<FlexRowColumnContainer>
152+
<TextInput
153+
value={confirmSpotUntil}
154+
onChange={(value) => handleDateChange(
155+
value,
156+
setConfirmSpotUntil,
157+
"confirmSpotUntil"
158+
)}
159+
title="Until when accepted people need to confirm their spot"
160+
placeholder="1970-01-01 00:00:00"
161+
/>
162+
</FlexRowColumnContainer>
163+
</FlexRowContainer>
134164

135165
<Text>
136166
Use the add button to add new questions and the edit button in the top

0 commit comments

Comments
 (0)