diff --git a/frontend/app/form-tutor/ui/table/columns.tsx b/frontend/app/form-tutor/ui/table/columns.tsx index c8f89a0..bdff299 100644 --- a/frontend/app/form-tutor/ui/table/columns.tsx +++ b/frontend/app/form-tutor/ui/table/columns.tsx @@ -4,13 +4,14 @@ import { ColumnDef } from "@tanstack/react-table"; import { Checkbox } from "@/components/ui/checkbox"; import { TutorFormEventsQuery } from "@/lib/gql/generated/graphql"; import { eventBroker } from "@/lib/eventBroker"; +import { EventLabelBadge } from "@/components/ui/badge"; +import { calculateFontColor } from "@/lib/utils/colorUtils"; export const columns: ColumnDef[] = [ { accessorKey: "isSelected", header: "", cell: ({ row }) => ( -
[] = [ }} aria-label="Ich kann diese Vorlesung halten" /> -
), }, { accessorKey: "title", header: () =>
Veranstaltung
, + cell: ({ row }) => ( +
+
{row.original.title}
+ + {row.original.type.name} + +
+ ), }, { accessorKey: "from", diff --git a/frontend/components/ui/badge.tsx b/frontend/components/ui/badge.tsx new file mode 100644 index 0000000..66cba29 --- /dev/null +++ b/frontend/components/ui/badge.tsx @@ -0,0 +1,43 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils/tailwindUtils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground", + secondary: + "border-transparent bg-secondary text-secondary-foreground", + destructive: + "border-transparent bg-destructive text-destructive-foreground", + outline: "text-foreground", + event: "border-transparent bg-secondary text-secondary-foreground disabled" + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +function EventLabelBadge({ className, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { EventLabelBadge, Badge, badgeVariants } diff --git a/frontend/components/ui/button.tsx b/frontend/components/ui/button.tsx index 9a5d4d8..789d7d9 100644 --- a/frontend/components/ui/button.tsx +++ b/frontend/components/ui/button.tsx @@ -2,7 +2,7 @@ import * as React from "react" import { Slot } from "@radix-ui/react-slot" import { cva, type VariantProps } from "class-variance-authority" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils/tailwindUtils" const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", diff --git a/frontend/components/ui/checkbox.tsx b/frontend/components/ui/checkbox.tsx index 90a368d..6574485 100644 --- a/frontend/components/ui/checkbox.tsx +++ b/frontend/components/ui/checkbox.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as CheckboxPrimitive from "@radix-ui/react-checkbox" import { Check } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils/tailwindUtils" const Checkbox = React.forwardRef< React.ElementRef, diff --git a/frontend/components/ui/input.tsx b/frontend/components/ui/input.tsx index b0d24cf..98192a6 100644 --- a/frontend/components/ui/input.tsx +++ b/frontend/components/ui/input.tsx @@ -1,6 +1,6 @@ import * as React from "react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils/tailwindUtils" export interface InputProps extends React.InputHTMLAttributes {} diff --git a/frontend/components/ui/table.tsx b/frontend/components/ui/table.tsx index 157e0f0..6d68414 100644 --- a/frontend/components/ui/table.tsx +++ b/frontend/components/ui/table.tsx @@ -1,6 +1,6 @@ import * as React from "react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils/tailwindUtils" const Table = React.forwardRef< HTMLTableElement, diff --git a/frontend/lib/gql/generated/gql.ts b/frontend/lib/gql/generated/gql.ts index 38f7664..8c5cf22 100644 --- a/frontend/lib/gql/generated/gql.ts +++ b/frontend/lib/gql/generated/gql.ts @@ -14,7 +14,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ */ const documents = { "mutation addTutor($firstName: String!, $lastName: String!, $email: String!, $eventsAvailable: [Int!]) {\n addTutor(\n tutor: {fn: $firstName, sn: $lastName, mail: $email, eventsAvailable: $eventsAvailable}\n )\n}": types.AddTutorDocument, - "query tutorFormEvents {\n events(needsTutors: true) {\n ID\n title\n from\n to\n }\n}": types.TutorFormEventsDocument, + "query tutorFormEvents {\n events(needsTutors: true) {\n ID\n title\n from\n to\n topic {\n name\n color\n }\n type {\n name\n color\n }\n }\n}": types.TutorFormEventsDocument, "query tutors {\n tutors {\n fn\n sn\n mail\n confirmed\n }\n}": types.TutorsDocument, }; @@ -39,7 +39,7 @@ export function graphql(source: "mutation addTutor($firstName: String!, $lastNam /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "query tutorFormEvents {\n events(needsTutors: true) {\n ID\n title\n from\n to\n }\n}"): (typeof documents)["query tutorFormEvents {\n events(needsTutors: true) {\n ID\n title\n from\n to\n }\n}"]; +export function graphql(source: "query tutorFormEvents {\n events(needsTutors: true) {\n ID\n title\n from\n to\n topic {\n name\n color\n }\n type {\n name\n color\n }\n }\n}"): (typeof documents)["query tutorFormEvents {\n events(needsTutors: true) {\n ID\n title\n from\n to\n topic {\n name\n color\n }\n type {\n name\n color\n }\n }\n}"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/frontend/lib/gql/generated/graphql.ts b/frontend/lib/gql/generated/graphql.ts index f1b364d..bdb06ce 100644 --- a/frontend/lib/gql/generated/graphql.ts +++ b/frontend/lib/gql/generated/graphql.ts @@ -35,32 +35,51 @@ export type Event = { ID: Scalars['Int']['output']; description?: Maybe; from: Scalars['timestamptz']['output']; - link?: Maybe; needsTutors: Scalars['Boolean']['output']; roomsAvailable?: Maybe>; title: Scalars['String']['output']; to: Scalars['timestamptz']['output']; - topic: Topic; + topic: Label; tutorsAssigned?: Maybe>; tutorsAvailable?: Maybe>; + type: Label; }; export type EventTutorRoomPair = { __typename?: 'EventTutorRoomPair'; + registrations?: Maybe; room?: Maybe; - tutors: Array; + tutors?: Maybe>; +}; + +export type Label = { + __typename?: 'Label'; + color?: Maybe; + name: Scalars['String']['output']; }; +export enum LabelKind { + EventType = 'EVENT_TYPE', + Topic = 'TOPIC' +} + export type Mutation = { __typename?: 'Mutation'; + addAvailableRoomToEvent: Scalars['String']['output']; addBuilding: Scalars['String']['output']; addEvent: Scalars['String']['output']; + addLabel: Scalars['String']['output']; addRegistration: Scalars['String']['output']; addRoom: Scalars['String']['output']; - addTopic: Scalars['String']['output']; addTutor: Scalars['String']['output']; - linkAvailableRoomToEvent: Scalars['String']['output']; - linkTutorToEventAndRoom: Scalars['String']['output']; + assignTutorToEvent: Scalars['String']['output']; + deleteBuilding: Scalars['String']['output']; + deleteEvent: Scalars['String']['output']; + deleteLabel: Scalars['String']['output']; + deleteRoom: Scalars['String']['output']; + deleteRoomFromEvent: Scalars['String']['output']; + deleteUser: Scalars['String']['output']; + unassignTutorFromEvent: Scalars['String']['output']; updateBuilding: Scalars['String']['output']; updateEvent: Scalars['String']['output']; updateStudentAcceptedStatus: Scalars['String']['output']; @@ -68,6 +87,11 @@ export type Mutation = { }; +export type MutationAddAvailableRoomToEventArgs = { + link: NewRoomToEventLink; +}; + + export type MutationAddBuildingArgs = { building: NewBuilding; }; @@ -78,6 +102,11 @@ export type MutationAddEventArgs = { }; +export type MutationAddLabelArgs = { + label: NewLabel; +}; + + export type MutationAddRegistrationArgs = { student: NewStudent; }; @@ -88,47 +117,73 @@ export type MutationAddRoomArgs = { }; -export type MutationAddTopicArgs = { - topic: NewTopic; +export type MutationAddTutorArgs = { + tutor: NewTutor; +}; + + +export type MutationAssignTutorToEventArgs = { + link: NewEventToTutorLink; }; -export type MutationAddTutorArgs = { - tutor: NewTutor; +export type MutationDeleteBuildingArgs = { + id: Array; +}; + + +export type MutationDeleteEventArgs = { + id: Array; +}; + + +export type MutationDeleteLabelArgs = { + name: Array; +}; + + +export type MutationDeleteRoomArgs = { + buildingID: Scalars['Int']['input']; + number: Scalars['String']['input']; }; -export type MutationLinkAvailableRoomToEventArgs = { +export type MutationDeleteRoomFromEventArgs = { link: NewRoomToEventLink; }; -export type MutationLinkTutorToEventAndRoomArgs = { +export type MutationDeleteUserArgs = { + mail: Array; +}; + + +export type MutationUnassignTutorFromEventArgs = { link: NewEventToTutorLink; }; export type MutationUpdateBuildingArgs = { building: NewBuilding; - buildingID: Scalars['Int']['input']; + id: Scalars['Int']['input']; }; export type MutationUpdateEventArgs = { event: NewEvent; - eventID: Scalars['Int']['input']; + id: Scalars['Int']['input']; }; export type MutationUpdateStudentAcceptedStatusArgs = { accepted: Scalars['Boolean']['input']; - studentMail: Scalars['String']['input']; + mail: Scalars['String']['input']; }; export type MutationUpdateTutorArgs = { + mail: Scalars['String']['input']; tutor: NewTutor; - tutorMail: Scalars['String']['input']; }; export type NewBuilding = { @@ -143,11 +198,11 @@ export type NewBuilding = { export type NewEvent = { description?: InputMaybe; from: Scalars['timestamptz']['input']; - link?: InputMaybe; needsTutors: Scalars['Boolean']['input']; title: Scalars['String']['input']; to: Scalars['timestamptz']['input']; topicName: Scalars['String']['input']; + typeName: Scalars['String']['input']; }; export type NewEventToTutorLink = { @@ -157,6 +212,12 @@ export type NewEventToTutorLink = { tutorMail: Scalars['String']['input']; }; +export type NewLabel = { + color?: InputMaybe; + kind: LabelKind; + name: Scalars['String']['input']; +}; + export type NewRoom = { buildingID: Scalars['Int']['input']; capacity?: InputMaybe; @@ -177,11 +238,6 @@ export type NewStudent = { sn: Scalars['String']['input']; }; -export type NewTopic = { - color?: InputMaybe; - name: Scalars['String']['input']; -}; - export type NewTutor = { eventsAvailable?: InputMaybe>; fn: Scalars['String']['input']; @@ -193,9 +249,9 @@ export type Query = { __typename?: 'Query'; buildings: Array; events: Array; + labels: Array