mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 21:45:17 +00:00
refactor: add dialog close on submit success
This commit is contained in:
@@ -23,7 +23,7 @@ import { Textarea } from "@/components/ui/textarea";
|
||||
import { api } from "@/utils/api";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { AlertTriangle, SquarePen } from "lucide-react";
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
import { z } from "zod";
|
||||
@@ -42,6 +42,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export const UpdateProject = ({ projectId }: Props) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const utils = api.useUtils();
|
||||
const { mutateAsync, error, isError } = api.project.update.useMutation();
|
||||
const { data } = api.project.one.useQuery(
|
||||
@@ -77,6 +78,7 @@ export const UpdateProject = ({ projectId }: Props) => {
|
||||
.then(() => {
|
||||
toast.success("Project updated succesfully");
|
||||
utils.project.all.invalidate();
|
||||
setIsOpen(false);
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error("Error to update the project");
|
||||
@@ -85,7 +87,7 @@ export const UpdateProject = ({ projectId }: Props) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<DropdownMenuItem
|
||||
className="w-full cursor-pointer space-x-3"
|
||||
|
||||
Reference in New Issue
Block a user