toast für admin-formulare

This commit is contained in:
PxlLoewe
2025-07-13 01:13:13 -07:00
parent a144b9efcd
commit 90e05dc478
4 changed files with 8 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import { useState } from "react";
import { deleteHeliport, upsertHeliport } from "../action";
import { Button } from "../../../../_components/ui/Button";
import { redirect } from "next/navigation";
import toast from "react-hot-toast";
export const HeliportForm = ({ heliport }: { heliport?: Heliport }) => {
const form = useForm({
@@ -24,6 +25,7 @@ export const HeliportForm = ({ heliport }: { heliport?: Heliport }) => {
setLoading(true);
await upsertHeliport(values, heliport?.id);
setLoading(false);
toast.success("Daten gespeichert");
if (!heliport) redirect(`/admin/Heliport`);
})}
className="flex flex-wrap gap-3"

View File

@@ -10,6 +10,7 @@ import { deleteKeyword, upsertKeyword } from "../action";
import { Button } from "../../../../_components/ui/Button";
import { redirect } from "next/navigation";
import { ListInput } from "_components/ui/List";
import toast from "react-hot-toast";
export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
const form = useForm({
@@ -25,6 +26,7 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
setLoading(true);
await upsertKeyword(values, keyword?.id);
setLoading(false);
toast.success("Daten gespeichert");
if (!keyword) redirect(`/admin/keyword`);
})}
className="grid grid-cols-6 gap-3"

View File

@@ -6,6 +6,7 @@ import { PenaltyOptionalDefaults, PenaltyOptionalDefaultsSchema } from "@repo/db
import { Button } from "_components/ui/Button";
import { Switch } from "_components/ui/Switch";
import { useForm } from "react-hook-form";
import toast from "react-hot-toast";
export const ReasonForm = ({
penalty,
@@ -27,6 +28,7 @@ export const ReasonForm = ({
onSubmit={form.handleSubmit(async (penalty) => {
if (!penalty.id) return;
const newPenalty = await editPenalty(penalty.id, penalty);
toast.success("Daten gespeichert");
form.reset(newPenalty);
})}
>

View File

@@ -9,6 +9,7 @@ import { useState } from "react";
import { deleteStation, upsertStation } from "../action";
import { Button } from "../../../../_components/ui/Button";
import { redirect } from "next/navigation";
import toast from "react-hot-toast";
export const StationForm = ({ station }: { station?: Station }) => {
const form = useForm({
@@ -24,6 +25,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
setLoading(true);
await upsertStation(values, station?.id);
setLoading(false);
toast.success("Daten gespeichert");
if (!station) redirect(`/admin/station`);
})}
className="grid grid-cols-6 gap-3"