add: domain in access and page
This commit is contained in:
@@ -37,6 +37,7 @@ export default function Access() {
|
|||||||
pagesInfo.page === 1
|
pagesInfo.page === 1
|
||||||
? i + 1
|
? i + 1
|
||||||
: i + pagesInfo.page_size * (pagesInfo.page - 1) + 1,
|
: i + pagesInfo.page_size * (pagesInfo.page - 1) + 1,
|
||||||
|
item?.domain?.fa_name || item?.page_data?.domain?.fa_name || "-",
|
||||||
item?.name,
|
item?.name,
|
||||||
item?.description,
|
item?.description,
|
||||||
`${getFaPermissions(item?.page)} (${item?.page})`,
|
`${getFaPermissions(item?.page)} (${item?.page})`,
|
||||||
@@ -119,6 +120,7 @@ export default function Access() {
|
|||||||
title="مدیریت دسترسی ها"
|
title="مدیریت دسترسی ها"
|
||||||
columns={[
|
columns={[
|
||||||
"ردیف",
|
"ردیف",
|
||||||
|
"حوزه",
|
||||||
"دسترسی",
|
"دسترسی",
|
||||||
"توضیحات",
|
"توضیحات",
|
||||||
"صفحه",
|
"صفحه",
|
||||||
|
|||||||
@@ -3,14 +3,19 @@ import Button from "../../components/Button/Button";
|
|||||||
import { Grid } from "../../components/Grid/Grid";
|
import { Grid } from "../../components/Grid/Grid";
|
||||||
import Textfield from "../../components/Textfeild/Textfeild";
|
import Textfield from "../../components/Textfeild/Textfeild";
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
import { zValidateEnglishString } from "../../data/getFormTypeErrors";
|
import {
|
||||||
|
zValidateEnglishString,
|
||||||
|
zValidateNumber,
|
||||||
|
} from "../../data/getFormTypeErrors";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { useApiMutation } from "../../utils/useApiRequest";
|
import { useApiMutation } from "../../utils/useApiRequest";
|
||||||
import { useToast } from "../../hooks/useToast";
|
import { useToast } from "../../hooks/useToast";
|
||||||
import { useModalStore } from "../../context/zustand-store/appStore";
|
import { useModalStore } from "../../context/zustand-store/appStore";
|
||||||
|
import { FormApiBasedAutoComplete } from "../../components/FormItems/FormApiBasedAutoComplete";
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
page: zValidateEnglishString("نام صفحه"),
|
page: zValidateEnglishString("نام صفحه"),
|
||||||
|
domain: zValidateNumber("حوزه"),
|
||||||
});
|
});
|
||||||
|
|
||||||
type AddPageProps = {
|
type AddPageProps = {
|
||||||
@@ -27,11 +32,13 @@ export const AddPage = ({ getData, item }: AddPageProps) => {
|
|||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
setValue,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useForm<FormValues>({
|
} = useForm<FormValues>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
page: item?.name || "",
|
page: item?.name || "",
|
||||||
|
domain: item?.domain?.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,6 +52,7 @@ export const AddPage = ({ getData, item }: AddPageProps) => {
|
|||||||
const payload = {
|
const payload = {
|
||||||
name: data.page,
|
name: data.page,
|
||||||
code: data.page + ".view",
|
code: data.page + ".view",
|
||||||
|
domain: data.domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
@@ -83,6 +91,25 @@ export const AddPage = ({ getData, item }: AddPageProps) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<Controller
|
||||||
|
name="domain"
|
||||||
|
control={control}
|
||||||
|
render={() => (
|
||||||
|
<FormApiBasedAutoComplete
|
||||||
|
selectField
|
||||||
|
defaultKey={item?.domain?.id}
|
||||||
|
title="انتخاب حوزه"
|
||||||
|
api="/core/domain/"
|
||||||
|
keyField="id"
|
||||||
|
valueField="fa_name"
|
||||||
|
error={!!errors.domain}
|
||||||
|
errorMessage={errors.domain?.message}
|
||||||
|
onChange={(value) => {
|
||||||
|
setValue("domain", value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<Button type="submit">ثبت</Button>
|
<Button type="submit">ثبت</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default function Pages() {
|
|||||||
? i + 1
|
? i + 1
|
||||||
: i + pagesInfo.page_size * (pagesInfo.page - 1) + 1,
|
: i + pagesInfo.page_size * (pagesInfo.page - 1) + 1,
|
||||||
getFaPermissions(item?.name),
|
getFaPermissions(item?.name),
|
||||||
|
item?.domain?.fa_name || "-",
|
||||||
item?.name,
|
item?.name,
|
||||||
item?.permissions?.map((option: any) => option.name)?.join(" - "),
|
item?.permissions?.map((option: any) => option.name)?.join(" - "),
|
||||||
<Popover key={i}>
|
<Popover key={i}>
|
||||||
@@ -110,7 +111,7 @@ export default function Pages() {
|
|||||||
count={pagesData?.count || 10}
|
count={pagesData?.count || 10}
|
||||||
isPaginated
|
isPaginated
|
||||||
title="صفحات سامانه"
|
title="صفحات سامانه"
|
||||||
columns={["ردیف", "صفحه", "کلید", "دسترسی ها", "عملیات"]}
|
columns={["ردیف", "صفحه", "حوزه", "کلید", "دسترسی ها", "عملیات"]}
|
||||||
rows={pagesTableData}
|
rows={pagesTableData}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export default function UnusedAccess() {
|
|||||||
pagesInfo.page === 1
|
pagesInfo.page === 1
|
||||||
? i + 1
|
? i + 1
|
||||||
: i + pagesInfo.page_size * (pagesInfo.page - 1) + 1,
|
: i + pagesInfo.page_size * (pagesInfo.page - 1) + 1,
|
||||||
|
item?.domain?.fa_name || item?.page_data?.domain?.fa_name || "-",
|
||||||
item?.name,
|
item?.name,
|
||||||
item?.description,
|
item?.description,
|
||||||
`${getFaPermissions(item?.page)} (${item?.page})`,
|
`${getFaPermissions(item?.page)} (${item?.page})`,
|
||||||
@@ -63,7 +64,7 @@ export default function UnusedAccess() {
|
|||||||
count={pagesData?.count || 10}
|
count={pagesData?.count || 10}
|
||||||
isPaginated
|
isPaginated
|
||||||
title="دسترسی های غیر فعال"
|
title="دسترسی های غیر فعال"
|
||||||
columns={["ردیف", "دسترسی", "توضیحات", "صفحه", "عملیات"]}
|
columns={["ردیف", "حوزه", "دسترسی", "توضیحات", "صفحه", "عملیات"]}
|
||||||
rows={pagesTableData}
|
rows={pagesTableData}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Reference in New Issue
Block a user