From 063f22569d35e05b76b1de4348cab70c79b7beb8 Mon Sep 17 00:00:00 2001 From: z1glr Date: Mon, 6 Jan 2025 21:40:14 +0000 Subject: [PATCH] added user-overview for setting availability --- client/package-lock.json | 75 +++++++++++++++++++ client/package.json | 1 + client/src/Zustand.ts | 12 +-- client/src/app/Overview.tsx | 14 ++-- client/src/app/admin/page.tsx | 46 ++++++------ client/src/app/me/page.tsx | 43 ++++++++++- .../src/components/Event/AssignmentTable.tsx | 22 ++++++ client/src/components/Event/Event.tsx | 33 ++++---- .../src/components/{Event => }/LocalDate.tsx | 7 +- 9 files changed, 190 insertions(+), 63 deletions(-) create mode 100644 client/src/components/Event/AssignmentTable.tsx rename client/src/components/{Event => }/LocalDate.tsx (60%) diff --git a/client/package-lock.json b/client/package-lock.json index 691bd9d..ba6cf19 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -17,6 +17,7 @@ "@nextui-org/divider": "^2.2.5", "@nextui-org/input": "^2.4.8", "@nextui-org/modal": "^2.2.7", + "@nextui-org/radio": "^2.3.8", "@nextui-org/select": "^2.4.9", "@nextui-org/system": "^2.4.6", "@nextui-org/table": "^2.2.8", @@ -1334,6 +1335,31 @@ "react-dom": ">=18 || >=19.0.0-rc.0" } }, + "node_modules/@nextui-org/radio": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@nextui-org/radio/-/radio-2.3.8.tgz", + "integrity": "sha512-ntwjpQ/WT8zQ3Fw5io65VeH2Q68LOgZ4lII7a6x35NDa7Eda1vlYroMAw/vxK8iyZYlUBSJdsoj2FU/10hBPmg==", + "license": "MIT", + "dependencies": { + "@nextui-org/form": "2.1.8", + "@nextui-org/react-utils": "2.1.3", + "@nextui-org/shared-utils": "2.1.2", + "@react-aria/focus": "3.19.0", + "@react-aria/interactions": "3.22.5", + "@react-aria/radio": "3.10.10", + "@react-aria/utils": "3.26.0", + "@react-aria/visually-hidden": "3.8.18", + "@react-stately/radio": "3.10.9", + "@react-types/radio": "3.8.5", + "@react-types/shared": "3.26.0" + }, + "peerDependencies": { + "@nextui-org/system": ">=2.4.0", + "@nextui-org/theme": ">=2.4.3", + "react": ">=18 || >=19.0.0-rc.0", + "react-dom": ">=18 || >=19.0.0-rc.0" + } + }, "node_modules/@nextui-org/react-rsc-utils": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@nextui-org/react-rsc-utils/-/react-rsc-utils-2.1.1.tgz", @@ -2080,6 +2106,27 @@ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, + "node_modules/@react-aria/radio": { + "version": "3.10.10", + "resolved": "https://registry.npmjs.org/@react-aria/radio/-/radio-3.10.10.tgz", + "integrity": "sha512-NVdeOVrsrHgSfwL2jWCCXFsWZb+RMRZErj5vthHQW4nkHECGOzeX56VaLWTSvdoCPqi9wdIX8A6K9peeAIgxzA==", + "license": "Apache-2.0", + "dependencies": { + "@react-aria/focus": "^3.19.0", + "@react-aria/form": "^3.0.11", + "@react-aria/i18n": "^3.12.4", + "@react-aria/interactions": "^3.22.5", + "@react-aria/label": "^3.7.13", + "@react-aria/utils": "^3.26.0", + "@react-stately/radio": "^3.10.9", + "@react-types/radio": "^3.8.5", + "@react-types/shared": "^3.26.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, "node_modules/@react-aria/selection": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/@react-aria/selection/-/selection-3.21.0.tgz", @@ -2431,6 +2478,22 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, + "node_modules/@react-stately/radio": { + "version": "3.10.9", + "resolved": "https://registry.npmjs.org/@react-stately/radio/-/radio-3.10.9.tgz", + "integrity": "sha512-kUQ7VdqFke8SDRCatw2jW3rgzMWbvw+n2imN2THETynI47NmNLzNP11dlGO2OllRtTrsLhmBNlYHa3W62pFpAw==", + "license": "Apache-2.0", + "dependencies": { + "@react-stately/form": "^3.1.0", + "@react-stately/utils": "^3.10.5", + "@react-types/radio": "^3.8.5", + "@react-types/shared": "^3.26.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, "node_modules/@react-stately/selection": { "version": "3.18.0", "resolved": "https://registry.npmjs.org/@react-stately/selection/-/selection-3.18.0.tgz", @@ -2663,6 +2726,18 @@ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, + "node_modules/@react-types/radio": { + "version": "3.8.5", + "resolved": "https://registry.npmjs.org/@react-types/radio/-/radio-3.8.5.tgz", + "integrity": "sha512-gSImTPid6rsbJmwCkTliBIU/npYgJHOFaI3PNJo7Y0QTAnFelCtYeFtBiWrFodSArSv7ASqpLLUEj9hZu/rxIg==", + "license": "Apache-2.0", + "dependencies": { + "@react-types/shared": "^3.26.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, "node_modules/@react-types/select": { "version": "3.9.8", "resolved": "https://registry.npmjs.org/@react-types/select/-/select-3.9.8.tgz", diff --git a/client/package.json b/client/package.json index 7f847ab..2c4fc7b 100644 --- a/client/package.json +++ b/client/package.json @@ -18,6 +18,7 @@ "@nextui-org/divider": "^2.2.5", "@nextui-org/input": "^2.4.8", "@nextui-org/modal": "^2.2.7", + "@nextui-org/radio": "^2.3.8", "@nextui-org/select": "^2.4.9", "@nextui-org/system": "^2.4.6", "@nextui-org/table": "^2.2.8", diff --git a/client/src/Zustand.ts b/client/src/Zustand.ts index e35ae76..44891bd 100644 --- a/client/src/Zustand.ts +++ b/client/src/Zustand.ts @@ -1,8 +1,4 @@ -import { - DateFormatter as IntlDateFormatter, - parseZonedDateTime, - ZonedDateTime, -} from "@internationalized/date"; +import { DateFormatter as IntlDateFormatter } from "@internationalized/date"; import { create } from "zustand"; export type Task = string; @@ -21,7 +17,7 @@ export const Availabilities: Availability[] = ["yes", "maybe", "no"]; export interface EventData { id: number; - date: ZonedDateTime; + date: string; tasks: Partial>; volunteers: Partial>; description: string; @@ -37,7 +33,7 @@ const zustand = create()((set) => ({ { id: 0, // date: parseDateTime("2025-01-05T11:00[Europe/Berlin]").toString(), - date: parseZonedDateTime("2025-01-05T11:00[Europe/Berlin]"), + date: "2025-01-05T11:00[Europe/Berlin]", tasks: { Audio: "Mark", Livestream: undefined, @@ -48,7 +44,7 @@ const zustand = create()((set) => ({ }, { id: 1, - date: parseZonedDateTime("2025-01-12T11:00[Europe/Berlin]"), + date: "2025-01-12T11:00[Europe/Berlin]", tasks: { Audio: "Mark", Livestream: undefined, diff --git a/client/src/app/Overview.tsx b/client/src/app/Overview.tsx index 146fd71..d8e26f9 100644 --- a/client/src/app/Overview.tsx +++ b/client/src/app/Overview.tsx @@ -6,6 +6,7 @@ import { useState } from "react"; import AddEvent from "../components/Event/AddEvent"; import zustand from "../Zustand"; import { Button } from "@nextui-org/button"; +import AssignmentTable from "@/components/Event/AssignmentTable"; export default function EventVolunteer() { const [showAddItemDialogue, setShowAddItemDialogue] = useState(false); @@ -14,15 +15,10 @@ export default function EventVolunteer() {

Overview

- {zustand.getState().events.map((ee, ii) => ( - + {zustand.getState().events.map((ee) => ( + + + ))}
diff --git a/client/src/app/admin/page.tsx b/client/src/app/admin/page.tsx index 10d58c2..e010fa0 100644 --- a/client/src/app/admin/page.tsx +++ b/client/src/app/admin/page.tsx @@ -1,7 +1,7 @@ "use client"; import AddEvent from "@/components/Event/AddEvent"; -import LocalDate from "@/components/Event/LocalDate"; +import LocalDate from "@/components/LocalDate"; import zustand, { Availability, EventData, Task, Tasks } from "@/Zustand"; import { Add, Copy, Edit, TrashCan } from "@carbon/icons-react"; import { Button, ButtonGroup } from "@nextui-org/button"; @@ -25,6 +25,26 @@ import { Tooltip } from "@nextui-org/tooltip"; import { useAsyncList } from "@react-stately/data"; import React, { Key, useState } from "react"; +function availability2Tailwind(availability?: Availability) { + switch (availability) { + case "yes": + return ""; + default: + return "italic"; + } +} + +function availability2Color(availability?: Availability) { + switch (availability) { + case "yes": + return "default"; + case "maybe": + return "warning"; + default: + return "danger"; + } +} + export default function AdminPanel() { const tasks = [ { key: "date", label: "Date" }, @@ -70,7 +90,7 @@ export default function AdminPanel() { options={{ dateStyle: "medium", timeStyle: "short" }} className="font-bold" > - {event[key].toDate()} + {event[key]} ); case "description": @@ -104,26 +124,6 @@ export default function AdminPanel() {
); default: - function availability2Tailwind(availability?: Availability) { - switch (availability) { - case "yes": - return ""; - default: - return "italic"; - } - } - - function availability2Color(availability?: Availability) { - switch (availability) { - case "yes": - return "default"; - case "maybe": - return "warning"; - default: - return "danger"; - } - } - return (