diff --git a/bun.lockb b/bun.lockb index e199d0b..a3d6f37 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4479caf..52d3974 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "astro": "^4.16.13", "better-sqlite3": "^11.5.0", "clsx": "^2.1.1", + "date-fns": "^4.1.0", "nanoid": "^5.0.8", "preact": "^10.24.3", "typescript": "^5.6.3" diff --git a/src/components/ActionRegistry.tsx b/src/components/ActionRegistry.tsx index 0ce9be2..d4eed9b 100644 --- a/src/components/ActionRegistry.tsx +++ b/src/components/ActionRegistry.tsx @@ -1,6 +1,7 @@ import { sendJSON } from '@/client/utils' import type { Room } from '@/db/model' import type { Action, ActionAnswer, ActionJolly } from '@/ggwp' +import { format } from 'date-fns' import { type Dispatch, type StateUpdater } from 'preact/hooks' type ActionCardProps = { @@ -40,35 +41,61 @@ const CardActions = ({ moveUp, moveDown, remove }: ActionCardProps) => ( const ActionCardAnswer = ({ action, ...props }: { action: ActionAnswer } & ActionCardProps) => { return ( -
-
Risposta
-
- Team: {action.team} -
-
- Domanda: {action.question} +
+
+
Risposta
+
+
schedule
+
+ {action.timestamp && format(new Date(action.timestamp), 'dd/MM/yyyy HH:mm:ss')} + + {action.timestamp && ' ' + format(new Date(action.timestamp), 'SSS')} + +
+
-
- Risultato: {action.outcome} +
+
+ Team: {action.team} +
+
+ Domanda: {action.question} +
+
+ Risultato: {action.outcome} +
+
+
-
-
) } const ActionCardJolly = ({ action, ...props }: { action: ActionJolly } & ActionCardProps) => { return ( -
-
Jolly
-
- Team: {action.team} +
+
+
Jolly
+
+
schedule
+
+ {action.timestamp && format(new Date(action.timestamp), 'dd/MM/yyyy HH:mm:ss')} + + {action.timestamp && ' ' + format(new Date(action.timestamp), 'SSS')} + +
+
-
- Problem: {action.group} +
+
+ Team: {action.team} +
+
+ Problem: {action.group} +
+
+
-
-
) } diff --git a/src/components/AdminPage.tsx b/src/components/AdminPage.tsx index 1192d52..8dadee9 100644 --- a/src/components/AdminPage.tsx +++ b/src/components/AdminPage.tsx @@ -7,6 +7,15 @@ import { computeScoreboardState } from '@/ggwp' import { Leaderboard } from './Leaderboard' export const AdminPage = ({ roomId }: { roomId: string }) => { + const [password, setPassword] = useState(null) + + useEffect(() => { + const url = new URL(location.href) + setPassword(url.searchParams.get('password')) + url.searchParams.delete('password') + history.replaceState({}, '', url.toString()) + }, []) + const listeners = useRef void>>({}) const [room, setRoom] = useState(null) @@ -35,6 +44,28 @@ export const AdminPage = ({ roomId }: { roomId: string }) => { return ( <>

Admin

+ + {password && ( + <> +

Password

+
+

Password Pannello Admin

+

+ Non perdere questa password, serve per accedere a questo pannello da un altro pc (altrimeni + chiedi ad Antonio) +

+ {password} + +
+ + )} +

{room.id}

{ diff --git a/src/components/SubmitAction.tsx b/src/components/SubmitAction.tsx index 2d8c584..e27908d 100644 --- a/src/components/SubmitAction.tsx +++ b/src/components/SubmitAction.tsx @@ -14,7 +14,7 @@ export const SubmitActionAnswer = ({ sendAction: (action: Action) => void onTeamQuestionIndex?: Receiver<{ team: string; question: string }> }) => { - const [answer, setAnswer] = useState({ + const [answer, setAnswer] = useState>({ question: '', team: '', outcome: 'correct', @@ -71,7 +71,17 @@ export const SubmitActionAnswer = ({ - +
) } @@ -99,7 +109,7 @@ export const SubmitActionJolly = ({ questionToGroup[question.id] = question.group }) - const [answer, setAnswer] = useState({ + const [answer, setAnswer] = useState>({ team: '', group: '', }) @@ -143,7 +153,17 @@ export const SubmitActionJolly = ({ ))} - +
) } diff --git a/src/ggwp/index.ts b/src/ggwp/index.ts index 3ec3962..fbcbbf0 100644 --- a/src/ggwp/index.ts +++ b/src/ggwp/index.ts @@ -47,17 +47,27 @@ function getTimeBonus(index: number): number { } export type ActionAnswer = { + timestamp: string + team: string question: string outcome: 'correct' | 'partial' | 'wrong' } export type ActionJolly = { + timestamp: string + team: string group: string } -export type Action = ({ type: 'answer' } & ActionAnswer) | ({ type: 'jolly' } & ActionJolly) +export type Action = + | ({ + type: 'answer' + } & ActionAnswer) + | ({ + type: 'jolly' + } & ActionJolly) export function computeScoreboardState(game: Game, rawActions: Action[]): Scoreboard { // filter out actions for the same question by the same team, keeping only the last one @@ -89,6 +99,7 @@ export function computeScoreboardState(game: Game, rawActions: Action[]): Scoreb } const questionActions: { + timestamp: string type: 'answer' team: string question: string diff --git a/src/styles.css b/src/styles.css index 9672c56..c8321ce 100644 --- a/src/styles.css +++ b/src/styles.css @@ -105,15 +105,32 @@ a { display: inline-block; align-content: center; - height: 1.75rem; + font-size: 15px; + font-weight: 700; + + height: 1.5rem; padding: 0 0.5rem; border-radius: 0.25rem; - color: oklch(from var(--tint) 0.15 0.1 h); + color: oklch(from var(--tint) 0.3 0.1 h); background: oklch(from var(--tint) calc(l + 0.3) c h); box-shadow: 2px 2px 0 oklch(from var(--tint) calc(l - 0.2) 0.1 h); } +.text { + &.small { + font-size: 16px; + } + + &.smaller { + font-size: 14px; + } + + &.dimmed { + color: oklch(from var(--tint) 0.4 0.1 h); + } +} + .text-large { font-size: 20px; } @@ -157,6 +174,14 @@ a { flex-direction: column; gap: 0.75rem; + &.gap-sm { + gap: 0.25rem; + } + + &.start { + align-items: start; + } + &.center { align-items: center; } @@ -175,6 +200,14 @@ a { flex-direction: row; gap: 0.75rem; + &.gap-sm { + gap: 0.25rem; + } + + &.start { + align-items: start; + } + &.center { align-items: center; }