Event kurzbeschreibung für Listenansicht hinzugefügt
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
import { Bot, Calendar, FileText, UserIcon } from "lucide-react";
|
import { Bot, Calendar, FileText, UserIcon } from "lucide-react";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { useRef, useState } from "react";
|
import { useRef } from "react";
|
||||||
import "react-datepicker/dist/react-datepicker.css";
|
import "react-datepicker/dist/react-datepicker.css";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { PaginatedTable, PaginatedTableRef } from "../../../../_components/PaginatedTable";
|
import { PaginatedTable, PaginatedTableRef } from "../../../../_components/PaginatedTable";
|
||||||
@@ -24,6 +24,7 @@ import { deleteEvent, upsertEvent } from "../action";
|
|||||||
import { AppointmentModal } from "./AppointmentModal";
|
import { AppointmentModal } from "./AppointmentModal";
|
||||||
import { ParticipantModal } from "./ParticipantModal";
|
import { ParticipantModal } from "./ParticipantModal";
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
export const Form = ({ event }: { event?: Event }) => {
|
export const Form = ({ event }: { event?: Event }) => {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
@@ -66,6 +67,7 @@ export const Form = ({ event }: { event?: Event }) => {
|
|||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(async (values) => {
|
onSubmit={form.handleSubmit(async (values) => {
|
||||||
await upsertEvent(values, event?.id);
|
await upsertEvent(values, event?.id);
|
||||||
|
toast.success("Event erfolgreich gespeichert");
|
||||||
if (!event) redirect(`/admin/event`);
|
if (!event) redirect(`/admin/event`);
|
||||||
})}
|
})}
|
||||||
className="grid grid-cols-6 gap-3"
|
className="grid grid-cols-6 gap-3"
|
||||||
@@ -75,17 +77,6 @@ export const Form = ({ event }: { event?: Event }) => {
|
|||||||
<h2 className="card-title">
|
<h2 className="card-title">
|
||||||
<FileText className="w-5 h-5" /> Allgemeines
|
<FileText className="w-5 h-5" /> Allgemeines
|
||||||
</h2>
|
</h2>
|
||||||
<Input form={form} label="Name" name="name" className="input-sm" />
|
|
||||||
<MarkdownEditor form={form} name="description" />
|
|
||||||
<Input
|
|
||||||
form={form}
|
|
||||||
label="Maximale Teilnehmer (Nur für live Events)"
|
|
||||||
className="input-sm"
|
|
||||||
{...form.register("maxParticipants", {
|
|
||||||
valueAsNumber: true,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
<Switch form={form} name="hidden" label="Versteckt" />
|
|
||||||
<Select
|
<Select
|
||||||
form={form}
|
form={form}
|
||||||
name="type"
|
name="type"
|
||||||
@@ -95,6 +86,9 @@ export const Form = ({ event }: { event?: Event }) => {
|
|||||||
value: value,
|
value: value,
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
|
<Input form={form} label="Name" name="name" className="input-sm" />
|
||||||
|
<MarkdownEditor form={form} name="description" />
|
||||||
|
<MarkdownEditor form={form} name="descriptionShort" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="card bg-base-200 shadow-xl col-span-3 max-xl:col-span-6">
|
<div className="card bg-base-200 shadow-xl col-span-3 max-xl:col-span-6">
|
||||||
@@ -144,7 +138,18 @@ export const Form = ({ event }: { event?: Event }) => {
|
|||||||
label="Discord Rolle für eingeschriebene Teilnehmer"
|
label="Discord Rolle für eingeschriebene Teilnehmer"
|
||||||
className="input-sm"
|
className="input-sm"
|
||||||
/>
|
/>
|
||||||
|
<Input
|
||||||
|
form={form}
|
||||||
|
label="Maximale Teilnehmer (Nur für live Events)"
|
||||||
|
className="input-sm"
|
||||||
|
{...form.register("maxParticipants", {
|
||||||
|
valueAsNumber: true,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
<Switch form={form} name="hasPresenceEvents" label="Hat Live Event" />
|
<Switch form={form} name="hasPresenceEvents" label="Hat Live Event" />
|
||||||
|
<div className="divider w-full" />
|
||||||
|
|
||||||
|
<Switch form={form} name="hidden" label="Event verstecken" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{form.watch("hasPresenceEvents") ? (
|
{form.watch("hasPresenceEvents") ? (
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ export const EventCard = ({
|
|||||||
<div className="col-span-4">
|
<div className="col-span-4">
|
||||||
<div className="text-left text-balance">
|
<div className="text-left text-balance">
|
||||||
<MDEditor.Markdown
|
<MDEditor.Markdown
|
||||||
source={event.description}
|
source={event.descriptionShort}
|
||||||
className="whitespace-pre-wrap"
|
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ const ModalBtn = ({
|
|||||||
<div className="text-left text-balance">
|
<div className="text-left text-balance">
|
||||||
<MDEditor.Markdown
|
<MDEditor.Markdown
|
||||||
source={event.description}
|
source={event.description}
|
||||||
className="whitespace-pre-wrap"
|
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ model Participant {
|
|||||||
model Event {
|
model Event {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
name String
|
name String
|
||||||
|
descriptionShort String @default("")
|
||||||
description String
|
description String
|
||||||
type EVENT_TYPE @default(EVENT)
|
type EVENT_TYPE @default(EVENT)
|
||||||
discordRoleId String? @default("")
|
discordRoleId String? @default("")
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Event" ADD COLUMN "descriptionShort" TEXT NOT NULL DEFAULT '';
|
||||||
Reference in New Issue
Block a user