toast für admin-formulare
This commit is contained in:
@@ -9,6 +9,7 @@ import { useState } from "react";
|
|||||||
import { deleteHeliport, upsertHeliport } from "../action";
|
import { deleteHeliport, upsertHeliport } from "../action";
|
||||||
import { Button } from "../../../../_components/ui/Button";
|
import { Button } from "../../../../_components/ui/Button";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
export const HeliportForm = ({ heliport }: { heliport?: Heliport }) => {
|
export const HeliportForm = ({ heliport }: { heliport?: Heliport }) => {
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
@@ -24,6 +25,7 @@ export const HeliportForm = ({ heliport }: { heliport?: Heliport }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
await upsertHeliport(values, heliport?.id);
|
await upsertHeliport(values, heliport?.id);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
toast.success("Daten gespeichert");
|
||||||
if (!heliport) redirect(`/admin/Heliport`);
|
if (!heliport) redirect(`/admin/Heliport`);
|
||||||
})}
|
})}
|
||||||
className="flex flex-wrap gap-3"
|
className="flex flex-wrap gap-3"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { deleteKeyword, upsertKeyword } from "../action";
|
|||||||
import { Button } from "../../../../_components/ui/Button";
|
import { Button } from "../../../../_components/ui/Button";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { ListInput } from "_components/ui/List";
|
import { ListInput } from "_components/ui/List";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
@@ -25,6 +26,7 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
await upsertKeyword(values, keyword?.id);
|
await upsertKeyword(values, keyword?.id);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
toast.success("Daten gespeichert");
|
||||||
if (!keyword) redirect(`/admin/keyword`);
|
if (!keyword) redirect(`/admin/keyword`);
|
||||||
})}
|
})}
|
||||||
className="grid grid-cols-6 gap-3"
|
className="grid grid-cols-6 gap-3"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { PenaltyOptionalDefaults, PenaltyOptionalDefaultsSchema } from "@repo/db
|
|||||||
import { Button } from "_components/ui/Button";
|
import { Button } from "_components/ui/Button";
|
||||||
import { Switch } from "_components/ui/Switch";
|
import { Switch } from "_components/ui/Switch";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
export const ReasonForm = ({
|
export const ReasonForm = ({
|
||||||
penalty,
|
penalty,
|
||||||
@@ -27,6 +28,7 @@ export const ReasonForm = ({
|
|||||||
onSubmit={form.handleSubmit(async (penalty) => {
|
onSubmit={form.handleSubmit(async (penalty) => {
|
||||||
if (!penalty.id) return;
|
if (!penalty.id) return;
|
||||||
const newPenalty = await editPenalty(penalty.id, penalty);
|
const newPenalty = await editPenalty(penalty.id, penalty);
|
||||||
|
toast.success("Daten gespeichert");
|
||||||
form.reset(newPenalty);
|
form.reset(newPenalty);
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useState } from "react";
|
|||||||
import { deleteStation, upsertStation } from "../action";
|
import { deleteStation, upsertStation } from "../action";
|
||||||
import { Button } from "../../../../_components/ui/Button";
|
import { Button } from "../../../../_components/ui/Button";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
export const StationForm = ({ station }: { station?: Station }) => {
|
export const StationForm = ({ station }: { station?: Station }) => {
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
@@ -24,6 +25,7 @@ export const StationForm = ({ station }: { station?: Station }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
await upsertStation(values, station?.id);
|
await upsertStation(values, station?.id);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
toast.success("Daten gespeichert");
|
||||||
if (!station) redirect(`/admin/station`);
|
if (!station) redirect(`/admin/station`);
|
||||||
})}
|
})}
|
||||||
className="grid grid-cols-6 gap-3"
|
className="grid grid-cols-6 gap-3"
|
||||||
|
|||||||
Reference in New Issue
Block a user