[] = [
);
},
},
+ {
+ id: "actions",
+ cell: ({ row }) => {
+ return ;
+ },
+ },
];
diff --git a/src/app/(dashboard)/dashboard/stores/page.tsx b/src/app/(dashboard)/dashboard/stores/page.tsx
index 0ecd3d70..a497aad6 100644
--- a/src/app/(dashboard)/dashboard/stores/page.tsx
+++ b/src/app/(dashboard)/dashboard/stores/page.tsx
@@ -3,7 +3,7 @@ import StoreDataTable from "~/app/(dashboard)/dashboard/stores/data-table";
import { api } from "~/trpc/server";
const StoresPage = async () => {
- const stores = await api.store.list.query();
+ const stores = await api.store.list();
return (
diff --git a/src/app/(dashboard)/dashboard/stores/update.modal.tsx b/src/app/(dashboard)/dashboard/stores/update.modal.tsx
new file mode 100644
index 00000000..6e461af1
--- /dev/null
+++ b/src/app/(dashboard)/dashboard/stores/update.modal.tsx
@@ -0,0 +1,136 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import { RotateCw, SquarePen } from "lucide-react";
+import { useEffect, useState } from "react";
+import { useForm, type SubmitHandler } from "react-hook-form";
+import type { TypeOf } from "zod";
+import { Button } from "~/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "~/components/ui/dialog";
+import {
+ Form,
+ FormControl,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "~/components/ui/form";
+import { Input } from "~/components/ui/input";
+import { useToast } from "~/components/ui/use-toast";
+import { updateEmployeeInput } from "~/server/api/schemas/employees";
+import { api } from "~/trpc/react";
+import type { RouterOutputs } from "~/trpc/shared";
+
+type Props = {
+ employee: NonNullable;
+};
+
+type FormValues = TypeOf;
+
+const UpdateEmployeeModal = ({ employee }: Props) => {
+ const [isOpen, setIsOpen] = useState(false);
+ const form = useForm({
+ defaultValues: {
+ id: employee.employee.id,
+ name: employee.employee.name,
+ email: employee.employee.email,
+ phone: employee.employee.phone ?? undefined,
+ },
+ resolver: zodResolver(updateEmployeeInput),
+ });
+
+ const updateEmployee = api.employee.update.useMutation();
+ const onSubmit: SubmitHandler = (values) => {
+ updateEmployee.mutate(values);
+ };
+
+ const utils = api.useUtils();
+ const { toast } = useToast();
+ useEffect(() => {
+ if (updateEmployee.isSuccess) {
+ toast({
+ title: "Éxito",
+ description: "Empleado actualizado correctamente",
+ });
+
+ void utils.employee.byStore.invalidate();
+ setIsOpen(false);
+ }
+ }, [updateEmployee.isSuccess]);
+
+ return (
+
+ );
+};
+
+export default UpdateEmployeeModal;
diff --git a/src/app/(dashboard)/employees/create/form.tsx b/src/app/(dashboard)/employees/create/form.tsx
index 0c646003..1542d68b 100644
--- a/src/app/(dashboard)/employees/create/form.tsx
+++ b/src/app/(dashboard)/employees/create/form.tsx
@@ -164,8 +164,8 @@ const CreateEmployeeForm = ({ storeId }: Props) => {
)}
/>
-