Skip to content

Commit

Permalink
data seeds; er diagram; design changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dheidemann committed Oct 15, 2024
1 parent 0563b55 commit fbf44c3
Show file tree
Hide file tree
Showing 24 changed files with 1,470 additions and 217 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PUBLIC_URL="http://localhost:8080"
API_KEY=""
PEPPER_KEY=""

POSTGRES_PASSWORD="password123"
POSTGRES_USER="postgres"
Expand Down
13 changes: 9 additions & 4 deletions frontend/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import {Toaster} from "@/components/ui/sonner";
import { Toaster } from "@/components/ui/sonner";
import Header from "@/components/header";
import { Providers } from "./providers";
import {Footer} from "@/components/footer";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -18,9 +20,12 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<Header />
<body className={inter.className}>{children}</body>
<Toaster />
<Providers>
<Header />
<body className={inter.className}><div className="mt-[60px]">{children}</div></body>
<Toaster />
</Providers>
<Footer />
</html>
);
}
5 changes: 1 addition & 4 deletions frontend/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React, { Suspense } from "react";
import { Skeleton } from "@/components/ui/skeleton";
import Planner from "./ui/planner";
import { Providers } from "./providers";

export default function Home() {
return (
<Suspense fallback={<Skeleton className="h-10 w-[200px]" />}>
<Providers>
<Planner />
</Providers>
<Planner />
</Suspense>
);
}
33 changes: 23 additions & 10 deletions frontend/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"use client"
"use client";

import {ReactNode, createContext, useContext, useState} from "react";
import { User } from "@/lib/gql/generated/graphql"
import { ReactNode, createContext, useContext, useState } from "react";
import { User } from "@/lib/gql/generated/graphql";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { type ThemeProviderProps } from "next-themes/dist/types";

type UserContextType = {
user: User | null;
setUser: (user: User | null) => void
}
setUser: (user: User | null) => void;
};

const UserContext = createContext<UserContextType | undefined>(undefined);

Expand All @@ -15,8 +17,8 @@ export const useUser = () => {
if (!context) {
throw new Error("useUser must be used within a UserProvider");
}
return context
}
return context;
};

const UserProvider = ({ children }: { children: ReactNode }) => {
const [user, setUser] = useState<User | null>(null);
Expand All @@ -28,8 +30,19 @@ const UserProvider = ({ children }: { children: ReactNode }) => {
);
};

const ThemeProvider = ({ children, ...props }: ThemeProviderProps) => {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
};

export const Providers = ({ children }: { children: ReactNode }) => {
return (
<UserProvider>{children}</UserProvider>
)
}
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<UserProvider>{children}</UserProvider>
</ThemeProvider>
);
};
File renamed without changes.
32 changes: 13 additions & 19 deletions frontend/app/ui/event-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import {
AddStudentApplicationForEventMutationVariables,
AddStudentRegistrationForEventDocument,
AddStudentRegistrationForEventMutation,
AddStudentRegistrationForEventMutationVariables,
Expand All @@ -15,7 +14,6 @@ import {
UserEventRegistrationDocument,
UserEventRegistrationQuery,
UserEventRegistrationQueryVariables,
UserToEventRegistration,
} from "@/lib/gql/generated/graphql";
import { client } from "@/lib/graphClient";
import React, { useEffect, useState } from "react";
Expand All @@ -41,6 +39,7 @@ import MapPreview from "@/components/map-preview";
import { useUser } from "../providers";
import { SignInDialog } from "@/components/sign-in-dialog";
import { DialogTrigger } from "@radix-ui/react-dialog";
import { MailLinkWithLabel } from "@/components/links/email";

export default function EventDialog({ id }: { id: number }) {
const { user } = useUser();
Expand Down Expand Up @@ -229,6 +228,9 @@ export default function EventDialog({ id }: { id: number }) {
{event?.tutorsAssigned?.map((e, i) => {
const capacity = e.room?.capacity ?? 1;
const utilization = (registrations[i] / capacity) * 100;
const isRegisteredEvent =
e.room?.number === registration?.room.number &&
e.room?.building.ID === registration?.room.building.ID;

return (
<TableRow key={e.room?.number} className="relative">
Expand All @@ -250,18 +252,10 @@ export default function EventDialog({ id }: { id: number }) {
</p>
</HoverCardTrigger>
<HoverCardContent>
<p className="mb-1 text-xs text-muted-foreground">
{t.fn + " " + t.sn}
</p>
<div className="flex flex-row items-center">
<Mail className="mr-2 h-4 w-4 opacity-70" />
<a
href={"mailto:" + t.mail}
className="hover:underline text-blue-500"
>
{t.mail}
</a>
</div>
<MailLinkWithLabel
mail={t.mail}
label={t.fn + " " + t.sn}
/>
</HoverCardContent>
</HoverCard>
))}
Expand Down Expand Up @@ -337,7 +331,9 @@ export default function EventDialog({ id }: { id: number }) {
<TableCell className="relative z-1">
<Button
disabled={utilization == 100 || !user || regLoading}
variant="outline"
variant={
isRegisteredEvent && user ? "destructive" : "outline"
}
onClick={() => {
handleRegistrationChange(
{
Expand All @@ -353,10 +349,8 @@ export default function EventDialog({ id }: { id: number }) {
{regLoading && (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
)}
{registration
? e.room?.number === registration.room.number &&
e.room.building.ID ===
registration.room.building.ID
{registration && user
? isRegisteredEvent
? "Abmelden"
: "Wechseln"
: "Anmelden"}
Expand Down
Loading

0 comments on commit fbf44c3

Please sign in to comment.