diff --git a/src/main.tsx b/src/main.tsx index 7f0a660..a480ab0 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -17,6 +17,7 @@ import "@fontsource/overpass" import "@fontsource/fira-code" import {Notifications} from "@mantine/notifications"; import {ModalsProvider} from "@mantine/modals"; +import {ReactQueryDevtools} from "@tanstack/react-query-devtools"; export const queryClient = new QueryClient() @@ -45,8 +46,8 @@ ReactDOM.createRoot(document.getElementById('root')!).render( - {/* + {/* */} diff --git a/src/pages/events/EventNavigate.tsx b/src/pages/events/EventNavigate.tsx index 44958df..f7841be 100644 --- a/src/pages/events/EventNavigate.tsx +++ b/src/pages/events/EventNavigate.tsx @@ -19,11 +19,11 @@ export default function EventNavigate() { const eventQuery = useQuery({ queryKey: ["event", eventId], queryFn: async () => (await pb.collection("events").getOne(eventId, { - expand: "eventAdmins, privilegedLists" + expand: "eventAdmins, privilegedLists, privilegedLists.eventListSlots_via_eventList.eventListSlotEntries_via_eventListsSlot" })) }) - const {canEditEventList, canEditEvent} = useEventRights(eventQuery.data) + const {isPrivilegedUser, canEditEvent} = useEventRights(eventQuery.data) if (eventQuery.isLoading) { return @@ -37,7 +37,7 @@ export default function EventNavigate() { return } - if (canEditEventList) { + if (isPrivilegedUser) { return } diff --git a/src/pages/events/EventOverview/EventList.tsx b/src/pages/events/EventOverview/EventList.tsx index 1833c64..361e618 100644 --- a/src/pages/events/EventOverview/EventList.tsx +++ b/src/pages/events/EventOverview/EventList.tsx @@ -43,7 +43,7 @@ import {useEventRights} from "@/pages/events/util.ts"; */ const EventRow = ({event}: { event: EventModel }) => { - const {canEditEventList, canEditEvent} = useEventRights(event) + const {isPrivilegedUser, canEditEvent} = useEventRights(event) const [opened, handlers] = useDisclosure(false) @@ -108,12 +108,13 @@ const EventRow = ({event}: { event: EventModel }) => { - ) : canEditEventList ? - + ) : isPrivilegedUser ? + @@ -185,7 +186,8 @@ export const EventList = () => { return await pb.collection("events").getList(activePage, 10, { sort: sort, - filter: [`hideFromPublic = false`, ...filter].join(" && ") + filter: [`hideFromPublic = false`, ...filter].join(" && "), + expand: "privilegedLists.eventListSlots_via_eventList.eventListSlotEntries_via_eventListsSlot" } ) } diff --git a/src/pages/events/e/:eventId/EditEventRouter.tsx b/src/pages/events/e/:eventId/EditEventRouter.tsx index 5119a34..ae26aab 100644 --- a/src/pages/events/e/:eventId/EditEventRouter.tsx +++ b/src/pages/events/e/:eventId/EditEventRouter.tsx @@ -89,11 +89,11 @@ export default function EditEventRouter() { const eventQuery = useQuery({ queryKey: ["event", eventId], queryFn: async () => (await pb.collection("events").getOne(eventId, { - expand: "eventAdmins, privilegedLists" + expand: "eventAdmins, privilegedLists, privilegedLists.eventListSlots_via_eventList.eventListSlotEntries_via_eventListsSlot" })) }) - const {canEditEventList, canEditEvent} = useEventRights(eventQuery.data) + const {isPrivilegedUser, canEditEvent} = useEventRights(eventQuery.data) if (eventQuery.isLoading) { return @@ -103,7 +103,7 @@ export default function EditEventRouter() { return } - if (!(canEditEvent || canEditEventList)) { + if (!(canEditEvent || isPrivilegedUser)) { return } diff --git a/src/pages/events/e/:eventId/EventLists/:listId/EventListRouter.tsx b/src/pages/events/e/:eventId/EventLists/:listId/EventListRouter.tsx index a690adb..51f4390 100644 --- a/src/pages/events/e/:eventId/EventLists/:listId/EventListRouter.tsx +++ b/src/pages/events/e/:eventId/EventLists/:listId/EventListRouter.tsx @@ -22,6 +22,8 @@ import ListEntryStatusSettings from "@/pages/events/e/:eventId/EventLists/:listId/ListSettings/ListEntryStatusSettings.tsx"; import ShowDebug from "@/components/ShowDebug.tsx"; import {pprintDateTime} from "@/lib/datetime.ts"; +import {useEventRights} from "@/pages/events/util.ts"; +import NotFound from "@/pages/not-found/index.page.tsx"; export default function EventListRouter({event}: { event: EventModel }) { @@ -35,6 +37,8 @@ export default function EventListRouter({event}: { event: EventModel }) { queryFn: async () => (await pb.collection("eventLists").getOne(listId)) }) + const {canEditEvent} = useEventRights(event) + if (listQuery.isLoading) { return } @@ -45,6 +49,34 @@ export default function EventListRouter({event}: { event: EventModel }) { const list = listQuery.data + const nav = [ + { + icon: , + to: `/events/e/${event.id}/lists/overview/${list.id}/slots`, + title: "Zeitslots" + } + ] + + if (canEditEvent) { + nav.push(...[ + { + icon: , + to: `/events/e/${event.id}/lists/overview/${list.id}/settings`, + title: "Einstellungen" + }, + { + icon: , + to: `/events/e/${event.id}/lists/overview/${list.id}/questions`, + title: "Formular" + }, + { + icon: , + to: `/events/e/${event.id}/lists/overview/${list.id}/status`, + title: "Eintrag Status" + } + ]) + } + return
@@ -97,28 +129,7 @@ export default function EventListRouter({event}: { event: EventModel }) {
- {[ - { - icon: , - to: `/events/e/${event.id}/lists/overview/${list.id}/slots`, - title: "Zeitslots" - }, - { - icon: , - to: `/events/e/${event.id}/lists/overview/${list.id}/settings`, - title: "Einstellungen" - }, - { - icon: , - to: `/events/e/${event.id}/lists/overview/${list.id}/questions`, - title: "Formular" - }, - { - icon: , - to: `/events/e/${event.id}/lists/overview/${list.id}/status`, - title: "Eintrag Status" - } - ].map(({icon, to, title}) => ( + {nav.map(({icon, to, title}) => ( {({isActive}) => - - - + + Beschreibung + + formValues.setFieldValue("description", value)} + /> + + + + + + + } { + const {canEditEvent} = useEventRights(event) + + const nav = [...viewNav] + if (canEditEvent) { + nav.push(...editNav) + } + return <> }/> @@ -96,11 +111,15 @@ export default function EventListsRouter({event}: { event: EventModel }) { }/> }/> - }/> - }/> + {canEditEvent && <> + }/> + }/> + } }/> }/> + + }/> } \ No newline at end of file diff --git a/src/pages/events/e/:eventId/EventLists/Search/EventEntries.tsx b/src/pages/events/e/:eventId/EventLists/Search/EventEntries.tsx index 116f046..a22e255 100644 --- a/src/pages/events/e/:eventId/EventLists/Search/EventEntries.tsx +++ b/src/pages/events/e/:eventId/EventLists/Search/EventEntries.tsx @@ -1,4 +1,4 @@ -import {EventListSlotEntriesWithUserModel} from "@/models/EventTypes.ts"; +import {EventListSlotEntriesWithUserModel, EventModel} from "@/models/EventTypes.ts"; import classes from "./EventEntries.module.css"; import {ActionIcon, Code, Collapse, ThemeIcon, Tooltip} from "@mantine/core"; import {IconEye, IconEyeOff, IconList, IconUser} from "@tabler/icons-react"; @@ -16,9 +16,10 @@ import {RenderDateRange} from "@/pages/events/e/:eventId/EventLists/EventListCom import EditSlotEntryMenu from "@/pages/events/e/:eventId/EventLists/EventListComponents/EditSlotEntryMenu.tsx"; import {Link} from "react-router-dom"; -function EventEntry({entry, refetch}: { +function EventEntry({entry, refetch, event}: { entry: EventListSlotEntriesWithUserModel, - refetch: () => void + refetch: () => void, + event: EventModel }) { const [expanded, expandedHandler] = useDisclosure(false) @@ -55,7 +56,7 @@ function EventEntry({entry, refetch}: { {expanded ? : } - + @@ -81,11 +82,12 @@ function EventEntry({entry, refetch}: { } -export default function EventEntries({entries, refetch}: { +export default function EventEntries({entries, refetch, event}: { entries: EventListSlotEntriesWithUserModel[], - refetch: () => void + refetch: () => void, + event: EventModel }) { return
- {entries.map(entry => )} + {entries.map(entry => )}
} \ No newline at end of file diff --git a/src/pages/events/e/:eventId/EventLists/Search/index.tsx b/src/pages/events/e/:eventId/EventLists/Search/index.tsx index 7c18aef..4965a1d 100644 --- a/src/pages/events/e/:eventId/EventLists/Search/index.tsx +++ b/src/pages/events/e/:eventId/EventLists/Search/index.tsx @@ -12,7 +12,15 @@ import { Title, Tooltip } from "@mantine/core"; -import {IconArrowDown, IconFilter, IconFilterEdit, IconFilterOff, IconSend, IconUserSearch} from "@tabler/icons-react"; +import { + IconArrowDown, + IconCsv, + IconFilter, + IconFilterEdit, + IconFilterOff, + IconSend, + IconUserSearch +} from "@tabler/icons-react"; import {useInfiniteQuery} from "@tanstack/react-query"; import {useDebouncedValue, useDisclosure} from "@mantine/hooks"; import {PocketBaseErrorAlert, usePB} from "@/lib/pocketbase.tsx"; @@ -188,6 +196,10 @@ export default function ListSearch({event}: { event: EventModel }) { + + @@ -206,7 +218,7 @@ export default function ListSearch({event}: { event: EventModel }) { - query.refetch()}/> + query.refetch()}/> {query.hasNextPage && (
diff --git a/src/pages/events/s/EventView.tsx b/src/pages/events/s/EventView.tsx index f4ee2bf..0deac12 100644 --- a/src/pages/events/s/EventView.tsx +++ b/src/pages/events/s/EventView.tsx @@ -41,7 +41,7 @@ export default function SharedEvent() { enabled: !!eventId }) - const {canEditEventList, canEditEvent} = useEventRights(eventQuery.data) + const {isPrivilegedUser, canEditEvent} = useEventRights(eventQuery.data) const {handler: loginHandler} = useLogin() @@ -112,7 +112,7 @@ export default function SharedEvent() { } - {canEditEventList &&
+ {isPrivilegedUser &&
) + const result = formValues.values.select ? debugQuery.data?.items.map(i => i[formValues.values.select]) : debugQuery.data?.items + return <>
Debug @@ -76,6 +78,14 @@ export default function DebugPage() { placeholder={"expand"} {...formValues.getInputProps("expand")} /> + + + +
@@ -102,7 +112,7 @@ export default function DebugPage() { - +
}