Fix minor Bugs,
This commit is contained in:
6
.idea/dataSources.xml
generated
6
.idea/dataSources.xml
generated
@@ -2,10 +2,10 @@
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="ticket_sys@localhost" uuid="3d7ee8f1-4863-4cbc-8c64-6945c4151623">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<driver-ref>mariadb</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/ticket_sys</jdbc-url>
|
||||
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mariadb://localhost:3306/ticket_sys</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
|
||||
1
.idea/data_source_mapping.xml
generated
1
.idea/data_source_mapping.xml
generated
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="DataSourcePerFileMappings">
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/3d7ee8f1-4863-4cbc-8c64-6945c4151623/console.sql" value="3d7ee8f1-4863-4cbc-8c64-6945c4151623" />
|
||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/3d7ee8f1-4863-4cbc-8c64-6945c4151623/console_1.sql" value="3d7ee8f1-4863-4cbc-8c64-6945c4151623" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -7,6 +7,7 @@ import {getCategories, Ticket} from "@/components/Tickets";
|
||||
import {sendRequestwTokenClient} from "@/app/actions/auth";
|
||||
import {getUser} from "@/components/getUser";
|
||||
import {useRouter} from "next/navigation";
|
||||
import {revalidatePathClient} from "@/components/revalidatePathClient/revalidatePathClient";
|
||||
|
||||
export default function Page({
|
||||
params,
|
||||
@@ -64,7 +65,6 @@ export default function Page({
|
||||
|
||||
const formAction = (e: FormData) => {
|
||||
|
||||
// Wenn du die Daten aus dem e: FormData Objekt ziehen willst (wie bisher):
|
||||
const ticket: Ticket = {
|
||||
status: Number(e.get("status")),
|
||||
priority: Number(e.get("priority")),
|
||||
@@ -74,7 +74,7 @@ export default function Page({
|
||||
username: currentUser || "none",
|
||||
};
|
||||
sendRequestwTokenClient(`/ticket/create`, "POST",JSON.stringify(ticket))
|
||||
router.push("/tickets")
|
||||
revalidatePathClient("/tickets","page").then( async () => router.push("/tickets",))
|
||||
};
|
||||
|
||||
if (!currentUser) {
|
||||
@@ -151,7 +151,7 @@ export default function Page({
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
<Button type={"submit"} className={"w-min p-4 h-min m-auto text-xl"}>Bearbeiten</Button>
|
||||
<Button type={"submit"} className={"w-min p-4 h-min m-auto text-xl"}>Erstellen</Button>
|
||||
</Form>
|
||||
</SingleCard>
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,8 @@ import { Button } from "@/components/Button";
|
||||
import {DetailedTicket, getCategories, Ticket} from "@/components/Tickets";
|
||||
import { getTicket } from "@/components/Tickets/getTicket";
|
||||
import {sendRequestwTokenClient} from "@/app/actions/auth";
|
||||
import {revalidatePathClient} from "@/components/revalidatePathClient/revalidatePathClient";
|
||||
import {router} from "next/client";
|
||||
|
||||
export default function Page({
|
||||
params,
|
||||
@@ -51,10 +53,8 @@ export default function Page({
|
||||
};
|
||||
|
||||
const formAction = (e: FormData) => {
|
||||
// Hier kannst du die Daten an den Server schicken
|
||||
console.log("Form submitted with:", currentTicket);
|
||||
|
||||
// Wenn du die Daten aus dem e: FormData Objekt ziehen willst (wie bisher):
|
||||
const ticket: Ticket = {
|
||||
status: Number(e.get("status")),
|
||||
priority: Number(e.get("priority")),
|
||||
@@ -63,8 +63,12 @@ export default function Page({
|
||||
description: e.get("description")?.toString() || "none",
|
||||
username: currentTicket?.username || "none",
|
||||
};
|
||||
sendRequestwTokenClient(`/ticket/update/${ticketId}`, "POST",JSON.stringify(ticket))
|
||||
alert("Gespeichert!");
|
||||
|
||||
const asyncRedirect = async () => {
|
||||
await revalidatePathClient(`/tickets/${ticketId}`,"page")
|
||||
await router.push("/tickets")
|
||||
}
|
||||
sendRequestwTokenClient(`/ticket/update/${ticketId}`, "POST",JSON.stringify(ticket)).then(asyncRedirect)
|
||||
};
|
||||
|
||||
if (!currentTicket) return <div>Lade Ticket...</div>;
|
||||
|
||||
@@ -12,7 +12,6 @@ export default async function Page() {
|
||||
<a>Deine Tickets</a>
|
||||
</SingleCard>
|
||||
<TicketTable/>
|
||||
<a></a>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import type {Metadata} from "next";
|
||||
import {Geist, Geist_Mono} from "next/font/google";
|
||||
import "@/app/globals.css";
|
||||
import React from "react";
|
||||
import {Header} from "@/components/Header/Header";
|
||||
import {Footer} from "@/components/Footer";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
|
||||
return (
|
||||
<html lang="de" suppressHydrationWarning>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased flex flex-col min-h-screen`}
|
||||
suppressHydrationWarning
|
||||
>
|
||||
|
||||
<Header/>
|
||||
<main className={"flex grow"}>
|
||||
{children}
|
||||
</main>
|
||||
<Footer/>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
12
src/app/not-found.tsx
Normal file
12
src/app/not-found.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import {Link} from "@/components/Link";
|
||||
import {SingleCard} from "@/components/SingleCard/SingleCard";
|
||||
import React from "react";
|
||||
|
||||
export default async function NotFound(): Promise<React.JSX.Element> {
|
||||
return (
|
||||
<SingleCard className={"flex flex-col"}>
|
||||
<a>Sadly This Feature is not implemented yet!</a>
|
||||
<Link href={"/home"}>Go Back</Link>
|
||||
</SingleCard>
|
||||
)
|
||||
}
|
||||
@@ -15,7 +15,6 @@ export const verifySession = cache(async () => {
|
||||
if (!cookie || resp === null) {
|
||||
return {isAuth: false, token: cookie}
|
||||
}
|
||||
console.log("hello world")
|
||||
const is_valid = (await (resp as Response).json()) as TokenIsValid
|
||||
|
||||
return {isAuth: is_valid.is_valid, token: cookie}
|
||||
|
||||
@@ -25,7 +25,7 @@ export function Row({
|
||||
>
|
||||
<td>{ticketname}</td>
|
||||
<td>{`${StateMapping[status]}`}</td>
|
||||
<td>{`${PrioMapping[priority]}`}</td>
|
||||
<td>{`${PrioMapping[priority -1]}`}</td>
|
||||
<td>{category}</td>
|
||||
<td>{username}</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,50 +1,12 @@
|
||||
import React from "react";
|
||||
import {Row} from "@/components/TicketTable";
|
||||
import {Ticket} from "@/components/Tickets";
|
||||
import {getTickets} from "@/components/Tickets/getTickets";
|
||||
|
||||
import Add from "@/components/svg/add";
|
||||
import {Link} from "@/components/Link";
|
||||
|
||||
export async function TicketTable() {
|
||||
|
||||
const tickets = await getTickets();
|
||||
console.log(tickets);
|
||||
const _mockData: Ticket[] = [{
|
||||
"ticketID": 1,
|
||||
"ticketname": "ADAQ",
|
||||
"username": "admin",
|
||||
"status": 1,
|
||||
"priority": 5,
|
||||
"category": "Crack",
|
||||
"description": "string"
|
||||
},
|
||||
{
|
||||
"ticketID": 2,
|
||||
"ticketname": "ADAQ",
|
||||
"username": "admin",
|
||||
"status": 1,
|
||||
"priority": 5,
|
||||
"category": "Crack",
|
||||
"description": "string"
|
||||
},
|
||||
{
|
||||
"ticketID": 3,
|
||||
"ticketname": "ADAQ",
|
||||
"username": "admin",
|
||||
"status": 1,
|
||||
"priority": 5,
|
||||
"category": "Crack",
|
||||
"description": "string"
|
||||
},
|
||||
{
|
||||
"ticketID": 4,
|
||||
"ticketname": "ADAQ",
|
||||
"username": "admin",
|
||||
"status": 1,
|
||||
"priority": 5,
|
||||
"category": "Crack",
|
||||
"description": "string"
|
||||
}]
|
||||
|
||||
|
||||
return (
|
||||
<div className="flex flex-col w-full px-8">
|
||||
@@ -60,13 +22,15 @@ export async function TicketTable() {
|
||||
</thead>
|
||||
<tbody>
|
||||
{tickets ? tickets.map((item, i) => (
|
||||
<Row key={`${item.ticketname}-${i}`} ticketID={item.ticketID} ticketname={item.ticketname}
|
||||
<Row key={`${item.ticketname}-${i}`}
|
||||
ticketID={item.ticketID} ticketname={item.ticketname}
|
||||
username={item.username}
|
||||
status={item.status} priority={item.priority} category={item.category}/>
|
||||
)): (<tr><td>There are no Tickets available</td></tr>)}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<Link href={"/new/ticket"} className={"w-min p-1 pl-auto"}><Add/></Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import React from "react";
|
||||
import {Row} from "@/components/TicketTable";
|
||||
import {RequestTicket} from "@/components/RequestTickets";
|
||||
import {Ticket} from "@/components/Tickets";
|
||||
|
||||
|
||||
|
||||
export async function UserTable() {
|
||||
const mockData: RequestTicket[] = [{
|
||||
const mockData: Ticket[] = [{
|
||||
"ticketID": 1,
|
||||
"ticketname": "ADAQ",
|
||||
"username": "admin",
|
||||
|
||||
1
src/components/revalidatePathClient/export.ts
Normal file
1
src/components/revalidatePathClient/export.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./revalidatePathClient"
|
||||
@@ -0,0 +1,6 @@
|
||||
'use server'
|
||||
import {revalidatePath} from "next/cache";
|
||||
|
||||
export async function revalidatePathClient(path: string, type?: "layout" | "page"): Promise<void> {
|
||||
revalidatePath(path,type)
|
||||
}
|
||||
15
src/components/svg/add.tsx
Normal file
15
src/components/svg/add.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as React from "react"
|
||||
import { SVGProps } from "react"
|
||||
const Add = (props: SVGProps<SVGSVGElement>) => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={40}
|
||||
height={40}
|
||||
fill="#FFF"
|
||||
viewBox="0 -960 960 960"
|
||||
{...props}
|
||||
>
|
||||
<path d="M442.12-442.12H193.3v-75.76h248.82v-248.98h75.76v248.98h248.98v75.76H517.88v248.82h-75.76v-248.82Z" />
|
||||
</svg>
|
||||
)
|
||||
export default Add
|
||||
Reference in New Issue
Block a user