diff --git a/src/components/dashboard/Roles/DataTable.jsx b/src/components/dashboard/Roles/DataTable.jsx
index 7a1e3c6..d7147ae 100644
--- a/src/components/dashboard/Roles/DataTable.jsx
+++ b/src/components/dashboard/Roles/DataTable.jsx
@@ -1,12 +1,11 @@
"use client";
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
import { GET_ROLE_LIST } from "@/core/utils/routes";
-import { Box, Stack, Typography } from "@mui/material";
+import { Box, Typography } from "@mui/material";
import { useMemo } from "react";
-// import RowActions from "./RowActions";
import Toolbar from "./Toolbar";
import moment from "jalali-moment";
-import RowActions from "@/components/dashboard/Roles/RowAcctions";
+import RowActions from "./RowAcctions";
const DataTable = () => {
const columns = useMemo(
diff --git a/src/components/dashboard/Roles/RowAcctions/Edit/Form/index.jsx b/src/components/dashboard/Roles/RowAcctions/Edit/Form/index.jsx
new file mode 100644
index 0000000..d95a357
--- /dev/null
+++ b/src/components/dashboard/Roles/RowAcctions/Edit/Form/index.jsx
@@ -0,0 +1,186 @@
+import LtrTextField from "@/core/components/LtrTextField";
+import StyledForm from "@/core/components/StyledForm";
+import { CREATE_ROLE } from "@/core/utils/routes";
+import useRequest from "@/lib/hooks/useRequest";
+import { yupResolver } from "@hookform/resolvers/yup";
+import {
+ Box,
+ Button,
+ Checkbox,
+ Chip,
+ DialogActions,
+ DialogContent,
+ Divider,
+ FormControlLabel,
+ FormHelperText,
+ Grid,
+ Skeleton,
+ Stack,
+} from "@mui/material";
+import { Controller, useForm } from "react-hook-form";
+import { array, object, string } from "yup";
+import usePermissionsList from "@/lib/hooks/usePermissionsList";
+
+const validationSchema = object().shape({
+ name: string().required("نام فارسی نقش را وارد کنید"),
+ name_fa: string().required("نام انگلیسی نقش را وارد کنید"),
+ permissions: array().min(1, "حداقل یک دسترسی را انتخاب نمایید")
+});
+
+const UpdateRoleForm = ({ values, setOpen, mutate }) => {
+ const requestServer = useRequest({ notificationSuccess: true });
+ const { permissions, loadingPermissions } = usePermissionsList();
+
+ const defaultValues = {
+ name: values.name,
+ name_fa: values.name_fa,
+ permissions: values.permissions?.map(p => p.id) || []
+ };
+
+ const {
+ control,
+ handleSubmit,
+ formState: { isSubmitting, errors },
+ } = useForm({ defaultValues, resolver: yupResolver(validationSchema) });
+
+ const onSubmit = async (data) => {
+ try {
+ await requestServer(`${CREATE_ROLE}/${values.id}`, "post", {
+ data: {
+ permissions: data.permissions,
+ name: data.name,
+ name_fa: data.name_fa,
+ },
+ });
+ setOpen(false);
+ mutate();
+ } catch (error) {}
+ };
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+ {
+ return (
+
+ );
+ }}
+ name={"name"}
+ />
+
+
+ {
+ return (
+
+ );
+ }}
+ name={"name_fa"}
+ />
+
+
+
+
+
+
+
+ {!loadingPermissions ? (
+ (
+ <>
+ {permissions.map((permission) => (
+
+ {
+ const value = parseInt(e.target.value, 10);
+ if (e.target.checked) {
+ field.onChange([...field.value, value]);
+ } else {
+ field.onChange(field.value.filter((id) => id !== value));
+ }
+ }}
+ />
+ }
+ label={permission.name_fa}
+ />
+
+ ))}
+ {!!error && error.message}
+ >
+ )}
+ />
+ ) : (
+
+
+
+
+
+
+
+
+ )}
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default UpdateRoleForm;
diff --git a/src/components/dashboard/Roles/RowAcctions/Edit/index.jsx b/src/components/dashboard/Roles/RowAcctions/Edit/index.jsx
new file mode 100644
index 0000000..1aa42c4
--- /dev/null
+++ b/src/components/dashboard/Roles/RowAcctions/Edit/index.jsx
@@ -0,0 +1,27 @@
+"use client";
+import { Edit } from "@mui/icons-material";
+import { Dialog, IconButton, Tooltip } from "@mui/material";
+import { useState } from "react";
+import UpdateUserForm from "./Form";
+
+const UpdateUser = ({ values, mutate }) => {
+ const [open, setOpen] = useState(false);
+
+ const handleOpen = () => {
+ setOpen(true);
+ };
+
+ return (
+ <>
+
+
+
+
+
+
+ >
+ );
+};
+export default UpdateUser;
diff --git a/src/components/dashboard/Roles/RowAcctions/index.jsx b/src/components/dashboard/Roles/RowAcctions/index.jsx
index e192a81..b551a15 100644
--- a/src/components/dashboard/Roles/RowAcctions/index.jsx
+++ b/src/components/dashboard/Roles/RowAcctions/index.jsx
@@ -1,11 +1,11 @@
import { Box } from "@mui/material";
import Delete from "./Delete";
-// import UpdateUser from "./Edit";
+import UpdateUser from "./Edit";
const RowActions = ({ row, mutate }) => {
return (
- {/**/}
+
);
};
diff --git a/src/components/dashboard/Roles/Toolbar/Create/Form/index.jsx b/src/components/dashboard/Roles/Toolbar/Create/Form/index.jsx
index dbc11e9..e573312 100644
--- a/src/components/dashboard/Roles/Toolbar/Create/Form/index.jsx
+++ b/src/components/dashboard/Roles/Toolbar/Create/Form/index.jsx
@@ -39,7 +39,6 @@ const CreateRoleForm = ({ setOpen, mutate }) => {
control,
handleSubmit,
formState: { isSubmitting, errors },
- watch,
} = useForm({ defaultValues, resolver: yupResolver(validationSchema) });
const onSubmit = async (data) => {