-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolved build error; graphql codegen
- Loading branch information
1 parent
c9fe821
commit 9ece765
Showing
19 changed files
with
5,353 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
node-version: [22.x] | ||
node-version: [22.4] | ||
|
||
defaults: | ||
run: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ColumnDef } from "@tanstack/react-table"; | ||
import { Checkbox } from "@/components/ui/checkbox"; | ||
import { TutorFormEventsQuery } from "@/lib/gql/generated/graphql"; | ||
|
||
export const columns: ColumnDef<TutorFormEventsQuery['events'][0]>[] = [ | ||
{ | ||
accessorKey: "isSelected", | ||
header: "", | ||
cell: ({ row }) => ( | ||
<div className="w-full flex flex-row justify-center"> | ||
<Checkbox | ||
className={"mx-auto"} | ||
checked={row.getIsSelected()} | ||
onCheckedChange={(value) => row.toggleSelected(!!value)} | ||
aria-label="Ich kann diese Vorlesung halten" | ||
/> | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: "title", | ||
header: () => <div className="text-left">Veranstaltung</div>, | ||
}, | ||
{ | ||
accessorKey: "from", | ||
header: () => <div className="text-left">Datum</div>, | ||
cell: ({ row }) => { | ||
const date = new Date(row.getValue('from')); | ||
return date.toLocaleDateString(); | ||
} | ||
}, | ||
{ | ||
accessorKey: "from", | ||
header: () => <div className="text-left">Von</div>, | ||
cell: ({ row }) => { | ||
const time = new Date(row.getValue('from')); | ||
return time.toLocaleTimeString(); | ||
} | ||
}, | ||
{ | ||
accessorKey: "to", | ||
header: () => <div className="text-left">Bis</div>, | ||
cell: ({ row }) => { | ||
const time = new Date(row.getValue('to')); | ||
return time.toLocaleTimeString(); | ||
} | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,78 @@ | ||
"use client" | ||
|
||
import { | ||
ColumnDef, | ||
flexRender, | ||
getCoreRowModel, | ||
useReactTable, | ||
ColumnDef, | ||
flexRender, | ||
getCoreRowModel, | ||
useReactTable, | ||
} from "@tanstack/react-table" | ||
|
||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/table" | ||
|
||
interface DataTableProps<TData, TValue> { | ||
columns: ColumnDef<TData, TValue>[] | ||
data: TData[] | ||
interface DataTableProps<TData> { | ||
columns: ColumnDef<TData>[] | ||
data: TData[] | ||
} | ||
|
||
const scrollable = "w-full h-30 overflow-scroll" | ||
|
||
export function DataTable<TData, TValue>({ | ||
columns, | ||
export function DataTable<TData>({ | ||
columns, | ||
data, | ||
}: DataTableProps<TData>) { | ||
const table = useReactTable({ | ||
data, | ||
}: Readonly<DataTableProps<TData, TValue>>) { | ||
const table = useReactTable({ | ||
data, | ||
columns, | ||
getCoreRowModel: getCoreRowModel(), | ||
}); | ||
columns, | ||
getCoreRowModel: getCoreRowModel(), | ||
}) | ||
|
||
return ( | ||
<div className="rounded-md border-2"> | ||
<Table> | ||
<TableHeader> | ||
{table.getHeaderGroups().map((headerGroup) => ( | ||
<TableRow key={headerGroup.id}> | ||
{headerGroup.headers.map((header) => { | ||
return ( | ||
<TableHead key={header.id}> | ||
{header.isPlaceholder | ||
? null | ||
: flexRender( | ||
header.column.columnDef.header, | ||
header.getContext() | ||
)} | ||
</TableHead> | ||
) | ||
})} | ||
</TableRow> | ||
))} | ||
</TableHeader> | ||
<TableBody> | ||
{table.getRowModel().rows?.length ? ( | ||
table.getRowModel().rows.map((row) => ( | ||
<TableRow | ||
key={row.id} | ||
data-state={row.getIsSelected() && "selected"} | ||
> | ||
{row.getVisibleCells().map((cell) => ( | ||
<TableCell key={cell.id}> | ||
{flexRender(cell.column.columnDef.cell, cell.getContext())} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
)) | ||
) : ( | ||
<TableRow> | ||
<TableCell colSpan={columns.length} className="h-24 text-center"> | ||
No results. | ||
</TableCell> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
) | ||
return ( | ||
<div className="rounded-md border"> | ||
<Table> | ||
<TableHeader> | ||
{table.getHeaderGroups().map((headerGroup) => ( | ||
<TableRow key={headerGroup.id}> | ||
{headerGroup.headers.map((header) => ( | ||
<TableHead key={header.id}> | ||
{header.isPlaceholder | ||
? null | ||
: flexRender( | ||
header.column.columnDef.header, | ||
header.getContext() | ||
)} | ||
</TableHead> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableHeader> | ||
<TableBody> | ||
{table.getRowModel().rows?.length ? ( | ||
table.getRowModel().rows.map((row) => ( | ||
<TableRow | ||
key={row.id} | ||
data-state={row.getIsSelected() && "selected"} | ||
> | ||
{row.getVisibleCells().map((cell) => ( | ||
<TableCell key={cell.id}> | ||
{flexRender(cell.column.columnDef.cell, cell.getContext())} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
)) | ||
) : ( | ||
<TableRow> | ||
<TableCell colSpan={columns.length} className="h-24 text-center"> | ||
No results. | ||
</TableCell> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
import { columns } from "../../../../lib/columns" | ||
import { DataTable } from "./data-table" | ||
import { client } from "@/lib/graphClient" | ||
import { GET_EVENTS } from "@/lib/queries" | ||
import { Veranstaltungen, Vorlesung } from "@/lib/definitions" | ||
|
||
async function getData(): Promise<Vorlesung[]> { | ||
const jsonData : Veranstaltungen = await client.request(GET_EVENTS); | ||
|
||
const vorlesungen: Vorlesung[] = jsonData.events.map(event => ({ | ||
id: event.ID, | ||
title: event.title, | ||
date: new Date(event.from).toLocaleDateString(), | ||
time: new Date(event.from).toLocaleTimeString() + " - " + new Date(event.to).toLocaleTimeString() | ||
})); | ||
|
||
return vorlesungen; | ||
} | ||
import { columns } from "./columns"; | ||
import { DataTable } from "./data-table"; | ||
import { client } from "@/lib/graphClient"; | ||
import { | ||
TutorFormEventsQuery, | ||
TutorFormEventsDocument, | ||
} from "@/lib/gql/generated/graphql"; | ||
|
||
export default async function EventTable() { | ||
const data = await getData() | ||
const data = await client.request<TutorFormEventsQuery>( | ||
TutorFormEventsDocument | ||
); | ||
|
||
return ( | ||
<div className="w-fill mx-auto"> | ||
<DataTable columns={columns} data={data}/> | ||
</div> | ||
) | ||
return ( | ||
<div className="w-fill mx-auto"> | ||
<DataTable columns={columns} data={data.events} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
|
||
const config: CodegenConfig = { | ||
overwrite: true, | ||
schema: "../server/graph/schema.graphqls", | ||
documents: "lib/**/*.graphql", | ||
generates: { | ||
"lib/gql/generated/": { | ||
preset: "client", | ||
} | ||
} | ||
}; | ||
|
||
export default config; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.