Skip to content

Commit 07654f5

Browse files
committed
Add attendance mode to registration
1 parent 2a825f3 commit 07654f5

6 files changed

Lines changed: 64 additions & 21 deletions

File tree

frontend/src/components/Auth.tsx

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { useState } from "preact/hooks";
22
import { sendAuth, teams, authError } from "../store";
3+
import { AttendanceMode } from "../types";
34

45
export function Auth() {
56
const [mode, setMode] = useState<"login" | "register">("login");
67
const [name, setName] = useState("");
78
const [team, setTeam] = useState(teams.value[0] || "");
9+
const [attendanceMode, setAttendanceMode] = useState(AttendanceMode.OnSite);
810
const [password, setPassword] = useState("");
911
const [isNotNao, setIsNotNao] = useState(false);
1012

@@ -14,14 +16,19 @@ export function Auth() {
1416
alert("NAOs are not allowed in MOPAD");
1517
return;
1618
}
17-
const payload = { name, team, password };
18-
sendAuth(mode === "login" ? { Login: payload } : { Register: payload });
19+
sendAuth(
20+
mode === "login"
21+
? { Login: { name, team, password } }
22+
: {
23+
Register: { name, team, password, attendance_mode: attendanceMode },
24+
},
25+
);
1926
};
2027

2128
const isValid = name && password && (mode === "login" || isNotNao);
2229

2330
return (
24-
<div id={mode} class="center">
31+
<form id={mode} class="center">
2532
<h1>MOPAD</h1>
2633
<h2>Moderated Organization PAD (powerful, agile, distributed)</h2>
2734
<h3>{mode === "login" ? "Login" : "Register"}</h3>
@@ -54,18 +61,38 @@ export function Auth() {
5461
/>
5562

5663
{mode === "register" && (
57-
<div class="i-am-not-a-nao">
58-
<input
59-
type="checkbox"
60-
id="nao-check"
61-
checked={isNotNao}
62-
onChange={(e) => setIsNotNao(e.currentTarget.checked)}
63-
/>
64-
<label htmlFor="nao-check">I'm not a NAO</label>
65-
</div>
64+
<>
65+
<div class="registration-checkbox">
66+
<input
67+
type="checkbox"
68+
id="attendance-mode-check"
69+
checked={attendanceMode == AttendanceMode.Remote}
70+
onChange={(e) =>
71+
setAttendanceMode(
72+
e.currentTarget.checked
73+
? AttendanceMode.Remote
74+
: AttendanceMode.OnSite,
75+
)
76+
}
77+
/>
78+
<label htmlFor="attendance-mode-check">
79+
Remote Participation only
80+
</label>
81+
82+
<div class="registration-checkbox">
83+
<input
84+
type="checkbox"
85+
id="nao-check"
86+
checked={isNotNao}
87+
onChange={(e) => setIsNotNao(e.currentTarget.checked)}
88+
/>
89+
<label htmlFor="nao-check">I'm not a NAO</label>
90+
</div>
91+
</div>
92+
</>
6693
)}
6794

68-
<button disabled={!isValid} onClick={handleSubmit}>
95+
<button type="submit" disabled={!isValid} onClick={handleSubmit}>
6996
{mode === "login" ? "Login" : "Register"}
7097
</button>
7198

@@ -85,7 +112,7 @@ export function Auth() {
85112
</div>
86113

87114
<Footer />
88-
</div>
115+
</form>
89116
);
90117
}
91118

frontend/src/mopad.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,18 @@ body.center {
142142
box-shadow: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.125);
143143
}
144144

145-
#register .i-am-not-a-nao {
145+
#register .registration-checkbox {
146146
margin: 0.5rem 0;
147147
width: 20rem;
148148
}
149149

150-
#register .i-am-not-a-nao input {
150+
#register .registration-checkbox input {
151151
width: initial;
152152
margin: 0 0.5rem 0 0;
153153
padding: 0;
154154
}
155155

156-
#register .i-am-not-a-nao label {
156+
#register .registration-checkbox label {
157157
font-size: 0.9rem;
158158
}
159159

frontend/src/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function patchTalk(id: number, changes: Partial<Talk>) {
115115
}
116116

117117
export function sendAuth(cmd: AuthCommand) {
118+
console.log(cmd);
118119
socket?.send(JSON.stringify(cmd));
119120
}
120121

frontend/src/types.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export interface SystemTime {
1010
nanos_since_epoch: number;
1111
}
1212

13-
export type Role = "Editor" | "Scheduler";
13+
export enum Role {
14+
Editor = "Editor",
15+
Scheduler = "Scheduler",
16+
}
1417

1518
export interface User {
1619
id: number;
@@ -46,6 +49,18 @@ export type Command =
4649
| { RemoveNerd: { talk_id: number; user_id: number } };
4750

4851
export type AuthCommand =
49-
| { Register: { name: string; team: string; password: string } }
52+
| {
53+
Register: {
54+
name: string;
55+
team: string;
56+
password: string;
57+
attendance_mode: null | AttendanceMode;
58+
};
59+
}
5060
| { Login: { name: string; team: string; password: string } }
5161
| { Relogin: { token: string } };
62+
63+
export enum AttendanceMode {
64+
OnSite = "OnSite",
65+
Remote = "Remote",
66+
}

frontend/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"strict": true,
2626
"noUnusedLocals": true,
2727
"noUnusedParameters": true,
28-
"erasableSyntaxOnly": true,
28+
"erasableSyntaxOnly": false,
2929
"noFallthroughCasesInSwitch": true,
3030
"noUncheckedSideEffectImports": true
3131
},

frontend/tsconfig.node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"strict": true,
1919
"noUnusedLocals": true,
2020
"noUnusedParameters": true,
21-
"erasableSyntaxOnly": true,
21+
"erasableSyntaxOnly": false,
2222
"noFallthroughCasesInSwitch": true,
2323
"noUncheckedSideEffectImports": true
2424
},

0 commit comments

Comments
 (0)