"use client"; import { Loading } from "@/components/dashboard/loading"; import { MultiSelect } from "@/components/staffs/multi-select"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; // import { // Form, // FormControl, // FormDescription, // FormField, // FormItem, // FormLabel, // FormMessage, // } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { toast } from "@/components/ui/toaster"; // import { trpc } from "@/lib/trpc/client"; // import { zodResolver } from "@hookform/resolvers/zod"; import { DialogTrigger } from "@radix-ui/react-dialog"; // import { Permission } from "@aigxion/db"; import { useRouter } from "next/navigation"; import { useState } from "react"; // import { useForm } from "react-hook-form"; import { z } from "zod"; type Props = { trigger: React.ReactNode; // permissions?: Permission[]; }; const formSchema = z.object({ name: z .string() .min(3) .regex(/^[a-zA-Z0-9_\-\.\*]+$/, { message: "Must be at least 3 characters long and only contain alphanumeric, periods, dashes and underscores", }), description: z.string().optional(), permissionOptions: z .array( z.object({ label: z.string(), value: z.string(), }), ) .optional(), }); export const CreateNewRole: React.FC = ({ trigger, }) => { const router = useRouter(); const [open, setOpen] = useState(false); // const form = useForm>({ // resolver: zodResolver(formSchema), // reValidateMode: "onBlur", // }); // const createRole = trpc.rbac.createRole.useMutation({ // onSuccess({ roleId }) { // toast.success("Role created"); // form.reset({ // name: "", // description: "", // }); // setOpen(false); // router.push(`/app/authorization/roles/${roleId}`); // }, // onError(err) { // console.error(err); // toast.error(err.message); // }, // }); async function onSubmit(values: z.infer) { // createRole.mutate({ // name: values.name, // description: values.description, // permissionIds: values.permissionOptions?.map((o) => o.value), // }); } return ( {trigger} Create a new role Roles group permissions together. {/*
( Name A unique name for your role. You will use this when managing roles through the API. These are not customer facing. )} /> ( Description{" "} Optional