그룹관리 메뉴권한 모달 수정
This commit is contained in:
@@ -38,6 +38,9 @@ export const createColumns = (
|
||||
{
|
||||
accessorKey: "menuNm",
|
||||
header: "메뉴명",
|
||||
cell: ({ getValue }) => (
|
||||
<div className="text-left">{getValue() as string}</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "mngAuthrtYn",
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { useState } from "react";
|
||||
import { useState, useRef } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getCoreRowModel } from "@tanstack/react-table";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import {
|
||||
Select,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
Input,
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
@@ -23,6 +29,7 @@ import {
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useDataTable, useMutationWrapper } from "@/shared/lib";
|
||||
import { createColumns } from "../model/group-menu-authority-table-columns";
|
||||
import { SiteSelect } from "@/entities/site";
|
||||
|
||||
type MenuAuthorityDialogProps = {
|
||||
groupId: string;
|
||||
@@ -33,9 +40,33 @@ function MenuAuthorityDialog({ groupId }: MenuAuthorityDialogProps) {
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [siteId, setSiteId] = useState("");
|
||||
const [keywordType, setKeywordType] = useState("");
|
||||
const [searchParams, setSearchParams] = useState({
|
||||
keyword: "",
|
||||
keywordType: "",
|
||||
siteId: "",
|
||||
});
|
||||
|
||||
const handleReset = () => {
|
||||
if (inputRef.current) inputRef.current.value = "";
|
||||
setKeywordType("");
|
||||
setSiteId("");
|
||||
setSearchParams({
|
||||
keyword: "",
|
||||
keywordType: "",
|
||||
siteId: "",
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENU_AUTHRTS, groupId],
|
||||
queryFn: () => MenuAuthorityApi.getGroupMenuAuthorityList({ groupId, useYn: "Y" }),
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENU_AUTHRTS, groupId, searchParams],
|
||||
queryFn: () => MenuAuthorityApi.getGroupMenuAuthorityList({
|
||||
groupId,
|
||||
...searchParams
|
||||
}),
|
||||
enabled: open && !!groupId,
|
||||
});
|
||||
|
||||
@@ -75,6 +106,17 @@ function MenuAuthorityDialog({ groupId }: MenuAuthorityDialogProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.target as HTMLFormElement);
|
||||
const keyword = formData.get("keyword") as string;
|
||||
setSearchParams({
|
||||
keyword,
|
||||
keywordType,
|
||||
siteId: siteId === "ALL" ? "" : siteId,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
@@ -82,10 +124,42 @@ function MenuAuthorityDialog({ groupId }: MenuAuthorityDialogProps) {
|
||||
메뉴권한
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[80rem]" aria-describedby={undefined}>
|
||||
<DialogContent className="max-w-[120rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>그룹별 메뉴 권한</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2">
|
||||
<SiteSelect
|
||||
value={siteId}
|
||||
onValueChange={(value) => setSiteId(value)}
|
||||
enabledAllSite
|
||||
className="w-[24rem]"
|
||||
/>
|
||||
<Select
|
||||
value={keywordType}
|
||||
onValueChange={(value) => setKeywordType(value)}
|
||||
>
|
||||
<SelectTrigger className="w-[12rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="menuNm">메뉴명</SelectItem>
|
||||
<SelectItem value="menuUrl">메뉴URL</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
name="keyword"
|
||||
className="w-[12rem]"
|
||||
/>
|
||||
<Button type="submit">검색</Button>
|
||||
<Button type="button" color="white" onClick={handleReset}>
|
||||
초기화
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="max-h-[40rem] overflow-auto">{tableComponent}</div>
|
||||
<DialogFooter className="!justify-center">
|
||||
<Button size="lg" onClick={handleSave}>
|
||||
|
||||
Reference in New Issue
Block a user