Merge commit '4ee673204552110924d8c9652cb752d10310cf1b' into iipbs/wr/hasuReg
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
export { FaqPage } from "./ui/faq-page";
|
||||
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import { PostApi, postFormSchema, type PostFormData } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function CreatePage({ bbsId }: { bbsId: string }) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createPost } = useMutationWrapper({
|
||||
mutationFn: (data: PostFormData) => PostApi.createPost(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostFormData>({
|
||||
resolver: zodResolver(postFormSchema),
|
||||
values: {
|
||||
bbsId: parseInt(bbsId),
|
||||
pstTtl: "",
|
||||
wrtrNm: userInfo?.userName ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">FAQ 게시글 등록</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={createPost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,323 @@
|
||||
"use client";
|
||||
|
||||
import dayjs from "dayjs";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionContent,
|
||||
AccordionItem,
|
||||
AccordionTrigger,
|
||||
Button,
|
||||
Checkbox,
|
||||
Input,
|
||||
Label,
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
Skeleton,
|
||||
} from "@common/components";
|
||||
import { AttachmentApi } from "@/entities/attachment";
|
||||
import { PostApi, type PostParams } from "@/entities/post";
|
||||
import { AuthorityButton } from "@/entities/menu-authority";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
useAlertStore,
|
||||
useMenuStore,
|
||||
usePrompt,
|
||||
useMutationWrapper,
|
||||
} from "@/shared/lib";
|
||||
|
||||
function FaqPage({ bbsId }: { bbsId: string }) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { prompt } = usePrompt();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const bbsInfo = useMenuStore((state) => state.bbsInfo);
|
||||
|
||||
const [postParams, setPostParams] = useState<PostParams>({
|
||||
keywordType: "title",
|
||||
keyword: "",
|
||||
});
|
||||
const [selectedPostNumbers, setSelectedPostNumbers] = useState<number[]>([]);
|
||||
|
||||
const {
|
||||
data: postList,
|
||||
isFetched,
|
||||
refetch,
|
||||
} = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, bbsInfo?.bbsTypeCd],
|
||||
queryFn: () =>
|
||||
PostApi.getPostList(parseInt(bbsId), {
|
||||
...postParams,
|
||||
bbsTypeCd: bbsInfo?.bbsTypeCd,
|
||||
}),
|
||||
enabled: !!bbsInfo?.bbsTypeCd,
|
||||
});
|
||||
|
||||
const { mutate: deletePost } = useMutationWrapper({
|
||||
mutationFn: ({ pstNo, delRsn }: { pstNo: number; delRsn?: string }) =>
|
||||
PostApi.deletePost(parseInt(bbsId), pstNo, delRsn),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.");
|
||||
refetch();
|
||||
},
|
||||
});
|
||||
|
||||
const getPromptValue = async (message: string) => {
|
||||
const { resolved, value } = await prompt(message);
|
||||
if (!resolved) return "";
|
||||
return value;
|
||||
};
|
||||
|
||||
const handleDeletePost = async (pstNo: number) => {
|
||||
const delRsn = await getPromptValue("삭제 사유를 입력해주세요.");
|
||||
deletePost({ pstNo, delRsn });
|
||||
};
|
||||
|
||||
const onSelectedPostDelete = async () => {
|
||||
const delRsn = await getPromptValue("삭제 사유를 입력해주세요.");
|
||||
await Promise.all(
|
||||
selectedPostNumbers.map((pstNo) =>
|
||||
PostApi.deletePost(parseInt(bbsId), pstNo, delRsn),
|
||||
),
|
||||
);
|
||||
refetch();
|
||||
setSelectedPostNumbers([]);
|
||||
alert("삭제되었습니다.");
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
refetch();
|
||||
};
|
||||
|
||||
const handleCheckboxChange = (pstNo: number, checked: boolean | string) => {
|
||||
setSelectedPostNumbers(
|
||||
checked === true
|
||||
? [...selectedPostNumbers, pstNo]
|
||||
: selectedPostNumbers.filter((num) => num !== pstNo),
|
||||
);
|
||||
};
|
||||
|
||||
const handleAllCheckboxChange = (checked: boolean | string) => {
|
||||
setSelectedPostNumbers(
|
||||
checked === true ? postList?.content.map((item) => item.pstNo) || [] : [],
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card card-border">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<Label className="mr-2 text-label">검색</Label>
|
||||
<Select
|
||||
value={postParams.keywordType}
|
||||
onValueChange={(keywordType) => {
|
||||
setPostParams({ ...postParams, keywordType });
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="h-[3.2rem] w-[10rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="title">제목</SelectItem>
|
||||
<SelectItem value="all">제목+내용</SelectItem>
|
||||
<SelectItem value="writer">작성자</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
value={postParams.keyword}
|
||||
onChange={(e) =>
|
||||
setPostParams({ ...postParams, keyword: e.target.value })
|
||||
}
|
||||
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<h3 className="text-2xl font-medium text-label">콘텐츠 목록</h3>
|
||||
<div className="flex gap-2">
|
||||
<AuthorityButton
|
||||
authority="regAuthrtYn"
|
||||
onClick={() => router.push(`${pathname}/register`)}
|
||||
>
|
||||
등록
|
||||
</AuthorityButton>
|
||||
<AuthorityButton
|
||||
authority="delAuthrtYn"
|
||||
color="red"
|
||||
onClick={onSelectedPostDelete}
|
||||
disabled={!selectedPostNumbers.length}
|
||||
>
|
||||
선택삭제
|
||||
</AuthorityButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-full overflow-auto !p-0">
|
||||
<div className="mb-4 flex items-center gap-2 rounded-sm border border-border bg-background p-4">
|
||||
<Checkbox
|
||||
id="all-select"
|
||||
checked={selectedPostNumbers.length === postList?.content.length}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={handleAllCheckboxChange}
|
||||
/>
|
||||
<Label htmlFor="all-select" className="text-2xl">
|
||||
전체선택
|
||||
</Label>
|
||||
</div>
|
||||
{isFetched ? (
|
||||
<Accordion
|
||||
type="multiple"
|
||||
className="secondary flex flex-col gap-4"
|
||||
>
|
||||
{postList?.content.map((item) => (
|
||||
<div key={item.pstNo} className="flex items-start gap-2">
|
||||
<Checkbox
|
||||
id={item.pstNo.toString()}
|
||||
checked={selectedPostNumbers.includes(item.pstNo)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) =>
|
||||
handleCheckboxChange(item.pstNo, checked)
|
||||
}
|
||||
className="mx-2 my-6"
|
||||
/>
|
||||
<AccordionItem
|
||||
value={item.pstNo.toString()}
|
||||
className="w-full"
|
||||
>
|
||||
<AccordionTrigger>
|
||||
<div className="flex flex-1 items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-primary">Q</span>
|
||||
<span>{item.pstTtl}</span>
|
||||
</div>
|
||||
<span className="px-4 text-[1.2rem] font-normal text-label">
|
||||
등록일: {dayjs(item.regDt).format("YYYY-MM-DD")}
|
||||
</span>
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
<div className="flex items-start gap-4">
|
||||
<span className="text-[1.4rem] font-bold text-label">
|
||||
A
|
||||
</span>
|
||||
<div className="flex-1">
|
||||
<pre className="whitespace-pre-wrap font-noto text-[1.4rem] tracking-tighter text-foreground">
|
||||
{item.pstCn}
|
||||
</pre>
|
||||
<Attachment atflCd={item.atflCd} />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button
|
||||
size="icon"
|
||||
color="white"
|
||||
onClick={() =>
|
||||
router.push(`${pathname}/${item.pstNo}`)
|
||||
}
|
||||
>
|
||||
<i className="diveicon di-pencil" />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon"
|
||||
color="white"
|
||||
onClick={() => handleDeletePost(item.pstNo)}
|
||||
>
|
||||
<i className="diveicon di-trash" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</div>
|
||||
))}
|
||||
</Accordion>
|
||||
) : (
|
||||
<Skeleton className="h-[36rem] w-full" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Attachment({ atflCd }: { atflCd: string }) {
|
||||
const [filename, setFilename] = useState("");
|
||||
|
||||
const { data: downloadResponse, isFetching } = useQuery({
|
||||
queryKey: [ENDPOINT.ATTACH_SERVICE.DOWNLOAD, atflCd],
|
||||
queryFn: () => AttachmentApi.downloadAttachmentByAtflCd(atflCd),
|
||||
enabled: !!atflCd,
|
||||
});
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!downloadResponse) return;
|
||||
try {
|
||||
const blob = new Blob([downloadResponse.data]);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
|
||||
link.href = url;
|
||||
link.download = filename || "download";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(link);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!downloadResponse) return;
|
||||
try {
|
||||
let filename = "";
|
||||
const contentDisposition =
|
||||
downloadResponse.headers["content-disposition"];
|
||||
if (contentDisposition) {
|
||||
const filenameMatch = contentDisposition.match(
|
||||
/filename\*=UTF-8''([^;]+)/,
|
||||
);
|
||||
if (filenameMatch && filenameMatch[1]) {
|
||||
filename = decodeURIComponent(filenameMatch[1]);
|
||||
}
|
||||
}
|
||||
setFilename(filename);
|
||||
} catch {
|
||||
setFilename("");
|
||||
}
|
||||
}, [downloadResponse]);
|
||||
|
||||
return isFetching ? (
|
||||
<div className="my-8">
|
||||
<Skeleton className="h-[2.5rem] w-[32rem]" />
|
||||
</div>
|
||||
) : (
|
||||
filename && (
|
||||
<div className="my-8 flex items-center gap-4">
|
||||
<span className="font-bold text-label">첨부파일</span>
|
||||
<Button
|
||||
size="sm"
|
||||
color="white"
|
||||
className="flex w-fit items-center gap-2"
|
||||
onClick={handleDownload}
|
||||
>
|
||||
<i className="diveicon di-download" />
|
||||
<span>{filename}</span>
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export { FaqPage };
|
||||
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import {
|
||||
PostApi,
|
||||
postUpdateFormSchema,
|
||||
type PostUpdateFormData,
|
||||
} from "@/entities/post";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
|
||||
const { data: postInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
});
|
||||
|
||||
const { mutateAsync: updatePost } = useMutationWrapper({
|
||||
mutationFn: (data: PostUpdateFormData) =>
|
||||
PostApi.updatePost(parseInt(bbsId), parseInt(pstNo), data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostUpdateFormData>({
|
||||
resolver: zodResolver(postUpdateFormSchema),
|
||||
values: {
|
||||
...postInfo,
|
||||
pstTtl: postInfo?.pstTtl ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">FAQ 게시글 수정</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={updatePost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,4 @@
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
export { ImagePage } from "./ui/image-page";
|
||||
export { ImagePost } from "./ui/image-post";
|
||||
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import { PostApi, postFormSchema, type PostFormData } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function CreatePage({ bbsId }: { bbsId: string }) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createPost } = useMutationWrapper({
|
||||
mutationFn: (data: PostFormData) => PostApi.createPost(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostFormData>({
|
||||
resolver: zodResolver(postFormSchema),
|
||||
values: {
|
||||
bbsId: parseInt(bbsId),
|
||||
pstTtl: "",
|
||||
wrtrNm: userInfo?.userName ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">이미지 게시글 등록</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={createPost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { PostPage as ImagePage } from "@/widgets/post";
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { Post as ImagePost } from "@/widgets/post";
|
||||
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import {
|
||||
PostApi,
|
||||
postUpdateFormSchema,
|
||||
type PostUpdateFormData,
|
||||
} from "@/entities/post";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
|
||||
const { data: postInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
});
|
||||
|
||||
const { mutateAsync: updatePost } = useMutationWrapper({
|
||||
mutationFn: (data: PostUpdateFormData) =>
|
||||
PostApi.updatePost(parseInt(bbsId), parseInt(pstNo), data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostUpdateFormData>({
|
||||
resolver: zodResolver(postUpdateFormSchema),
|
||||
values: {
|
||||
...postInfo,
|
||||
pstTtl: postInfo?.pstTtl ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">이미지 게시글 수정</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={updatePost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,4 @@
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
export { MoviePage } from "./ui/movie-page";
|
||||
export { MoviePost } from "./ui/movie-post";
|
||||
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import { PostApi, postFormSchema, type PostFormData } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function CreatePage({ bbsId }: { bbsId: string }) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createPost } = useMutationWrapper({
|
||||
mutationFn: (data: PostFormData) => PostApi.createPost(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostFormData>({
|
||||
resolver: zodResolver(postFormSchema),
|
||||
values: {
|
||||
bbsId: parseInt(bbsId),
|
||||
pstTtl: "",
|
||||
wrtrNm: userInfo?.userName ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">동영상 게시글 등록</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={createPost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import {
|
||||
PostApi,
|
||||
postUpdateFormSchema,
|
||||
type PostUpdateFormData,
|
||||
} from "@/entities/post";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
|
||||
const { data: postInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
});
|
||||
|
||||
const { mutateAsync: updatePost } = useMutationWrapper({
|
||||
mutationFn: (data: PostUpdateFormData) =>
|
||||
PostApi.updatePost(parseInt(bbsId), parseInt(pstNo), data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostUpdateFormData>({
|
||||
resolver: zodResolver(postUpdateFormSchema),
|
||||
values: {
|
||||
...postInfo,
|
||||
pstTtl: postInfo?.pstTtl ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">동영상 게시글 수정</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={updatePost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { PostPage as MoviePage } from "@/widgets/post";
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { Post as MoviePost } from "@/widgets/post";
|
||||
@@ -0,0 +1,4 @@
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
export { NormalPage } from "./ui/normal-page";
|
||||
export { NormalPost } from "./ui/normal-post";
|
||||
@@ -0,0 +1,50 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import { PostApi, postFormSchema, type PostFormData } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function CreatePage({ bbsId, pstNo }: { bbsId: string; pstNo?: string }) {
|
||||
const answerRegisterMode = !!pstNo;
|
||||
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createPost } = useMutationWrapper({
|
||||
mutationFn: (data: PostFormData) => PostApi.createPost(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostFormData>({
|
||||
resolver: zodResolver(postFormSchema),
|
||||
values: {
|
||||
bbsId: parseInt(bbsId),
|
||||
pstTtl: "",
|
||||
wrtrNm: userInfo?.userName ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
popupYn: "N",
|
||||
upndFixYn: "N",
|
||||
prdPstgYn: "N",
|
||||
parentPstNo: pstNo ? parseInt(pstNo) : null,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{answerRegisterMode ? "답글 등록" : "게시글 등록"}
|
||||
</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={createPost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import {
|
||||
PostApi,
|
||||
postUpdateFormSchema,
|
||||
type PostUpdateFormData,
|
||||
} from "@/entities/post";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
|
||||
const { data: postInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
});
|
||||
|
||||
const { mutateAsync: updatePost } = useMutationWrapper({
|
||||
mutationFn: (data: PostUpdateFormData) =>
|
||||
PostApi.updatePost(parseInt(bbsId), parseInt(pstNo), data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostUpdateFormData>({
|
||||
resolver: zodResolver(postUpdateFormSchema),
|
||||
values: {
|
||||
...postInfo,
|
||||
pstTtl: postInfo?.pstTtl ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">게시글 수정</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={updatePost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { PostPage as NormalPage } from "@/widgets/post";
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { Post as NormalPost } from "@/widgets/post";
|
||||
@@ -0,0 +1,4 @@
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
export { NoticePage } from "./ui/notice-page";
|
||||
export { NoticePost } from "./ui/notice-post";
|
||||
@@ -0,0 +1,90 @@
|
||||
import dayjs from "dayjs";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Badge, Button } from "@common/components";
|
||||
import { AttachmentApi } from "@/entities/attachment";
|
||||
import type { Post } from "@/entities/post";
|
||||
|
||||
export const columns: ColumnDef<Post>[] = [
|
||||
{
|
||||
accessorKey: "rowNo",
|
||||
header: "NO",
|
||||
},
|
||||
{
|
||||
accessorKey: "pstTtl",
|
||||
header: "제목",
|
||||
cell: ({ row }) => {
|
||||
const { pstTtl, inqNocs } = row.original;
|
||||
|
||||
return (
|
||||
<div className="flex min-w-[20vw] items-center gap-2 text-left">
|
||||
{inqNocs >= 100 && <Badge color="red">HOT</Badge>}
|
||||
{dayjs().diff(dayjs(row.original.regDt), "hour") < 24 && (
|
||||
<Badge color="blue">NEW</Badge>
|
||||
)}
|
||||
{pstTtl}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "inqNocs",
|
||||
header: "조회수",
|
||||
},
|
||||
{
|
||||
accessorKey: "atflCd",
|
||||
header: "첨부파일",
|
||||
cell: ({ row }) => {
|
||||
const atflCd = row.original.atflCd;
|
||||
if (!atflCd) return null;
|
||||
return <AttachmentButton atflCd={atflCd} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "rgtrNm",
|
||||
header: "작성자",
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => dayjs(row.original.regDt).format("YYYY-MM-DD"),
|
||||
},
|
||||
];
|
||||
|
||||
const AttachmentButton = ({ atflCd }: { atflCd: string }) => {
|
||||
const handleDownload = async (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.stopPropagation();
|
||||
try {
|
||||
let filename = "";
|
||||
const response = await AttachmentApi.downloadAttachmentByAtflCd(atflCd);
|
||||
const contentDisposition = response.headers["content-disposition"];
|
||||
if (contentDisposition) {
|
||||
const filenameMatch = contentDisposition.match(
|
||||
/filename\*=UTF-8''([^;]+)/,
|
||||
);
|
||||
if (filenameMatch) {
|
||||
filename = decodeURIComponent(filenameMatch[1]);
|
||||
}
|
||||
}
|
||||
|
||||
const blob = new Blob([response.data]);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(link);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button size="icon" color="white" onClick={handleDownload}>
|
||||
<i className="diveicon di-download" />
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import { PostApi, postFormSchema, type PostFormData } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function CreatePage({ bbsId }: { bbsId: string }) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createPost } = useMutationWrapper({
|
||||
mutationFn: (data: PostFormData) => PostApi.createPost(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostFormData>({
|
||||
resolver: zodResolver(postFormSchema),
|
||||
values: {
|
||||
bbsId: parseInt(bbsId),
|
||||
pstTtl: "",
|
||||
wrtrNm: userInfo?.userName ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
popupYn: "N",
|
||||
upndFixYn: "N",
|
||||
prdPstgYn: "N",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">공지 게시글 등록</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={createPost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { PostForm } from "@/widgets/post";
|
||||
import {
|
||||
PostApi,
|
||||
postUpdateFormSchema,
|
||||
type PostUpdateFormData,
|
||||
} from "@/entities/post";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
|
||||
const { data: postInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, bbsId, pstNo],
|
||||
queryFn: () => PostApi.getPostInfo(parseInt(bbsId), parseInt(pstNo)),
|
||||
});
|
||||
|
||||
const { mutateAsync: updatePost } = useMutationWrapper({
|
||||
mutationFn: (data: PostUpdateFormData) =>
|
||||
PostApi.updatePost(parseInt(bbsId), parseInt(pstNo), data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PostUpdateFormData>({
|
||||
resolver: zodResolver(postUpdateFormSchema),
|
||||
values: {
|
||||
...postInfo,
|
||||
pstTtl: postInfo?.pstTtl ?? "",
|
||||
pstPswd: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">공지 게시글 수정</h3>
|
||||
</div>
|
||||
<PostForm form={form} handleSave={updatePost} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { PostPage as NoticePage } from "@/widgets/post";
|
||||
@@ -0,0 +1,3 @@
|
||||
"use client";
|
||||
|
||||
export { Post as NoticePost } from "@/widgets/post";
|
||||
@@ -50,7 +50,7 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) {
|
||||
});
|
||||
|
||||
const handleProgress = (percentage: string) => {
|
||||
setProgress(Number(percentage));
|
||||
setProgress(parseInt(percentage));
|
||||
};
|
||||
|
||||
const handleUploadResponse = async (res: HttpResponse) => {
|
||||
@@ -59,7 +59,7 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) {
|
||||
|
||||
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
|
||||
if (atflCd) form.setValue("atflCd", atflCd);
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId));
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrlByAtflId(atflId));
|
||||
if (attachmentData)
|
||||
await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd);
|
||||
};
|
||||
@@ -68,7 +68,9 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) {
|
||||
if (!attachmentData) return;
|
||||
|
||||
(async () => {
|
||||
setImageUrl(await AttachmentApi.getImageUrl(attachmentData.atflId));
|
||||
setImageUrl(
|
||||
await AttachmentApi.getImageUrlByAtflId(attachmentData.atflId),
|
||||
);
|
||||
})();
|
||||
}, [attachmentData]);
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ function BannerPage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-full overflow-auto !p-0">
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import {
|
||||
bannerFormSchema,
|
||||
type BannerFormData,
|
||||
@@ -14,9 +13,9 @@ import { BannerForm } from "./banner-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createBanner } = useMutation({
|
||||
const { mutateAsync: createBanner } = useMutationWrapper({
|
||||
mutationFn: (data: BannerFormData) => BannerApi.createBanner(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { Button, DataTable } from "@common/components";
|
||||
import { PostingApi, type PostPayload } from "@/entities/posting";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
bannerFormSchema,
|
||||
@@ -27,7 +27,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
const router = useRouter();
|
||||
const { confirm } = useConfirm();
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
|
||||
@@ -39,10 +39,10 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
const { data: postHistory } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POSTINGS, sequential],
|
||||
queryFn: () =>
|
||||
PostingApi.getPostingHistory({ pstgTrgtNo: Number(sequential) }),
|
||||
PostingApi.getPostingHistory({ pstgTrgtNo: parseInt(sequential) }),
|
||||
});
|
||||
|
||||
const { mutateAsync: updateBanner } = useMutation({
|
||||
const { mutateAsync: updateBanner } = useMutationWrapper({
|
||||
mutationFn: (data: BannerFormData) =>
|
||||
BannerApi.updateBanner(sequential, data),
|
||||
onSuccess: () => {
|
||||
@@ -50,14 +50,14 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteBanner } = useMutation({
|
||||
const { mutateAsync: deleteBanner } = useMutationWrapper({
|
||||
mutationFn: () => BannerApi.deleteBanner(sequential),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: savePosting } = useMutation({
|
||||
const { mutateAsync: savePosting } = useMutationWrapper({
|
||||
mutationFn: (data: PostPayload[]) => PostingApi.savePosting(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -102,7 +102,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
</div>
|
||||
<BannerForm
|
||||
form={form}
|
||||
bnrSn={Number(sequential)}
|
||||
bnrSn={parseInt(sequential)}
|
||||
handleSave={updateBanner}
|
||||
handleDelete={deleteBanner}
|
||||
/>
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import dayjs from "dayjs";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import type { ColumnDef, Row } from "@tanstack/react-table";
|
||||
import { useLocalStorage } from "@frontend-opensource/use-react-hooks";
|
||||
import type { Board } from "@/entities/board/model/board-interface";
|
||||
import type { Board } from "@/entities/board";
|
||||
import { Button } from "@common/components";
|
||||
|
||||
export const columns: ColumnDef<Board>[] = [
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row }) => row.index + 1,
|
||||
cell: ({ row, table }) => {
|
||||
const totalRows = table.getRowCount();
|
||||
const currentPage = table.getState().pagination.pageIndex;
|
||||
const pageSize = table.getState().pagination.pageSize;
|
||||
return totalRows - (currentPage * pageSize + row.index);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "bbsNm",
|
||||
@@ -37,22 +42,22 @@ export const columns: ColumnDef<Board>[] = [
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "관리",
|
||||
header: "게시물관리",
|
||||
cell: ({ row }) => <ManageButton row={row} />,
|
||||
},
|
||||
];
|
||||
|
||||
const ManageButton = ({ row }: { row: Row<Board> }) => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { bbsTypeCd, bbsId } = row.original;
|
||||
const [, setBbsInfo] = useLocalStorage("bbs-info", "");
|
||||
|
||||
return (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
router.push(`/pst/${bbsTypeCd.toLowerCase()}/${bbsId}`);
|
||||
setBbsInfo(JSON.stringify(row.original));
|
||||
router.push(`${pathname}/${bbsTypeCd.toLowerCase()}/${bbsId}`);
|
||||
}}
|
||||
>
|
||||
관리
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import {
|
||||
Input,
|
||||
@@ -19,7 +20,12 @@ import {
|
||||
} from "@common/components";
|
||||
import { FormWrapper } from "@/widgets/form-wrapper";
|
||||
import { CodeSelect } from "@/entities/code";
|
||||
import type { Board, BoardFormData } from "@/entities/board";
|
||||
import {
|
||||
BoardTemplateApi,
|
||||
type Board,
|
||||
type BoardFormData,
|
||||
} from "@/entities/board";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { FormControl, FormField, FormItem } from "@/shared/ui/form";
|
||||
|
||||
type BbsFormProps = {
|
||||
@@ -29,6 +35,15 @@ type BbsFormProps = {
|
||||
};
|
||||
|
||||
function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
const bbsTypeCd = form.watch("bbsTypeCd");
|
||||
const disabledForm = !!bbsTypeCd && bbsTypeCd !== "BBSNORMAL";
|
||||
|
||||
const { data: boardTemplate } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.BBS_TEMPLATES, bbsTypeCd],
|
||||
queryFn: () => BoardTemplateApi.getBoardTemplate(bbsTypeCd),
|
||||
enabled: disabledForm,
|
||||
});
|
||||
|
||||
return (
|
||||
<FormWrapper form={form} isModifyMode={!!bbsId} {...props}>
|
||||
<div className="card">
|
||||
@@ -109,7 +124,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.rfrncUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="rfrncUseY" />
|
||||
<Label htmlFor="rfrncUseY">사용</Label>
|
||||
@@ -134,7 +154,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.atflUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="atflUseY" />
|
||||
<Label htmlFor="atflUseY">사용</Label>
|
||||
@@ -163,15 +188,15 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
{...field}
|
||||
type="number"
|
||||
min={0}
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
if (isNaN(Number(value))) return;
|
||||
field.onChange(value === "" ? null : Number(value));
|
||||
}}
|
||||
value={boardTemplate?.atflMaxCnt ?? field.value ?? ""}
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
className="w-[12rem] !text-[1.3rem]"
|
||||
placeholder="최대 개수 입력"
|
||||
disabled={form.watch("atflUseYn") === "N"}
|
||||
disabled={
|
||||
form.getValues("atflUseYn") === "N" || disabledForm
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
@@ -192,15 +217,17 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
{...field}
|
||||
type="number"
|
||||
min={0}
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
if (isNaN(Number(value))) return;
|
||||
field.onChange(value === "" ? null : Number(value));
|
||||
}}
|
||||
value={
|
||||
boardTemplate?.atflMaxFileSz ?? field.value ?? ""
|
||||
}
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
className="w-[12rem] !text-[1.3rem]"
|
||||
placeholder="최대 크기 입력"
|
||||
disabled={form.watch("atflUseYn") === "N"}
|
||||
disabled={
|
||||
form.getValues("atflUseYn") === "N" || disabledForm
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
@@ -217,7 +244,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.ansUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="ansUseY" />
|
||||
<Label htmlFor="ansUseY">사용</Label>
|
||||
@@ -245,7 +277,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
<Select
|
||||
value={field.value ?? ""}
|
||||
onValueChange={field.onChange}
|
||||
disabled={form.watch("ansUseYn") === "N"}
|
||||
disabled={form.getValues("ansUseYn") === "N"}
|
||||
>
|
||||
<SelectTrigger className="w-[12rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
@@ -271,7 +303,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.cmntUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="cmntUseY" />
|
||||
<Label htmlFor="cmntUseY">사용</Label>
|
||||
@@ -296,7 +333,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.dgstfnEvlUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="dgstfnEvlUseY" />
|
||||
<Label htmlFor="dgstfnEvlUseY">사용</Label>
|
||||
@@ -321,7 +363,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.popupUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="popupUseY" />
|
||||
<Label htmlFor="popupUseY">사용</Label>
|
||||
@@ -346,7 +393,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.smsUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="smsUseY" />
|
||||
<Label htmlFor="smsUseY">사용</Label>
|
||||
@@ -371,7 +423,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.upndFixUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="upndFixUseY" />
|
||||
<Label htmlFor="upndFixUseY">사용</Label>
|
||||
@@ -396,7 +453,12 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup {...field} onValueChange={field.onChange}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={boardTemplate?.pstgPrdUseYn ?? field.value}
|
||||
onValueChange={field.onChange}
|
||||
disabled={disabledForm}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="pstgPrdUseY" />
|
||||
<Label htmlFor="pstgPrdUseY">사용</Label>
|
||||
|
||||
@@ -117,7 +117,7 @@ function BbsPage() {
|
||||
<Select
|
||||
value={table.getState().pagination.pageSize.toString()}
|
||||
onValueChange={(value) => {
|
||||
table.setPageSize(Number(value));
|
||||
table.setPageSize(parseInt(value));
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="h-[3.2rem] w-[12rem]">
|
||||
@@ -134,7 +134,7 @@ function BbsPage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-full overflow-auto !p-0">
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import {
|
||||
BoardApi,
|
||||
boardFormSchema,
|
||||
@@ -14,9 +13,9 @@ import { BbsForm } from "./bbs-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createBoard } = useMutation({
|
||||
const { mutateAsync: createBoard } = useMutationWrapper({
|
||||
mutationFn: (data: BoardFormData) => BoardApi.createBoard(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
BoardApi,
|
||||
@@ -13,14 +13,14 @@ import {
|
||||
import { BbsForm } from "./bbs-form";
|
||||
|
||||
function ModifyPage({ bbsId }: { bbsId: string }) {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: boardInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.BBS, bbsId],
|
||||
queryFn: () => BoardApi.getBoardInfo(bbsId),
|
||||
});
|
||||
|
||||
const { mutateAsync: updateBoard } = useMutation({
|
||||
const { mutateAsync: updateBoard } = useMutationWrapper({
|
||||
mutationFn: (data: BoardFormData) => BoardApi.updateBoard(bbsId, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.");
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { CodePage } from "./ui/code-page";
|
||||
@@ -0,0 +1,70 @@
|
||||
import dayjs from "dayjs";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Button } from "@common/components";
|
||||
import type { LwpoCode } from "@/entities/code";
|
||||
import { LwpoCodeManagementDialog } from "../ui/lwpocode-dialog";
|
||||
import { useState } from "react";
|
||||
|
||||
export const columns: ColumnDef<LwpoCode>[] = [
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row, table }) => {
|
||||
const totalRows = table.getRowCount();
|
||||
const { pageIndex, pageSize } = table.getState().pagination;
|
||||
return totalRows - (pageIndex * pageSize + row.index);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "lwpoCd",
|
||||
header: "하위코드",
|
||||
},
|
||||
{
|
||||
accessorKey: "lwpoCdNm",
|
||||
header: "하위코드명",
|
||||
},
|
||||
{
|
||||
accessorKey: "useYn",
|
||||
header: "사용 여부",
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => {
|
||||
const date = dayjs(row.original.regDt);
|
||||
return date.format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "관리",
|
||||
cell: ({ row }) => (
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<LwpoCodeManageButton
|
||||
lwpoCd={row.original.lwpoCd}
|
||||
upCd={row.original.upCd}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const LwpoCodeManageButton = ({
|
||||
lwpoCd,
|
||||
upCd,
|
||||
}: {
|
||||
lwpoCd: string;
|
||||
upCd: string;
|
||||
}) => {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
return (
|
||||
<LwpoCodeManagementDialog
|
||||
lwpoCd={lwpoCd}
|
||||
upCd={upCd}
|
||||
open={dialogOpen}
|
||||
onOpenChange={setDialogOpen}
|
||||
>
|
||||
<Button size="sm">관리</Button>
|
||||
</LwpoCodeManagementDialog>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
import dayjs from "dayjs";
|
||||
import { useState } from "react";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Button } from "@common/components";
|
||||
import type { UpCode } from "@/entities/code";
|
||||
import { UpCodeManagementDialog } from "../ui/upcode-dialog";
|
||||
|
||||
export const columns: ColumnDef<UpCode>[] = [
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row, table }) => {
|
||||
const totalRows = table.getRowCount();
|
||||
const { pageIndex, pageSize } = table.getState().pagination;
|
||||
return totalRows - (pageIndex * pageSize + row.index);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "upCd",
|
||||
header: "상위코드",
|
||||
},
|
||||
{
|
||||
accessorKey: "upCdNm",
|
||||
header: "상위코드명",
|
||||
},
|
||||
{
|
||||
accessorKey: "cdSe",
|
||||
header: "코드구분",
|
||||
},
|
||||
{
|
||||
accessorKey: "useYn",
|
||||
header: "사용여부",
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => {
|
||||
const date = dayjs(row.original.regDt);
|
||||
return date.format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "관리",
|
||||
cell: ({ row }) => (
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<UpCodeManageButton upCd={row.original.upCd} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const UpCodeManageButton = ({ upCd }: { upCd: string }) => {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
return (
|
||||
<UpCodeManagementDialog
|
||||
upCd={upCd}
|
||||
open={dialogOpen}
|
||||
onOpenChange={setDialogOpen}
|
||||
>
|
||||
<Button size="sm">관리</Button>
|
||||
</UpCodeManagementDialog>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { UpCodeSection } from "./upcode-section";
|
||||
import { LwpoCodeSection } from "./lwpocode-section";
|
||||
|
||||
function CodePage() {
|
||||
const [selectedUpCd, setSelectedUpCd] = useState("");
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="flex">
|
||||
<UpCodeSection handleSelectedUpCd={setSelectedUpCd} />
|
||||
<LwpoCodeSection upCd={selectedUpCd} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CodePage };
|
||||
@@ -0,0 +1,321 @@
|
||||
import { memo } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
Input,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Label,
|
||||
DialogTrigger,
|
||||
} from "@common/components";
|
||||
import {
|
||||
UpCodeApi,
|
||||
LwpoCodeApi,
|
||||
LwpoCodeFormSchema,
|
||||
type LwpoCodeFormData,
|
||||
} from "@/entities/code";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { Form, FormField, FormItem, FormControl } from "@/shared/ui/form";
|
||||
|
||||
type ManagementLwpoCodeDialogProps = {
|
||||
lwpoCd?: string;
|
||||
upCd?: string;
|
||||
children?: React.ReactNode;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
};
|
||||
|
||||
const LwpoCodeManagementDialog = memo(
|
||||
({
|
||||
lwpoCd,
|
||||
upCd,
|
||||
children,
|
||||
open,
|
||||
onOpenChange,
|
||||
...props
|
||||
}: ManagementLwpoCodeDialogProps) => {
|
||||
const isRegistration = !lwpoCd;
|
||||
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: detailData } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.LWPO_CODE, upCd, lwpoCd],
|
||||
queryFn: () => LwpoCodeApi.lwpoCodeDetail(upCd!, lwpoCd!),
|
||||
enabled: !!upCd && !isRegistration,
|
||||
});
|
||||
|
||||
const { data: upCodeData } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.UP_CODE, upCd],
|
||||
queryFn: () => UpCodeApi.upCodeDetail(upCd!),
|
||||
enabled: !!upCd,
|
||||
});
|
||||
|
||||
const { mutateAsync: createLwpoCode } = useMutationWrapper({
|
||||
mutationFn: (data: LwpoCodeFormData) => LwpoCodeApi.createLwpoCode(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", () => onOpenChange?.(false));
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: updateLwpoCode } = useMutationWrapper({
|
||||
mutationFn: (data: LwpoCodeFormData) =>
|
||||
LwpoCodeApi.updateLwpoCode(upCd!, lwpoCd!, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", () => onOpenChange?.(false));
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<LwpoCodeFormData>({
|
||||
resolver: zodResolver(LwpoCodeFormSchema),
|
||||
values: {
|
||||
lwpoCd: detailData?.lwpoCd ?? "",
|
||||
upCd: upCd ?? "",
|
||||
lwpoCdNm: detailData?.lwpoCdNm ?? "",
|
||||
lwpoCdExpln: detailData?.lwpoCdExpln ?? "",
|
||||
unit: detailData?.unit ?? "",
|
||||
prntLwpoCd: detailData?.prntLwpoCd ?? "",
|
||||
useYn: detailData?.useYn ?? "Y",
|
||||
sortSeq: detailData?.sortSeq ?? 0,
|
||||
delYn: "N",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit =
|
||||
(callback: (data: LwpoCodeFormData) => void) =>
|
||||
async (data: LwpoCodeFormData) => {
|
||||
const confirmMessage = isRegistration
|
||||
? "등록하시겠습니까?"
|
||||
: "수정하시겠습니까?";
|
||||
|
||||
if (await confirm(confirmMessage)) callback(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange} {...props}>
|
||||
<DialogTrigger asChild>{children}</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
{isRegistration ? "하위코드 등록" : "하위코드 관리"}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(
|
||||
onSubmit(isRegistration ? createLwpoCode : updateLwpoCode),
|
||||
)}
|
||||
className="space-y-4"
|
||||
>
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="20%" />
|
||||
<col width="80%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableHead>하위코드</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="lwpoCd"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="하위코드를 입력해주세요"
|
||||
disabled={!isRegistration}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>하위코드명</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="lwpoCdNm"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="하위코드명을 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>하위코드설명</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="lwpoCdExpln"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="하위코드 설명을 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{upCodeData?.cdSe === "CODECLUNIT" && (
|
||||
<TableRow>
|
||||
<TableHead>단위</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="unit"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="단위를 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{upCodeData?.cdSe === "CODECLTREE" && (
|
||||
<TableRow>
|
||||
<TableHead>상위하위코드</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="prntLwpoCd"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="상위하위코드를 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
<TableRow>
|
||||
<TableHead>정렬순서</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="sortSeq"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="정렬순서를 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>사용여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="useYn"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
name="useYn"
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="useY" />
|
||||
<Label htmlFor="useY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="useN" />
|
||||
<Label htmlFor="useN">사용안함</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
<DialogFooter className="!justify-center">
|
||||
<Button size="lg" type="submit">
|
||||
{isRegistration ? "등록" : "저장"}
|
||||
</Button>
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" color="white">
|
||||
취소
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
},
|
||||
(prevProps, nextProps) => {
|
||||
return (
|
||||
prevProps.lwpoCd === nextProps.lwpoCd &&
|
||||
prevProps.upCd === nextProps.upCd &&
|
||||
prevProps.open === nextProps.open
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
LwpoCodeManagementDialog.displayName = "LwpoCodeManagementDialog";
|
||||
|
||||
export { LwpoCodeManagementDialog };
|
||||
@@ -0,0 +1,98 @@
|
||||
import { useState } from "react";
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type PaginationState,
|
||||
} from "@tanstack/react-table";
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { LwpoCodeApi, type LwpoCodeParams } from "@/entities/code";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { columns } from "../model/lwpocode-table-columns";
|
||||
import { LwpoCodeManagementDialog } from "./lwpocode-dialog";
|
||||
|
||||
type LwpoCodeSectionProps = {
|
||||
upCd?: string;
|
||||
};
|
||||
|
||||
function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [lwpoCodeQuery, setLwpoCodeQuery] = useState<LwpoCodeParams>({
|
||||
lwpoCdNm: "",
|
||||
});
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const { data: lwpoCodeList, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.LWPO_CODE, upCd, pagination],
|
||||
queryFn: () =>
|
||||
LwpoCodeApi.getLwpoCodeList({
|
||||
...lwpoCodeQuery,
|
||||
upCd,
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
}),
|
||||
enabled: !!upCd,
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: lwpoCodeList?.content ?? [],
|
||||
columns,
|
||||
rowCount: lwpoCodeList?.totalElements ?? 0,
|
||||
state: { pagination },
|
||||
manualPagination: true,
|
||||
enableMultiRowSelection: false,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
getRowId: (row) => row.lwpoCd,
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
refetch();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex-1">
|
||||
<div className="card card-border">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<Label htmlFor="" className="mr-2 text-label">
|
||||
하위코드명
|
||||
</Label>
|
||||
<Input
|
||||
className="h-[3.2rem] w-[20rem] rounded-sm !text-[1.3rem]"
|
||||
value={lwpoCodeQuery.lwpoCdNm}
|
||||
onChange={(e) =>
|
||||
setLwpoCodeQuery({
|
||||
...lwpoCodeQuery,
|
||||
lwpoCdNm: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">하위코드 목록</h3>
|
||||
<LwpoCodeManagementDialog
|
||||
open={dialogOpen}
|
||||
onOpenChange={setDialogOpen}
|
||||
>
|
||||
<Button>등록</Button>
|
||||
</LwpoCodeManagementDialog>
|
||||
</div>
|
||||
<div className="card !m-4 h-[calc(100vh-35rem)] overflow-auto !p-0">
|
||||
<DataTable table={table} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { LwpoCodeSection };
|
||||
@@ -0,0 +1,280 @@
|
||||
import { memo } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
Input,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Label,
|
||||
DialogTrigger,
|
||||
} from "@common/components";
|
||||
import {
|
||||
CodeSelect,
|
||||
UpCodeApi,
|
||||
upCodeFormSchema,
|
||||
type UpCodeFormData,
|
||||
} from "@/entities/code";
|
||||
import { SiteSelect } from "@/entities/site";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { Form, FormField, FormItem, FormControl } from "@/shared/ui/form";
|
||||
|
||||
type UpCodeManagementDialogProps = {
|
||||
upCd?: string;
|
||||
children?: React.ReactNode;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
};
|
||||
|
||||
const UpCodeManagementDialog = memo(
|
||||
({
|
||||
upCd,
|
||||
children,
|
||||
open,
|
||||
onOpenChange,
|
||||
...props
|
||||
}: UpCodeManagementDialogProps) => {
|
||||
const isRegistration = !upCd;
|
||||
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: detailData } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.UP_CODE, upCd],
|
||||
queryFn: () => UpCodeApi.upCodeDetail(upCd!),
|
||||
enabled: open && !!upCd,
|
||||
});
|
||||
|
||||
const { mutateAsync: createUpCode } = useMutationWrapper({
|
||||
mutationFn: (data: UpCodeFormData) => UpCodeApi.createUpCode(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", () => onOpenChange?.(false));
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: updateUpCode } = useMutationWrapper({
|
||||
mutationFn: (data: UpCodeFormData) => UpCodeApi.updateUpCode(upCd!, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", () => onOpenChange?.(false));
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<UpCodeFormData>({
|
||||
resolver: zodResolver(upCodeFormSchema),
|
||||
values: {
|
||||
upCd: detailData?.upCd ?? "",
|
||||
upCdNm: detailData?.upCdNm ?? "",
|
||||
cdSe: detailData?.cdSe ?? "",
|
||||
siteId: detailData?.siteId ?? "",
|
||||
upCdExpln: detailData?.upCdExpln ?? "",
|
||||
useYn: detailData?.useYn ?? "Y",
|
||||
delYn: "N",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit =
|
||||
(callback: (data: UpCodeFormData) => void) =>
|
||||
async (data: UpCodeFormData) => {
|
||||
const confirmMessage = isRegistration
|
||||
? "등록하시겠습니까?"
|
||||
: "수정하시겠습니까?";
|
||||
|
||||
if (await confirm(confirmMessage)) callback(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange} {...props}>
|
||||
<DialogTrigger asChild>{children}</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
{isRegistration ? "상위코드 등록" : "상위코드 관리"}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(
|
||||
onSubmit(isRegistration ? createUpCode : updateUpCode),
|
||||
)}
|
||||
className="space-y-4"
|
||||
>
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="15%" />
|
||||
<col width="85%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableHead>상위코드</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="upCd"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="상위코드를를 입력해주세요"
|
||||
disabled={!isRegistration}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>상위코드명</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="upCdNm"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="상위코드명을 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>상위코드설명</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="upCdExpln"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="상위코드설명을 입력해주세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>코드구분</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="cdSe"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex flex-col">
|
||||
<FormControl>
|
||||
<CodeSelect
|
||||
upCd="CODECL"
|
||||
value={field.value || ""}
|
||||
onValueChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>사이트</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="siteId"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex flex-col">
|
||||
<FormControl>
|
||||
<SiteSelect
|
||||
value={field.value || ""}
|
||||
onValueChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>사용여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="useYn"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
name="useYn"
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="useY" />
|
||||
<Label htmlFor="useY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="useN" />
|
||||
<Label htmlFor="useN">사용안함</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
<DialogFooter className="!justify-center">
|
||||
<Button size="lg" type="submit">
|
||||
{isRegistration ? "등록" : "저장"}
|
||||
</Button>
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" color="white">
|
||||
취소
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
},
|
||||
(prevProps, nextProps) => {
|
||||
return (
|
||||
prevProps.upCd === nextProps.upCd && prevProps.open === nextProps.open
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
UpCodeManagementDialog.displayName = "UpCodeManagementDialog";
|
||||
|
||||
export { UpCodeManagementDialog };
|
||||
@@ -0,0 +1,101 @@
|
||||
import { useState } from "react";
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type PaginationState,
|
||||
} from "@tanstack/react-table";
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { UpCodeApi, type UpCode, type UpCodeParams } from "@/entities/code";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { columns } from "../model/upcode-table-columns";
|
||||
import { UpCodeManagementDialog } from "./upcode-dialog";
|
||||
|
||||
type UpCodeSectionProps = {
|
||||
handleSelectedUpCd: (upCd: string) => void;
|
||||
};
|
||||
|
||||
function UpCodeSection({ handleSelectedUpCd }: UpCodeSectionProps) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [upCodeQuery, setUpCodeQuery] = useState<UpCodeParams>({
|
||||
keyword: "",
|
||||
});
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const { data: upCodeList, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.UP_CODE, pagination],
|
||||
queryFn: () =>
|
||||
UpCodeApi.getUpCodeList({
|
||||
...upCodeQuery,
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
}),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: upCodeList?.content ?? [],
|
||||
columns,
|
||||
rowCount: upCodeList?.totalElements ?? 0,
|
||||
state: { pagination },
|
||||
manualPagination: true,
|
||||
enableMultiRowSelection: false,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
getRowId: (row) => row.upCd,
|
||||
});
|
||||
|
||||
const handleRowClick = (row: UpCode) => {
|
||||
table.setRowSelection({ [row.upCd]: true });
|
||||
handleSelectedUpCd(row.upCd);
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
refetch();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex-1">
|
||||
<div className="card card-border">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<Label htmlFor="" className="mr-2 text-label">
|
||||
상위코드명
|
||||
</Label>
|
||||
<Input
|
||||
className="h-[3.2rem] w-[20rem] rounded-sm !text-[1.3rem]"
|
||||
value={upCodeQuery.keyword}
|
||||
onChange={(e) =>
|
||||
setUpCodeQuery({
|
||||
...upCodeQuery,
|
||||
keyword: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">상위코드 목록</h3>
|
||||
<UpCodeManagementDialog
|
||||
open={dialogOpen}
|
||||
onOpenChange={setDialogOpen}
|
||||
>
|
||||
<Button>등록</Button>
|
||||
</UpCodeManagementDialog>
|
||||
</div>
|
||||
<div className="card !m-4 h-[calc(100vh-35rem)] overflow-auto !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { UpCodeSection };
|
||||
@@ -1,4 +1,6 @@
|
||||
import Image from "next/image";
|
||||
import dynamic from "next/dynamic";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { type UseFormReturn } from "react-hook-form";
|
||||
import {
|
||||
Input,
|
||||
@@ -12,12 +14,10 @@ import {
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import { FormWrapper } from "@/widgets/form-wrapper";
|
||||
import { FormItem, FormControl, FormField } from "@/shared/ui/form";
|
||||
import type { ContentsFormData } from "@/entities/content";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CodeApi } from "@/entities/code";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { CodeApi } from "@/entities/code/api/code-service";
|
||||
import Image from "next/image";
|
||||
import { FormItem, FormControl, FormField } from "@/shared/ui/form";
|
||||
|
||||
const Editor = dynamic(
|
||||
() => import("@/entities/editor").then((module) => module.Editor),
|
||||
|
||||
@@ -89,7 +89,7 @@ function ContentsPage() {
|
||||
등록
|
||||
</Button>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] overflow-auto !p-0">
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable
|
||||
table={table}
|
||||
onRowClick={handleRowClick}
|
||||
|
||||
@@ -2,21 +2,20 @@
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import {
|
||||
ContentsApi,
|
||||
contentsFormSchema,
|
||||
type ContentsFormData,
|
||||
} from "@/entities/content";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ContentsForm } from "./contents-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createContents } = useMutation({
|
||||
const { mutateAsync: createContents } = useMutationWrapper({
|
||||
mutationFn: (data: ContentsFormData) => ContentsApi.createContents(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import {
|
||||
CONTENTS_APPROVE_STATUS,
|
||||
ContentsApi,
|
||||
contentsFormSchema,
|
||||
type ContentsFormData,
|
||||
} from "@/entities/content";
|
||||
import { ContentsForm } from "./contents-form";
|
||||
import {
|
||||
Select,
|
||||
SelectTrigger,
|
||||
@@ -22,13 +13,22 @@ import {
|
||||
SelectItem,
|
||||
Button,
|
||||
} from "@common/components";
|
||||
import {
|
||||
CONTENTS_APPROVE_STATUS,
|
||||
ContentsApi,
|
||||
contentsFormSchema,
|
||||
type ContentsFormData,
|
||||
} from "@/entities/content";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ContentsForm } from "./contents-form";
|
||||
|
||||
function ModifyPage({ sequential }: { sequential: string }) {
|
||||
const { confirm } = useConfirm();
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const contsSn = Number(sequential);
|
||||
const contsSn = parseInt(sequential);
|
||||
const [contsVer, setContsVer] = useState(0);
|
||||
|
||||
const { data: contentsVersionList } = useQuery({
|
||||
@@ -47,7 +47,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
enabled: !!contsVer,
|
||||
});
|
||||
|
||||
const { mutateAsync: createContents } = useMutation({
|
||||
const { mutateAsync: createContents } = useMutationWrapper({
|
||||
mutationFn: (data: ContentsFormData) => ContentsApi.createContents(data),
|
||||
onSuccess: () => {
|
||||
setContsVer(0);
|
||||
@@ -58,7 +58,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: updateContents } = useMutation({
|
||||
const { mutateAsync: updateContents } = useMutationWrapper({
|
||||
mutationFn: (data: ContentsFormData) =>
|
||||
ContentsApi.updateContents(contsSn, contsVer, data),
|
||||
onSuccess: () => {
|
||||
@@ -66,7 +66,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteContents } = useMutation({
|
||||
const { mutateAsync: deleteContents } = useMutationWrapper({
|
||||
mutationFn: () => ContentsApi.deleteContents(contsSn, contsVer),
|
||||
onSuccess: () => {
|
||||
setContsVer(0);
|
||||
@@ -77,7 +77,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: requestApprove } = useMutation({
|
||||
const { mutateAsync: requestApprove } = useMutationWrapper({
|
||||
mutationFn: () => ContentsApi.requestApprove(contsSn, contsVer),
|
||||
onSuccess: () => {
|
||||
alert("승인 요청이 완료되었습니다.");
|
||||
@@ -87,7 +87,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: approveContents } = useMutation({
|
||||
const { mutateAsync: approveContents } = useMutationWrapper({
|
||||
mutationFn: () => ContentsApi.approveContents(contsSn, contsVer),
|
||||
onSuccess: () => {
|
||||
alert("승인되었습니다.");
|
||||
@@ -135,7 +135,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
<Select
|
||||
value={contsVer.toString()}
|
||||
onValueChange={(value) => {
|
||||
setContsVer(Number(value));
|
||||
setContsVer(parseInt(value));
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="w-[28rem]">
|
||||
|
||||
@@ -30,7 +30,7 @@ export const createColumns = (
|
||||
header: "파일크기",
|
||||
cell: ({ row }) => {
|
||||
const size = row.getValue("atflFlieSz");
|
||||
return size ? formatFileSize(Number(size)) : "0 Bytes";
|
||||
return size ? formatFileSize(size as number) : "0 Bytes";
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { keepPreviousData, useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
@@ -10,13 +10,13 @@ import {
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { AttachmentApi, type AttachmentParams } from "@/entities/attachment";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { createColumns } from "../model/table-columns";
|
||||
|
||||
function FilePage() {
|
||||
const { confirm } = useConfirm();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [attachmentQuery, setAttachmentQuery] = useState<AttachmentParams>({
|
||||
keyword: "",
|
||||
@@ -38,8 +38,9 @@ function FilePage() {
|
||||
enabled: false,
|
||||
});
|
||||
|
||||
const { mutate: deleteAttachment } = useMutation({
|
||||
mutationFn: (atflId: string) => AttachmentApi.deleteAttachment(atflId),
|
||||
const { mutate: deleteAttachment } = useMutationWrapper({
|
||||
mutationFn: (atflId: string) =>
|
||||
AttachmentApi.deleteAttachmentByAtflId(atflId),
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
alert("삭제되었습니다.");
|
||||
@@ -107,7 +108,7 @@ function FilePage() {
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">파일 목록</h3>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] overflow-auto !p-0">
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { imageFormSchema, type ImageFormData } from "../model/image-interface";
|
||||
import { ImageApi } from "../api/image-service";
|
||||
import { ImageForm } from "./image-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createImage } = useMutation({
|
||||
const { mutateAsync: createImage } = useMutationWrapper({
|
||||
mutationFn: (data: ImageFormData) => ImageApi.createImage(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
|
||||
@@ -44,7 +44,9 @@ function ImageForm({ form, imgSn, ...props }: ImageFormProps) {
|
||||
progress,
|
||||
setFile,
|
||||
} = useTus();
|
||||
const { setAttachmentFileCode } = useAttachmentStore((state) => state);
|
||||
const setAttachmentFileCode = useAttachmentStore(
|
||||
(state) => state.setAttachmentFileCode,
|
||||
);
|
||||
const [imageUrl, setImageUrl] = useState("");
|
||||
|
||||
const { data: attachmentData } = useQuery({
|
||||
@@ -60,7 +62,7 @@ function ImageForm({ form, imgSn, ...props }: ImageFormProps) {
|
||||
|
||||
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
|
||||
if (atflCd) form.setValue("atflCd", atflCd);
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId));
|
||||
if (atflId) setImageUrl(await AttachmentApi.getImageUrlByAtflId(atflId));
|
||||
if (attachmentData)
|
||||
await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd);
|
||||
};
|
||||
@@ -122,11 +124,9 @@ function ImageForm({ form, imgSn, ...props }: ImageFormProps) {
|
||||
type="number"
|
||||
min={0}
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
if (isNaN(Number(value))) return;
|
||||
field.onChange(Number(value));
|
||||
}}
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
className="w-[12rem] !text-[1.3rem]"
|
||||
placeholder="정렬순서 입력"
|
||||
/>
|
||||
|
||||
@@ -121,7 +121,7 @@ function ImagePage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-full overflow-auto !p-0">
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { Button, DataTable } from "@common/components";
|
||||
import { PostingApi, type PostPayload } from "@/entities/posting";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { imageFormSchema, type ImageFormData } from "../model/image-interface";
|
||||
import { columns } from "../model/posting-table-columns";
|
||||
@@ -24,7 +24,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
const router = useRouter();
|
||||
const { confirm } = useConfirm();
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
|
||||
@@ -36,24 +36,24 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
const { data: postHistory } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POSTINGS, sequential],
|
||||
queryFn: () =>
|
||||
PostingApi.getPostingHistory({ pstgTrgtNo: Number(sequential) }),
|
||||
PostingApi.getPostingHistory({ pstgTrgtNo: parseInt(sequential) }),
|
||||
});
|
||||
|
||||
const { mutateAsync: updateImage } = useMutation({
|
||||
const { mutateAsync: updateImage } = useMutationWrapper({
|
||||
mutationFn: (data: ImageFormData) => ImageApi.updateImage(sequential, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.");
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteImage } = useMutation({
|
||||
const { mutateAsync: deleteImage } = useMutationWrapper({
|
||||
mutationFn: () => ImageApi.deleteImage(sequential),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: savePosting } = useMutation({
|
||||
const { mutateAsync: savePosting } = useMutationWrapper({
|
||||
mutationFn: (data: PostPayload[]) => PostingApi.savePosting(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -98,7 +98,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
</div>
|
||||
<ImageForm
|
||||
form={form}
|
||||
imgSn={Number(sequential)}
|
||||
imgSn={parseInt(sequential)}
|
||||
handleSave={updateImage}
|
||||
handleDelete={deleteImage}
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import type { NodeModel, TreeMethods } from "@minoru/react-dnd-treeview";
|
||||
import { Button, cn } from "@common/components";
|
||||
import { useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import type { TreeMenu } from "../model/menu-interface";
|
||||
@@ -33,7 +34,7 @@ function MenuNode({
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { mutateAsync: updateMenuName } = useMutation({
|
||||
const { mutateAsync: updateMenuName } = useMutationWrapper({
|
||||
mutationFn: (nodeName: string) => {
|
||||
const encodedName = encodeURIComponent(nodeName);
|
||||
return MenuApi.updateMenuName(id as number, encodedName);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import type { NodeModel } from "@minoru/react-dnd-treeview";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Button,
|
||||
Select,
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from "@common/components";
|
||||
import { SiteApi } from "@/entities/site";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import type { TreeMenu } from "../model/menu-interface";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import {
|
||||
@@ -30,7 +30,7 @@ import { generateMenuTreeData } from "../lib/utils";
|
||||
|
||||
function MenuPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const [siteId, setSiteId] = useState("");
|
||||
@@ -68,7 +68,7 @@ function MenuPage() {
|
||||
})),
|
||||
});
|
||||
|
||||
const { mutateAsync: createMenu } = useMutation({
|
||||
const { mutateAsync: createMenu } = useMutationWrapper({
|
||||
mutationFn: (data: MenuFormData) => MenuApi.createMenu(data),
|
||||
onSuccess: () => {
|
||||
alert("저장되었습니다.");
|
||||
@@ -78,7 +78,7 @@ function MenuPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: updateMenu } = useMutation({
|
||||
const { mutate: updateMenu } = useMutationWrapper({
|
||||
mutationFn: ({
|
||||
menuCd,
|
||||
data,
|
||||
@@ -94,7 +94,7 @@ function MenuPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: deleteMenu } = useMutation({
|
||||
const { mutate: deleteMenu } = useMutationWrapper({
|
||||
mutationFn: (menuCd: number) => MenuApi.deleteMenu(menuCd),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useRef } from "react";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Tree,
|
||||
type NodeModel,
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "@minoru/react-dnd-treeview";
|
||||
import { Button } from "@common/components";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useMutationWrapper } from "@/shared/lib";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import type { MenuFormData, TreeMenu, TreeNode } from "../model/menu-interface";
|
||||
import { handleDropNode, handleSelectNode } from "../lib/utils";
|
||||
@@ -38,7 +39,7 @@ function MenuTree({
|
||||
const queryClient = useQueryClient();
|
||||
const treeMethods = useRef<TreeMethods>(null);
|
||||
|
||||
const { mutate: updateTreeMenu } = useMutation({
|
||||
const { mutate: updateTreeMenu } = useMutationWrapper({
|
||||
mutationFn: (newTree: TreeNode) =>
|
||||
MenuApi.updateTreeMenu(siteId, [newTree]),
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
AuthorizationsService,
|
||||
AuthorizationsParams,
|
||||
AuthorizationsList,
|
||||
AuthorizationFormData,
|
||||
WithRoleAuthorizations,
|
||||
} from "../model/authorizations-interface";
|
||||
|
||||
export class AuthorizationsApiService implements AuthorizationsService {
|
||||
public async getAuthorizationsList(
|
||||
params: AuthorizationsParams,
|
||||
): Promise<AuthorizationsList> {
|
||||
const response = await client.get<AuthorizationsList>(
|
||||
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}`,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getAuthorizationInfo(
|
||||
authorizationNo: string,
|
||||
): Promise<WithRoleAuthorizations> {
|
||||
const response = await client.get<WithRoleAuthorizations>(
|
||||
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}/${authorizationNo}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async createAuthorization(
|
||||
data: AuthorizationFormData,
|
||||
): Promise<WithRoleAuthorizations> {
|
||||
const response = await client.post<WithRoleAuthorizations>(
|
||||
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async updateAuthorization(
|
||||
authorizationNo: string,
|
||||
data: AuthorizationFormData,
|
||||
): Promise<WithRoleAuthorizations> {
|
||||
const response = await client.put<WithRoleAuthorizations>(
|
||||
`${ENDPOINT.USER_SERVICE.AUTHORIZATIONS}/${authorizationNo}`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const AuthorizationsApi = new AuthorizationsApiService();
|
||||
@@ -1,43 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
RoleAuthorizationsService,
|
||||
RoleAuthorizationsParams,
|
||||
RoleAuthorizationsList,
|
||||
RoleAuthorizationsData,
|
||||
RoleAuthorizations,
|
||||
} from "../model/role-authorizations-interface";
|
||||
|
||||
export class RoleAuthorizationsApiService implements RoleAuthorizationsService {
|
||||
public async getRoleAuthorizationsList(
|
||||
params: RoleAuthorizationsParams,
|
||||
): Promise<RoleAuthorizationsList> {
|
||||
const response = await client.get<RoleAuthorizationsList>(
|
||||
`${ENDPOINT.USER_SERVICE.ROLE_AUTHORIZATIONS}/api`,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async createRoleAuthorizations(
|
||||
data: RoleAuthorizationsData,
|
||||
): Promise<RoleAuthorizations> {
|
||||
const response = await client.post<RoleAuthorizations>(
|
||||
`${ENDPOINT.USER_SERVICE.ROLE_AUTHORIZATIONS}`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async updateRoleAuthorizations(
|
||||
data: RoleAuthorizationsData,
|
||||
): Promise<RoleAuthorizations> {
|
||||
const response = await client.put<RoleAuthorizations>(
|
||||
`${ENDPOINT.USER_SERVICE.ROLE_AUTHORIZATIONS}`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const RoleAuthorizationsApi = new RoleAuthorizationsApiService();
|
||||
@@ -1,62 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export interface AuthorizationsParams extends PageableParams {
|
||||
keywordType?: string;
|
||||
keyword?: string;
|
||||
authorizationName?: string;
|
||||
httpMethodCode?: string;
|
||||
useYn?: string;
|
||||
}
|
||||
|
||||
export interface Authorizations {
|
||||
authorizationNo: number;
|
||||
authorizationName: string;
|
||||
urlPatternValue: string;
|
||||
httpMethodCode: string;
|
||||
sortSeq: number;
|
||||
useYn: string;
|
||||
mdfr: string;
|
||||
mdfcnDt: string;
|
||||
}
|
||||
|
||||
export interface RoleAuthorizations {
|
||||
roleId: string;
|
||||
authorizationNo: number;
|
||||
authorizationName: string;
|
||||
urlPatternValue: string;
|
||||
httpMethodCode: string;
|
||||
sortSeq: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface WithRoleAuthorizations extends Authorizations {
|
||||
roleAuthorizations: RoleAuthorizations[];
|
||||
}
|
||||
|
||||
export const authorizationFormSchema = z.object({
|
||||
authorizationName: z.string(),
|
||||
urlPatternValue: z.string(),
|
||||
httpMethodCode: z.string(),
|
||||
sortSeq: z.number(),
|
||||
useYn: z.string(),
|
||||
});
|
||||
|
||||
export type AuthorizationsList = PageableList<Authorizations>;
|
||||
export type AuthorizationFormData = z.infer<typeof authorizationFormSchema>;
|
||||
|
||||
export interface AuthorizationsService {
|
||||
getAuthorizationsList: (
|
||||
params: AuthorizationsParams,
|
||||
) => Promise<AuthorizationsList>;
|
||||
getAuthorizationInfo: (
|
||||
authorizationNo: string,
|
||||
) => Promise<WithRoleAuthorizations>;
|
||||
createAuthorization: (
|
||||
data: AuthorizationFormData,
|
||||
) => Promise<WithRoleAuthorizations>;
|
||||
updateAuthorization: (
|
||||
authorizationNo: string,
|
||||
data: AuthorizationFormData,
|
||||
) => Promise<WithRoleAuthorizations>;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import dayjs from "dayjs";
|
||||
import { type ColumnDef } from "@tanstack/react-table";
|
||||
import type { Authorizations } from "./authorizations-interface";
|
||||
import type { Authorizations } from "@/entities/authorization";
|
||||
import { ManagementAuthorityDialog } from "../ui/management-authority-dialog";
|
||||
|
||||
export const columns: ColumnDef<Authorizations>[] = [
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export interface RoleAuthorizationsParams extends PageableParams {
|
||||
keywordType?: string;
|
||||
keyword?: string;
|
||||
authorizationNo?: string;
|
||||
}
|
||||
|
||||
export interface RoleAuthorizations {
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
roleContent: string;
|
||||
useYn: string;
|
||||
authorizationNo: number;
|
||||
authYn: string;
|
||||
}
|
||||
|
||||
export const roleAuthorizationsSchema = z.object({
|
||||
roleId: z.string(),
|
||||
authorizationNo: z.number(),
|
||||
authYn: z.string(),
|
||||
});
|
||||
|
||||
export const roleAuthorizationsFormSchema = z.object({
|
||||
roleAuthorizations: z.array(roleAuthorizationsSchema),
|
||||
});
|
||||
|
||||
export type RoleAuthorizationsList = PageableList<RoleAuthorizations>;
|
||||
export type RoleAuthorizationsData = z.infer<typeof roleAuthorizationsSchema>[];
|
||||
export type RoleAuthorizationsFormData = z.infer<
|
||||
typeof roleAuthorizationsFormSchema
|
||||
>;
|
||||
|
||||
export interface RoleAuthorizationsService {
|
||||
getRoleAuthorizationsList: (
|
||||
params: RoleAuthorizationsParams,
|
||||
) => Promise<RoleAuthorizationsList>;
|
||||
createRoleAuthorizations: (
|
||||
data: RoleAuthorizationsData,
|
||||
) => Promise<RoleAuthorizations>;
|
||||
updateRoleAuthorizations: (
|
||||
data: RoleAuthorizationsData,
|
||||
) => Promise<RoleAuthorizations>;
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import { Checkbox } from "@common/components";
|
||||
import type { RoleAuthorizations } from "./role-authorizations-interface";
|
||||
import type { RoleAuthorizationsFormData } from "./role-authorizations-interface";
|
||||
import type {
|
||||
RoleAuthorizations,
|
||||
RoleAuthorizationsFormData,
|
||||
} from "@/entities/role-authorization";
|
||||
|
||||
export const createColumns = (
|
||||
form: UseFormReturn<RoleAuthorizationsFormData>,
|
||||
|
||||
@@ -3,20 +3,19 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import {
|
||||
AuthorizationsApi,
|
||||
authorizationFormSchema,
|
||||
type AuthorizationFormData,
|
||||
} from "../model/authorizations-interface";
|
||||
import { AuthorizationsApi } from "../api/authorization-service";
|
||||
} from "@/entities/authorization";
|
||||
import { ModuleForm } from "./module-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createAuthorization } = useMutation({
|
||||
const { mutateAsync: createAuthorization } = useMutationWrapper({
|
||||
mutationFn: (data: AuthorizationFormData) =>
|
||||
AuthorizationsApi.createAuthorization(data),
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useState, memo } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
@@ -25,124 +25,133 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import {
|
||||
RoleAuthorizationsApi,
|
||||
roleAuthorizationsFormSchema,
|
||||
type RoleAuthorizationsFormData,
|
||||
type RoleAuthorizationsData,
|
||||
} from "../model/role-authorizations-interface";
|
||||
} from "@/entities/role-authorization";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { createColumns } from "../model/role-authorizations-table-columns";
|
||||
import type { Authorizations } from "../model/authorizations-interface";
|
||||
import { RoleAuthorizationsApi } from "../api/role-authorization-service";
|
||||
import type { Authorizations } from "@/entities/authorization";
|
||||
|
||||
type ManagementAuthorityDialogProps = {
|
||||
authorizationNo?: string;
|
||||
rowData?: Authorizations;
|
||||
} & React.ComponentProps<typeof Dialog>;
|
||||
|
||||
function ManagementAuthorityDialog({
|
||||
authorizationNo,
|
||||
rowData,
|
||||
...props
|
||||
}: ManagementAuthorityDialogProps) {
|
||||
const { confirm } = useConfirm();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const ManagementAuthorityDialog = memo(
|
||||
({ authorizationNo, rowData, ...props }: ManagementAuthorityDialogProps) => {
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [isOpened, setIsOpened] = useState(false);
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
const [isOpened, setIsOpened] = useState(false);
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
|
||||
const { data: roleAuthorizationList } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.ROLE_AUTHORIZATIONS, authorizationNo],
|
||||
queryFn: () =>
|
||||
RoleAuthorizationsApi.getRoleAuthorizationsList({ authorizationNo }),
|
||||
enabled: !!authorizationNo && isOpened,
|
||||
});
|
||||
const { data: roleAuthorizationList } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.ROLE_AUTHORIZATIONS, authorizationNo],
|
||||
queryFn: () =>
|
||||
RoleAuthorizationsApi.getRoleAuthorizationsList({ authorizationNo }),
|
||||
enabled: !!authorizationNo && isOpened,
|
||||
});
|
||||
|
||||
const { mutateAsync: saveRoleAuthorization } = useMutation({
|
||||
mutationFn: (data: RoleAuthorizationsData) =>
|
||||
RoleAuthorizationsApi.createRoleAuthorizations(data),
|
||||
onSuccess: () => {
|
||||
alert("저장되었습니다.");
|
||||
},
|
||||
});
|
||||
const { mutateAsync: saveRoleAuthorization } = useMutationWrapper({
|
||||
mutationFn: (data: RoleAuthorizationsData) =>
|
||||
RoleAuthorizationsApi.createRoleAuthorizations(data),
|
||||
onSuccess: () => {
|
||||
alert("저장되었습니다.");
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<RoleAuthorizationsFormData>({
|
||||
resolver: zodResolver(roleAuthorizationsFormSchema),
|
||||
values: {
|
||||
roleAuthorizations:
|
||||
roleAuthorizationList?.content.map(
|
||||
({ roleId, authorizationNo, useYn }) => ({
|
||||
roleId,
|
||||
authorizationNo,
|
||||
authYn: useYn,
|
||||
}),
|
||||
) ?? [],
|
||||
},
|
||||
});
|
||||
const form = useForm<RoleAuthorizationsFormData>({
|
||||
resolver: zodResolver(roleAuthorizationsFormSchema),
|
||||
values: {
|
||||
roleAuthorizations:
|
||||
roleAuthorizationList?.content.map(
|
||||
({ roleId, authorizationNo, useYn }) => ({
|
||||
roleId,
|
||||
authorizationNo,
|
||||
authYn: useYn,
|
||||
}),
|
||||
) ?? [],
|
||||
},
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: roleAuthorizationList?.content ?? [],
|
||||
columns: createColumns(form),
|
||||
state: {
|
||||
rowSelection,
|
||||
},
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
const table = useReactTable({
|
||||
data: roleAuthorizationList?.content ?? [],
|
||||
columns: createColumns(form),
|
||||
state: {
|
||||
rowSelection,
|
||||
},
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
|
||||
const handleSave = async () => {
|
||||
if (await confirm("저장하시겠습니까?")) {
|
||||
const data = form.getValues("roleAuthorizations");
|
||||
await saveRoleAuthorization(data);
|
||||
}
|
||||
};
|
||||
const handleSave = async () => {
|
||||
if (await confirm("저장하시겠습니까?")) {
|
||||
const data = form.getValues("roleAuthorizations");
|
||||
await saveRoleAuthorization(data);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm" onClick={() => setIsOpened(true)}>
|
||||
관리
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>모듈API 권한관리</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-8">
|
||||
<Table variant="line">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>API명</TableHead>
|
||||
<TableHead>요청 메소드</TableHead>
|
||||
<TableHead>API URL</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell align="center">
|
||||
{rowData?.authorizationName}
|
||||
</TableCell>
|
||||
<TableCell align="center">{rowData?.httpMethodCode}</TableCell>
|
||||
<TableCell align="center">{rowData?.urlPatternValue}</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
<DataTable table={table} />
|
||||
</div>
|
||||
<DialogFooter className="!justify-center">
|
||||
<Button size="lg" onClick={handleSave}>
|
||||
저장
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm" onClick={() => setIsOpened(true)}>
|
||||
관리
|
||||
</Button>
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" color="white">
|
||||
취소
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>모듈API 권한관리</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-8">
|
||||
<Table variant="line">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>API명</TableHead>
|
||||
<TableHead>요청 메소드</TableHead>
|
||||
<TableHead>API URL</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell align="center">
|
||||
{rowData?.authorizationName}
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{rowData?.httpMethodCode}
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{rowData?.urlPatternValue}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="max-h-[40rem] overflow-auto">
|
||||
<DataTable table={table} />
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter className="!justify-center">
|
||||
<Button size="lg" onClick={handleSave}>
|
||||
저장
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" color="white">
|
||||
취소
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
},
|
||||
(prevProps, nextProps) => {
|
||||
return prevProps.authorizationNo === nextProps.authorizationNo;
|
||||
},
|
||||
);
|
||||
|
||||
ManagementAuthorityDialog.displayName = "ManagementAuthorityDialog";
|
||||
|
||||
export { ManagementAuthorityDialog };
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
AuthorizationsApi,
|
||||
authorizationFormSchema,
|
||||
type AuthorizationFormData,
|
||||
} from "../model/authorizations-interface";
|
||||
import { AuthorizationsApi } from "../api/authorization-service";
|
||||
} from "@/entities/authorization";
|
||||
import { ModuleForm } from "./module-form";
|
||||
|
||||
function ModifyPage({ sequential }: { sequential: string }) {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: authorizationInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.AUTHORIZATIONS, sequential],
|
||||
queryFn: () => AuthorizationsApi.getAuthorizationInfo(sequential),
|
||||
});
|
||||
|
||||
const { mutateAsync: updateAuthorization } = useMutation({
|
||||
const { mutateAsync: updateAuthorization } = useMutationWrapper({
|
||||
mutationFn: (data: AuthorizationFormData) =>
|
||||
AuthorizationsApi.updateAuthorization(sequential, data),
|
||||
onSuccess: () => {
|
||||
@@ -40,7 +40,7 @@ function ModifyPage({ sequential }: { sequential: string }) {
|
||||
</div>
|
||||
<ModuleForm
|
||||
form={form}
|
||||
authorizationNo={Number(sequential)}
|
||||
authorizationNo={parseInt(sequential)}
|
||||
handleSave={updateAuthorization}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ import { FormControl, FormField, FormItem } from "@/shared/ui/form";
|
||||
import type {
|
||||
AuthorizationFormData,
|
||||
WithRoleAuthorizations,
|
||||
} from "../model/authorizations-interface";
|
||||
} from "@/entities/authorization";
|
||||
|
||||
type BannerFormProps = {
|
||||
form: UseFormReturn<AuthorizationFormData>;
|
||||
@@ -113,11 +113,9 @@ function ModuleForm({ form, authorizationNo, ...props }: BannerFormProps) {
|
||||
type="number"
|
||||
min={0}
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
if (isNaN(Number(value))) return;
|
||||
field.onChange(Number(value));
|
||||
}}
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
className="w-[12rem] !text-[1.3rem]"
|
||||
placeholder="정렬순서 입력"
|
||||
/>
|
||||
|
||||
@@ -11,12 +11,12 @@ import {
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { CodeSelect } from "@/entities/code";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
Authorizations,
|
||||
AuthorizationsParams,
|
||||
} from "../model/authorizations-interface";
|
||||
import {
|
||||
AuthorizationsApi,
|
||||
type Authorizations,
|
||||
type AuthorizationsParams,
|
||||
} from "@/entities/authorization";
|
||||
import { columns } from "../model/authorizations-table-columns";
|
||||
import { AuthorizationsApi } from "../api/authorization-service";
|
||||
|
||||
function ModulePage() {
|
||||
const router = useRouter();
|
||||
@@ -113,7 +113,7 @@ function ModulePage() {
|
||||
<h3 className="text-2xl font-medium text-label">모듈API 목록</h3>
|
||||
<Button onClick={() => router.push("/module/register")}>등록</Button>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-[59rem] overflow-auto !p-0">
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -119,7 +119,7 @@ function OrganizationForm({
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
onChange={(e) =>
|
||||
field.onChange(Number(e.target.value))
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="정렬순서를 입력해주세요"
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import type { NodeModel } from "@minoru/react-dnd-treeview";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Button } from "@common/components";
|
||||
import { DndTree, EditableNode } from "@/widgets/dnd-tree";
|
||||
import {
|
||||
@@ -18,13 +18,13 @@ import {
|
||||
type OrganizationTreeForDnd,
|
||||
} from "@/entities/organization";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { OrganizationForm } from "./organization-form";
|
||||
import { UserOrganizationSection } from "./user-organization-section";
|
||||
|
||||
function OrganizationPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const [additionalNode, setAdditionalNode] =
|
||||
@@ -48,7 +48,7 @@ function OrganizationPage() {
|
||||
enabled: !!selectedOrganization?.ognzSn,
|
||||
});
|
||||
|
||||
const { mutateAsync: createOrganization } = useMutation({
|
||||
const { mutateAsync: createOrganization } = useMutationWrapper({
|
||||
mutationFn: (form: OrganizationFormData) =>
|
||||
OrganizationApi.createOrganization(form),
|
||||
onSuccess: () => {
|
||||
@@ -59,7 +59,7 @@ function OrganizationPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteOrganization } = useMutation({
|
||||
const { mutateAsync: deleteOrganization } = useMutationWrapper({
|
||||
mutationFn: (ognzSn: number) => OrganizationApi.deleteOrganization(ognzSn),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.");
|
||||
@@ -70,7 +70,7 @@ function OrganizationPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: updateOrganizationName } = useMutation({
|
||||
const { mutateAsync: updateOrganizationName } = useMutationWrapper({
|
||||
mutationFn: ({ ognzSn, name }: { ognzSn: number; name: string }) =>
|
||||
OrganizationApi.updateOrganizationName(ognzSn, name),
|
||||
onSuccess: () => {
|
||||
@@ -81,7 +81,7 @@ function OrganizationPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: updateOrganization } = useMutation({
|
||||
const { mutateAsync: updateOrganization } = useMutationWrapper({
|
||||
mutationFn: ({
|
||||
ognzSn,
|
||||
data,
|
||||
@@ -97,7 +97,7 @@ function OrganizationPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: updateOrganizationByDnd } = useMutation({
|
||||
const { mutateAsync: updateOrganizationByDnd } = useMutationWrapper({
|
||||
mutationFn: (data: OrganizationTreeForDnd) =>
|
||||
OrganizationApi.updateOrganizationByDnd([data]),
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import {
|
||||
useQuery,
|
||||
useMutation,
|
||||
useQueryClient,
|
||||
keepPreviousData,
|
||||
} from "@tanstack/react-query";
|
||||
@@ -37,7 +36,7 @@ import {
|
||||
import { CodeApi, type ICode } from "@/entities/code";
|
||||
import type { OrganizationTree } from "@/entities/organization";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { AdditionalUserDialog } from "./additional-user-dialog";
|
||||
import { MoveOrganizationDialog } from "./move-organization-dialog";
|
||||
|
||||
@@ -48,7 +47,7 @@ type UserOrganizationSectionProps = {
|
||||
function UserOrganizationSection({ ognzSn }: UserOrganizationSectionProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const { confirm } = useConfirm();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [userList, setUserList] = useState<User[]>([]);
|
||||
const [selectedUsers, setSelectedUsers] = useState<User[]>([]);
|
||||
@@ -73,7 +72,7 @@ function UserOrganizationSection({ ognzSn }: UserOrganizationSectionProps) {
|
||||
queryFn: () => CodeApi.getCode("JDGDCLCD"),
|
||||
});
|
||||
|
||||
const { mutate: saveUserOrganization } = useMutation({
|
||||
const { mutate: saveUserOrganization } = useMutationWrapper({
|
||||
mutationFn: (data: UserOrganizationPayload[]) =>
|
||||
UserOrganizationApi.saveUserOrganization(data),
|
||||
onSuccess: () => {
|
||||
@@ -84,7 +83,7 @@ function UserOrganizationSection({ ognzSn }: UserOrganizationSectionProps) {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: moveUserOrganization } = useMutation({
|
||||
const { mutate: moveUserOrganization } = useMutationWrapper({
|
||||
mutationFn: (data: MoveUserOrganizationPayload[]) =>
|
||||
UserOrganizationApi.moveUserOrganization(data),
|
||||
onSuccess: () => {
|
||||
@@ -335,7 +334,7 @@ const UserCells = memo(
|
||||
min={0}
|
||||
defaultValue={user.sortSeq}
|
||||
onChange={(e) =>
|
||||
updateFormValue(index, "sortSeq")(Number(e.target.value))
|
||||
updateFormValue(index, "sortSeq")(parseInt(e.target.value))
|
||||
}
|
||||
className="w-[6rem] !text-[1.3rem]"
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
popupFormSchema,
|
||||
popupUpdateFormSchema,
|
||||
type PopupFormData,
|
||||
type PopupInfo,
|
||||
type PopupList,
|
||||
type PopupParams,
|
||||
type PopupService,
|
||||
type PopupUpdateFormData,
|
||||
} from "../model/popup-interface";
|
||||
import { client } from "@/shared/api";
|
||||
|
||||
export class PopupApiService implements PopupService {
|
||||
public async getPopupList(params: PopupParams): Promise<PopupList> {
|
||||
const response = await client.get<PopupList>(ENDPOINT.CMS_SERVICE.POPUPS, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getPopupInfo(popupSn: number): Promise<PopupInfo> {
|
||||
const response = await client.get<PopupInfo>(
|
||||
`${ENDPOINT.CMS_SERVICE.POPUPS}/${popupSn}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async createPopup(data: PopupFormData): Promise<void> {
|
||||
const validatedData = popupFormSchema.parse(data);
|
||||
await client.post(ENDPOINT.CMS_SERVICE.POPUPS, validatedData);
|
||||
}
|
||||
|
||||
public async updatePopup(
|
||||
popupSn: number,
|
||||
data: PopupUpdateFormData,
|
||||
): Promise<void> {
|
||||
const validatedData = popupUpdateFormSchema.parse(data);
|
||||
await client.put(
|
||||
`${ENDPOINT.CMS_SERVICE.POPUPS}/${popupSn}`,
|
||||
validatedData,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const PopupApi = new PopupApiService();
|
||||
@@ -0,0 +1,4 @@
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
export { PopupPage } from "./ui/popup-page";
|
||||
export { ViewPopup } from "./ui/view-popup";
|
||||
@@ -0,0 +1,71 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export interface PopupParams extends PageableParams {
|
||||
keyword?: string;
|
||||
popupTypeCd?: string;
|
||||
contsTypeCd?: string;
|
||||
useYn?: string;
|
||||
}
|
||||
|
||||
export interface Popup {
|
||||
popupSn: number;
|
||||
popupTypeCd: string;
|
||||
popupTypeNm: string;
|
||||
contsTypeCd: string;
|
||||
contsTypeNm: string;
|
||||
popupTtl: string;
|
||||
popupWdth: number;
|
||||
popupHgt: number;
|
||||
popupEndUseYn: string;
|
||||
useYn: string;
|
||||
mdfcnDt: string;
|
||||
mdfr: string;
|
||||
mdfrNm: string;
|
||||
}
|
||||
|
||||
export interface PopupInfo extends Popup {
|
||||
popupCn: string;
|
||||
popupVtclPstn: number;
|
||||
popupHrzntltyPstn: number;
|
||||
popupLnkgUrl: string;
|
||||
atflCd: string;
|
||||
regDt: string;
|
||||
rgTrNm: string;
|
||||
}
|
||||
|
||||
export const popupFormSchema = z.object({
|
||||
popupTypeCd: z.string(),
|
||||
contsTypeCd: z.string(),
|
||||
popupTtl: z.string(),
|
||||
popupCn: z.string().nullish(),
|
||||
popupWdth: z.number(),
|
||||
popupHgt: z.number(),
|
||||
popupVtclPstn: z.number(),
|
||||
popupHrzntltyPstn: z.number(),
|
||||
popupEndUseYn: z.string(),
|
||||
popupLnkgUrl: z.string().nullish(),
|
||||
atflCd: z.string().nullish(),
|
||||
useYn: z.string(),
|
||||
rgtr: z.string(),
|
||||
});
|
||||
|
||||
export const popupUpdateFormSchema = popupFormSchema
|
||||
.omit({
|
||||
rgtr: true,
|
||||
})
|
||||
.extend({
|
||||
mdfr: z.string(),
|
||||
})
|
||||
.partial();
|
||||
|
||||
export type PopupList = PageableList<Popup>;
|
||||
export type PopupFormData = z.infer<typeof popupFormSchema>;
|
||||
export type PopupUpdateFormData = z.infer<typeof popupUpdateFormSchema>;
|
||||
|
||||
export interface PopupService {
|
||||
getPopupList(params: PopupParams): Promise<PopupList>;
|
||||
getPopupInfo(popupSn: number): Promise<PopupInfo>;
|
||||
createPopup(data: PopupFormData): Promise<void>;
|
||||
updatePopup(popupSn: number, data: PopupUpdateFormData): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import dayjs from "dayjs";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Checkbox } from "@common/components";
|
||||
import type { Post } from "@/entities/posting";
|
||||
|
||||
export const columns: ColumnDef<Post>[] = [
|
||||
{
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={table.getIsAllPageRowsSelected()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) =>
|
||||
table.toggleAllPageRowsSelected(!!checked)
|
||||
}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) => row.toggleSelected(!!checked)}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "siteNm",
|
||||
header: "사이트",
|
||||
},
|
||||
{
|
||||
accessorKey: "pstgPrdSeNm",
|
||||
header: "게시기간",
|
||||
cell: ({ row }) => {
|
||||
const pstgPrdSeNm = row.original.pstgPrdSeNm;
|
||||
const pstgBgngDt = row.original.pstgBgngDt;
|
||||
const pstgEndDt = row.original.pstgEndDt;
|
||||
return `${pstgPrdSeNm} (${dayjs(pstgBgngDt).format("YYYY-MM-DD")} ~ ${dayjs(pstgEndDt).format("YYYY-MM-DD")})`;
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,100 @@
|
||||
import dayjs from "dayjs";
|
||||
import { type ColumnDef } from "@tanstack/react-table";
|
||||
import { Button, Checkbox } from "@common/components";
|
||||
import { PopupApi } from "../api/popup-service";
|
||||
import type { Popup } from "./popup-interface";
|
||||
|
||||
export const columns: ColumnDef<Popup>[] = [
|
||||
{
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={table.getIsAllPageRowsSelected()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) =>
|
||||
table.toggleAllPageRowsSelected(!!checked)
|
||||
}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) => row.toggleSelected(!!checked)}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row, table }) => {
|
||||
const { pageIndex, pageSize } = table.getState().pagination;
|
||||
const totalRows = table.getRowCount();
|
||||
return totalRows - (pageIndex * pageSize + row.index);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "popupTtl",
|
||||
header: "제목",
|
||||
},
|
||||
{
|
||||
accessorKey: "popupTypeNm",
|
||||
header: "팝업유형",
|
||||
},
|
||||
{
|
||||
accessorKey: "contsTypeNm",
|
||||
header: "콘텐츠유형",
|
||||
},
|
||||
{
|
||||
accessorKey: "useYn",
|
||||
header: "사용여부",
|
||||
},
|
||||
{
|
||||
accessorKey: "mdfcnDt",
|
||||
header: "최종수정일",
|
||||
cell: ({ row }) => {
|
||||
const date = dayjs(row.original.mdfcnDt);
|
||||
return date.format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "mdfrNm",
|
||||
header: "최종수정자",
|
||||
},
|
||||
{
|
||||
id: "preview",
|
||||
header: "미리보기",
|
||||
cell: ({ row }) => <PreviewButton popupSn={row.original.popupSn} />,
|
||||
},
|
||||
];
|
||||
|
||||
const PreviewButton = ({ popupSn }: { popupSn: number }) => {
|
||||
const handlePreview = async (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
try {
|
||||
const response = await PopupApi.getPopupInfo(popupSn);
|
||||
if (!response) return;
|
||||
|
||||
const width = response.popupWdth;
|
||||
const height = response.popupHgt;
|
||||
const left = response.popupHrzntltyPstn + window.screenX;
|
||||
const top = response.popupVtclPstn + window.screenY;
|
||||
window.open(
|
||||
`/view/popup/${popupSn}`,
|
||||
"",
|
||||
`width=${width},height=${height},left=${left},top=${top}`,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button size="sm" onClick={handlePreview}>
|
||||
미리보기
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useUserStore, useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { popupFormSchema, type PopupFormData } from "../model/popup-interface";
|
||||
import { PopupApi } from "../api/popup-service";
|
||||
import { PopupForm } from "./popup-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createPopup } = useMutationWrapper({
|
||||
mutationFn: (data: PopupFormData) => PopupApi.createPopup(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PopupFormData>({
|
||||
resolver: zodResolver(popupFormSchema),
|
||||
defaultValues: {
|
||||
contsTypeCd: "39",
|
||||
popupEndUseYn: "Y",
|
||||
useYn: "Y",
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!userInfo || !form) return;
|
||||
form.setValue("rgtr", userInfo.userUnqId);
|
||||
}, [userInfo, form]);
|
||||
|
||||
return (
|
||||
<div className="card card-border !mb-0 !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">팝업 등록</h3>
|
||||
</div>
|
||||
<PopupForm form={form} handleSave={createPopup} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,127 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type RowSelectionState,
|
||||
} from "@tanstack/react-table";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { DataTable } from "@common/components";
|
||||
import { AuthorityButton } from "@/entities/menu-authority";
|
||||
import { PostingApi, type PostPayload } from "@/entities/posting";
|
||||
import { useAlertStore, useUserStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
popupUpdateFormSchema,
|
||||
type PopupUpdateFormData,
|
||||
} from "../model/popup-interface";
|
||||
import { columns } from "../model/posting-table-columns";
|
||||
import { PopupApi } from "../api/popup-service";
|
||||
import { PopupForm } from "./popup-form";
|
||||
|
||||
function ModifyPage({ popupSn }: { popupSn: number }) {
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
const { confirm } = useConfirm();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
|
||||
const { data: popupInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POPUPS, popupSn],
|
||||
queryFn: () => PopupApi.getPopupInfo(popupSn),
|
||||
enabled: !!popupSn,
|
||||
});
|
||||
|
||||
const { data: postHistory } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POSTINGS, popupSn],
|
||||
queryFn: () => PostingApi.getPostingHistory({ pstgTrgtNo: popupSn }),
|
||||
});
|
||||
|
||||
const { mutateAsync: updatePopup } = useMutationWrapper({
|
||||
mutationFn: (data: PopupUpdateFormData) =>
|
||||
PopupApi.updatePopup(popupSn, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: savePostingHistory } = useMutationWrapper({
|
||||
mutationFn: (data: PostPayload[]) => PostingApi.savePosting(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POSTINGS, popupSn],
|
||||
});
|
||||
alert("삭제되었습니다.");
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<PopupUpdateFormData>({
|
||||
resolver: zodResolver(popupUpdateFormSchema),
|
||||
values: {
|
||||
...popupInfo,
|
||||
mdfr: userInfo?.userUnqId ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: postHistory?.content ?? [],
|
||||
columns,
|
||||
state: {
|
||||
rowSelection,
|
||||
},
|
||||
enableMultiRowSelection: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
|
||||
const handleDeletePostingHistory = async () => {
|
||||
const data = table.getFilteredSelectedRowModel().rows.map((row) => ({
|
||||
...row.original,
|
||||
mode: "D",
|
||||
}));
|
||||
|
||||
if (await confirm("삭제하시겠습니까?")) {
|
||||
savePostingHistory(data);
|
||||
setRowSelection({});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mt-6 flex flex-col">
|
||||
<div className="card card-border !mb-0 !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">팝업 수정</h3>
|
||||
</div>
|
||||
<PopupForm form={form} handleSave={updatePopup} />
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">사이트 게시 이력</h3>
|
||||
</div>
|
||||
<div className="card">
|
||||
<div className="mb-4 flex justify-end">
|
||||
<AuthorityButton
|
||||
authority="mngAuthrtYn"
|
||||
size="sm"
|
||||
color="red"
|
||||
disabled={!table.getFilteredSelectedRowModel().rows.length}
|
||||
onClick={handleDeletePostingHistory}
|
||||
>
|
||||
이력삭제
|
||||
</AuthorityButton>
|
||||
</div>
|
||||
<DataTable table={table} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,366 @@
|
||||
import dynamic from "next/dynamic";
|
||||
import { useEffect, useState } from "react";
|
||||
import type { Path, UseFormReturn } from "react-hook-form";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
Input,
|
||||
Label,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import { FormWrapper } from "@/widgets/form-wrapper";
|
||||
import { AttachmentApi } from "@/entities/attachment";
|
||||
import { GeneralFileUploader } from "@/widgets/post";
|
||||
import { CodeSelect } from "@/entities/code";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { setCookie } from "@/shared/lib";
|
||||
import { FormItem, FormControl, FormField } from "@/shared/ui/form";
|
||||
import type {
|
||||
PopupFormData,
|
||||
PopupUpdateFormData,
|
||||
} from "../model/popup-interface";
|
||||
|
||||
const Editor = dynamic(
|
||||
() => import("@/entities/editor").then((module) => module.Editor),
|
||||
{ ssr: false },
|
||||
);
|
||||
|
||||
type PopupFormProps<T extends PopupFormData | PopupUpdateFormData> = {
|
||||
form: UseFormReturn<T>;
|
||||
popupSn?: string;
|
||||
handleSave: (data: T) => Promise<void>;
|
||||
handleDelete?: () => Promise<void>;
|
||||
};
|
||||
|
||||
function PopupForm<T extends PopupFormData | PopupUpdateFormData>({
|
||||
form,
|
||||
popupSn,
|
||||
handleSave,
|
||||
...props
|
||||
}: PopupFormProps<T>) {
|
||||
const atflCd = form.getValues("atflCd" as Path<T>);
|
||||
const [deleteAttachmentIds, setDeleteAttachmentIds] = useState<string[]>([]);
|
||||
|
||||
const { data: attachmentData } = useQuery({
|
||||
queryKey: [ENDPOINT.ATTACH_SERVICE.ATTACHMENTS, atflCd],
|
||||
queryFn: () => AttachmentApi.getAttachmentsInfo(atflCd as string),
|
||||
enabled: !!atflCd,
|
||||
});
|
||||
|
||||
const saveHandlerInterceptor = async (data: T) => {
|
||||
if (deleteAttachmentIds.length > 0) {
|
||||
await Promise.all(
|
||||
deleteAttachmentIds.map(AttachmentApi.deleteAttachmentByAtflId),
|
||||
);
|
||||
}
|
||||
await handleSave(data);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setCookie("atfl-cd-key", "");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<FormWrapper
|
||||
form={form}
|
||||
isModifyMode={!!popupSn}
|
||||
handleSave={saveHandlerInterceptor}
|
||||
{...props}
|
||||
>
|
||||
<div className="card">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="15%" />
|
||||
<col width="85%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableHead>제목</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupTtl" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="팝업 제목을 입력하십시오."
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>팝업 크기</TableHead>
|
||||
<TableCell className="border">
|
||||
<div className="flex items-center gap-1">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupWdth" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
className="w-[10rem] !text-[1.3rem]"
|
||||
placeholder="너비"
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<span className="w-5 text-center">×</span>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupHgt" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
className="w-[10rem] !text-[1.3rem]"
|
||||
placeholder="높이"
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>팝업 위치</TableHead>
|
||||
<TableCell className="border">
|
||||
<div className="flex items-center gap-1">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupHrzntltyPstn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
className="w-[10rem] !text-[1.3rem]"
|
||||
placeholder="Left"
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<span className="w-5 text-center">/</span>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupVtclPstn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
className="w-[10rem] !text-[1.3rem]"
|
||||
placeholder="Top"
|
||||
onChange={(e) =>
|
||||
field.onChange(parseInt(e.target.value))
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>팝업 유형</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupTypeCd" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<CodeSelect
|
||||
upCd="POPUPTYPE"
|
||||
onValueChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>콘텐츠 유형</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"contsTypeCd" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={(field.value ?? "") as string}
|
||||
name="contsTypeCd"
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="39" id="contsTypeCd39" />
|
||||
<Label htmlFor="contsTypeCd39">콘텐츠</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="38" id="contsTypeCd38" />
|
||||
<Label htmlFor="contsTypeCd38">링크</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>링크 주소</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupLnkgUrl" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="링크 주소를 입력하십시오."
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>팝업 내용</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupCn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Editor
|
||||
value={(field.value ?? "") as string}
|
||||
onEditorChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>첨부 파일</TableHead>
|
||||
<TableCell className="border">
|
||||
<GeneralFileUploader
|
||||
form={form}
|
||||
attachmentData={attachmentData}
|
||||
deleteAttachmentIds={deleteAttachmentIds}
|
||||
setDeleteAttachmentIds={setDeleteAttachmentIds}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>팝업 그만 보기 사용 여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"popupEndUseYn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
name="popupEndUseYn"
|
||||
value={(field.value ?? "") as string}
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="popupEndUseY" />
|
||||
<Label htmlFor="popupEndUseY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="popupEndUseN" />
|
||||
<Label htmlFor="popupEndUseN">사용안함</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>사용 여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"useYn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
name="useYn"
|
||||
value={(field.value ?? "") as string}
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="useY" />
|
||||
<Label htmlFor="useY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="useN" />
|
||||
<Label htmlFor="useN">사용안함</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</FormWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export { PopupForm };
|
||||
@@ -0,0 +1,131 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type PaginationState,
|
||||
type RowSelectionState,
|
||||
} from "@tanstack/react-table";
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { AuthorityButton } from "@/entities/menu-authority";
|
||||
import { POSTING_TYPE, PostingDialog } from "@/entities/posting";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { PopupApi } from "../api/popup-service";
|
||||
import { columns } from "../model/table-columns";
|
||||
import type { Popup, PopupParams } from "../model/popup-interface";
|
||||
|
||||
type PostingTarget = {
|
||||
pstgTrgtNm: string;
|
||||
pstgTrgtNo: number;
|
||||
};
|
||||
|
||||
function PopupPage() {
|
||||
const router = useRouter();
|
||||
|
||||
const [popupParams, setPopupParams] = useState<PopupParams>({
|
||||
keyword: "",
|
||||
});
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 10,
|
||||
});
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
const [postingTargets, setPostingTargets] = useState<PostingTarget[]>([]);
|
||||
|
||||
const { data: popupList, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POPUPS],
|
||||
queryFn: () =>
|
||||
PopupApi.getPopupList({
|
||||
...popupParams,
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
}),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
refetch();
|
||||
};
|
||||
|
||||
const handleRowClick = (row: Popup) => {
|
||||
router.push(`/popup/register/${row.popupSn}`);
|
||||
};
|
||||
|
||||
const table = useReactTable({
|
||||
data: popupList?.content ?? [],
|
||||
columns,
|
||||
rowCount: popupList?.totalElements ?? 0,
|
||||
state: {
|
||||
pagination,
|
||||
rowSelection,
|
||||
},
|
||||
manualPagination: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const postingTargets = table
|
||||
.getFilteredSelectedRowModel()
|
||||
.rows.map((row) => ({
|
||||
pstgTrgtNm: row.original.popupTtl,
|
||||
pstgTrgtNo: row.original.popupSn,
|
||||
}));
|
||||
|
||||
if (!postingTargets.length) {
|
||||
setPostingTargets([]);
|
||||
return;
|
||||
}
|
||||
|
||||
setPostingTargets(postingTargets);
|
||||
}, [rowSelection]);
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card card-border">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<Label htmlFor="" className="mr-2 text-label">
|
||||
팝업명
|
||||
</Label>
|
||||
<Input
|
||||
className="h-[3.2rem] w-[20rem] rounded-sm !text-[1.3rem]"
|
||||
value={popupParams.keyword}
|
||||
onChange={(e) =>
|
||||
setPopupParams({ ...popupParams, keyword: e.target.value })
|
||||
}
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">팝업 목록</h3>
|
||||
<div className="flex items-center gap-2">
|
||||
<PostingDialog
|
||||
postingType={POSTING_TYPE.POPUP}
|
||||
postingTargets={postingTargets}
|
||||
/>
|
||||
<AuthorityButton
|
||||
authority="regAuthrtYn"
|
||||
onClick={() => router.push("/popup/register")}
|
||||
>
|
||||
등록
|
||||
</AuthorityButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { PopupPage };
|
||||
@@ -0,0 +1,74 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Button, Checkbox, Label } from "@common/components";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { PopupApi } from "../api/popup-service";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { setCookie, getCookie } from "@/shared/lib/cookie";
|
||||
|
||||
function ViewPopup({ popupSn }: { popupSn: string }) {
|
||||
const doNotShowTodayRef = useRef(false);
|
||||
|
||||
const { data: popupInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POPUPS, popupSn],
|
||||
queryFn: () => PopupApi.getPopupInfo(parseInt(popupSn)),
|
||||
});
|
||||
|
||||
const handleClose = () => {
|
||||
if (doNotShowTodayRef.current) {
|
||||
const expireDate = new Date();
|
||||
expireDate.setHours(23, 59, 59, 999);
|
||||
|
||||
setCookie(`cs-popup-hide-for-day-${popupSn}`, "true", {
|
||||
expires: expireDate,
|
||||
path: "/",
|
||||
});
|
||||
}
|
||||
|
||||
window.close();
|
||||
};
|
||||
|
||||
const handleCheckboxChange = (checked: boolean) => {
|
||||
doNotShowTodayRef.current = checked;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const cookieName = `cs-popup-hide-for-day-${popupSn}`;
|
||||
const hasCookie = getCookie(cookieName);
|
||||
|
||||
if (hasCookie) {
|
||||
window.close();
|
||||
}
|
||||
}, [popupSn]);
|
||||
|
||||
return (
|
||||
<div className="h-svh bg-container p-4">
|
||||
<div className="card card-border !m-0">
|
||||
<div className="card-header">
|
||||
<h1 className="text-3xl font-bold text-foreground">
|
||||
{popupInfo?.popupTtl}
|
||||
</h1>
|
||||
</div>
|
||||
<div
|
||||
className="whitespace-pre-wrap p-2"
|
||||
dangerouslySetInnerHTML={{ __html: popupInfo?.popupCn ?? "" }}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-2 flex items-center justify-between p-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="doNotShowToday"
|
||||
onCheckedChange={handleCheckboxChange}
|
||||
/>
|
||||
<Label htmlFor="doNotShowToday">오늘 하루 보지 않기</Label>
|
||||
</div>
|
||||
<Button size="sm" color="white" onClick={handleClose}>
|
||||
닫기
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ViewPopup };
|
||||
@@ -0,0 +1 @@
|
||||
export { RecentPage } from "./ui/recent-page";
|
||||
@@ -0,0 +1,117 @@
|
||||
import dayjs from "dayjs";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Button, Checkbox } from "@common/components";
|
||||
import { AttachmentApi } from "@/entities/attachment";
|
||||
import type { RecentPost } from "@/entities/post";
|
||||
|
||||
export const columns: ColumnDef<RecentPost>[] = [
|
||||
{
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={table.getIsAllPageRowsSelected()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) =>
|
||||
table.toggleAllPageRowsSelected(!!checked)
|
||||
}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onCheckedChange={(checked) => row.toggleSelected(!!checked)}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
meta: {
|
||||
width: 40,
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "rowNo",
|
||||
header: "NO",
|
||||
meta: {
|
||||
width: 80,
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "bbsNm",
|
||||
header: "게시판",
|
||||
meta: {
|
||||
width: 200,
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "pstTtl",
|
||||
header: "제목",
|
||||
cell: ({ row }) => <div className="text-left">{row.original.pstTtl}</div>,
|
||||
},
|
||||
{
|
||||
accessorKey: "atflCd",
|
||||
header: "첨부파일",
|
||||
cell: ({ row }) => {
|
||||
const atflCd = row.original.atflCd;
|
||||
if (!atflCd) return null;
|
||||
return <AttachmentButton atflCd={atflCd} />;
|
||||
},
|
||||
meta: {
|
||||
width: 100,
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "rgtrNm",
|
||||
header: "작성자",
|
||||
meta: {
|
||||
width: 120,
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => dayjs(row.original.regDt).format("YYYY-MM-DD"),
|
||||
meta: {
|
||||
width: 120,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const AttachmentButton = ({ atflCd }: { atflCd: string }) => {
|
||||
const handleDownload = async (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.stopPropagation();
|
||||
try {
|
||||
let filename = "";
|
||||
const response = await AttachmentApi.downloadAttachmentByAtflCd(atflCd);
|
||||
const contentDisposition = response.headers["content-disposition"];
|
||||
if (contentDisposition) {
|
||||
const filenameMatch = contentDisposition.match(
|
||||
/filename\*=UTF-8''([^;]+)/,
|
||||
);
|
||||
if (filenameMatch) {
|
||||
filename = decodeURIComponent(filenameMatch[1]);
|
||||
}
|
||||
}
|
||||
|
||||
const blob = new Blob([response.data]);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(link);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button size="icon" color="white" onClick={handleDownload}>
|
||||
<i className="diveicon di-download" />
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
import React, { useRef } from "react";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogTrigger,
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@common/components";
|
||||
import type { Board } from "@/entities/board";
|
||||
import type { MovePost } from "@/entities/post";
|
||||
import { AuthorityButton } from "@/entities/menu-authority";
|
||||
|
||||
type MovePostDialogProps = {
|
||||
selectedPosts: MovePost[];
|
||||
boardList: Board[];
|
||||
onMovePost: (data: MovePost[]) => void;
|
||||
};
|
||||
|
||||
function MovePostDialog({
|
||||
selectedPosts,
|
||||
boardList,
|
||||
onMovePost,
|
||||
}: MovePostDialogProps) {
|
||||
const selectedPostsRef = useRef<MovePost[]>(selectedPosts);
|
||||
|
||||
const onSelectValueChange = (toBbsId: string) => {
|
||||
selectedPostsRef.current = selectedPosts.map((post) => ({
|
||||
...post,
|
||||
toBbsId: parseInt(toBbsId),
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<AuthorityButton
|
||||
authority="mngAuthrtYn"
|
||||
disabled={!selectedPosts.length}
|
||||
>
|
||||
게시물 이동
|
||||
</AuthorityButton>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<p className="pt-8 text-center text-[1.3rem]">
|
||||
이동할 게시판을 선택해 주세요.
|
||||
</p>
|
||||
<Select onValueChange={onSelectValueChange}>
|
||||
<SelectTrigger className="my-4">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{boardList.map((board) => (
|
||||
<SelectItem key={board.bbsId} value={board.bbsId.toString()}>
|
||||
{board.bbsNm}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Button onClick={() => onMovePost(selectedPostsRef.current)}>
|
||||
이동
|
||||
</Button>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export { MovePostDialog };
|
||||
@@ -0,0 +1,343 @@
|
||||
"use client";
|
||||
|
||||
import dayjs from "dayjs";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type PaginationState,
|
||||
type RowSelectionState,
|
||||
} from "@tanstack/react-table";
|
||||
import {
|
||||
Button,
|
||||
DateRangePicker,
|
||||
Input,
|
||||
Label,
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
DataTable,
|
||||
} from "@common/components";
|
||||
import {
|
||||
PostApi,
|
||||
type DeletePost,
|
||||
type MovePost,
|
||||
type RecentPost,
|
||||
type RecentPostParams,
|
||||
} from "@/entities/post";
|
||||
import { BoardApi } from "@/entities/board";
|
||||
import { AuthorityButton } from "@/entities/menu-authority";
|
||||
import { useAlertStore, useMutationWrapper, usePrompt } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { columns } from "../model/table-columns";
|
||||
import { MovePostDialog } from "./move-post-dialog";
|
||||
|
||||
type DateRange = {
|
||||
from: Date | undefined;
|
||||
to?: Date | undefined;
|
||||
};
|
||||
|
||||
function RecentPage() {
|
||||
const router = useRouter();
|
||||
const { prompt } = usePrompt();
|
||||
const { confirm } = useConfirm();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const [dateRange, setDateRange] = useState<DateRange>();
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 10,
|
||||
});
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
const [recentPostParams, setRecentPostParams] = useState<RecentPostParams>({
|
||||
keywordType: "",
|
||||
keyword: "",
|
||||
bbsId: null,
|
||||
delYn: "N",
|
||||
frDateYmd: "",
|
||||
toDateYmd: "",
|
||||
});
|
||||
const [isDeletePostData, setIsDeletePostData] = useState(false);
|
||||
|
||||
const { data: recentPostList, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, pagination],
|
||||
queryFn: () =>
|
||||
PostApi.getRecentPostList({
|
||||
...recentPostParams,
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
}),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
|
||||
const { data: boardList } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.BBS],
|
||||
queryFn: () => BoardApi.getBoardList(),
|
||||
});
|
||||
|
||||
const { mutate: movePost } = useMutationWrapper({
|
||||
mutationFn: (data: MovePost[]) => PostApi.movePost(data),
|
||||
onSuccess: () => {
|
||||
alert("이동이 완료되었습니다.", refetch);
|
||||
},
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: recentPostList?.content ?? [],
|
||||
columns,
|
||||
state: {
|
||||
pagination,
|
||||
rowSelection,
|
||||
},
|
||||
rowCount: recentPostList?.totalElements ?? 0,
|
||||
manualPagination: true,
|
||||
enableMultiRowSelection: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
|
||||
const isSelectedRow = table.getFilteredSelectedRowModel().rows.length > 0;
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
setIsDeletePostData(recentPostParams.delYn === "Y");
|
||||
refetch();
|
||||
};
|
||||
|
||||
const handleRowClick = (row: RecentPost) => {
|
||||
router.push(
|
||||
`/bbs/${row.bbsTypeCd.toLowerCase()}/${row.bbsId}/${row.pstNo}`,
|
||||
);
|
||||
};
|
||||
|
||||
const handleRecentPostParamsChange =
|
||||
(key: keyof RecentPostParams) => (value: unknown) => {
|
||||
setRecentPostParams({ ...recentPostParams, [key]: value });
|
||||
};
|
||||
|
||||
const handlePresetDateRange = (value: string) => {
|
||||
let presetDateRange: DateRange | undefined;
|
||||
switch (value) {
|
||||
case "1W":
|
||||
presetDateRange = {
|
||||
from: dayjs().subtract(7, "day").toDate(),
|
||||
to: dayjs().toDate(),
|
||||
};
|
||||
break;
|
||||
case "1M":
|
||||
presetDateRange = {
|
||||
from: dayjs().subtract(30, "day").toDate(),
|
||||
to: dayjs().toDate(),
|
||||
};
|
||||
break;
|
||||
case "3M":
|
||||
presetDateRange = {
|
||||
from: dayjs().subtract(90, "day").toDate(),
|
||||
to: dayjs().toDate(),
|
||||
};
|
||||
break;
|
||||
default:
|
||||
presetDateRange = undefined;
|
||||
}
|
||||
setDateRange(presetDateRange);
|
||||
};
|
||||
|
||||
const onSoftDeletePost = async () => {
|
||||
const { resolved, value: delRsn } =
|
||||
await prompt("삭제 사유를 입력해주세요.");
|
||||
if (!resolved) return;
|
||||
|
||||
const selectedPosts: DeletePost[] = table
|
||||
.getFilteredSelectedRowModel()
|
||||
.rows.map((row) => ({
|
||||
bbsId: row.original.bbsId,
|
||||
pstNo: row.original.pstNo,
|
||||
delRsn,
|
||||
}));
|
||||
PostApi.softDeletePost(selectedPosts);
|
||||
alert("삭제가 완료되었습니다.", refetch);
|
||||
setRowSelection({});
|
||||
};
|
||||
|
||||
const onHardDeletePost = async () => {
|
||||
if (
|
||||
await confirm(
|
||||
"게시물을 완전 삭제하시겠습니까?\n이 작업은 되돌릴 수 없습니다.",
|
||||
)
|
||||
) {
|
||||
const selectedPosts: DeletePost[] = table
|
||||
.getFilteredSelectedRowModel()
|
||||
.rows.map((row) => ({
|
||||
bbsId: row.original.bbsId,
|
||||
pstNo: row.original.pstNo,
|
||||
}));
|
||||
PostApi.hardDeletePost(selectedPosts);
|
||||
alert("삭제가 완료되었습니다.", refetch);
|
||||
setRowSelection({});
|
||||
}
|
||||
};
|
||||
|
||||
const onRestorePost = async () => {
|
||||
if (await confirm("게시물을 복원하시겠습니까?")) {
|
||||
const selectedPosts: DeletePost[] = table
|
||||
.getFilteredSelectedRowModel()
|
||||
.rows.map((row) => ({
|
||||
bbsId: row.original.bbsId,
|
||||
pstNo: row.original.pstNo,
|
||||
}));
|
||||
PostApi.restorePost(selectedPosts);
|
||||
alert("복원이 완료되었습니다.", refetch);
|
||||
setRowSelection({});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card card-border">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<Label className="mr-2">날짜</Label>
|
||||
<DateRangePicker value={dateRange} onValueChange={setDateRange}>
|
||||
<div className="card card-border flex items-center gap-2">
|
||||
<Select onValueChange={handlePresetDateRange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="기간 선택" className="w-[24rem]" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="1W">일주일</SelectItem>
|
||||
<SelectItem value="1M">1개월</SelectItem>
|
||||
<SelectItem value="3M">3개월</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</DateRangePicker>
|
||||
|
||||
<Label className="ml-4 mr-2 text-label">게시판</Label>
|
||||
<Select onValueChange={handleRecentPostParamsChange("bbsId")}>
|
||||
<SelectTrigger className="w-[12rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{boardList?.content.map((board) => (
|
||||
<SelectItem key={board.bbsId} value={board.bbsId.toString()}>
|
||||
{board.bbsNm}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Label className="ml-4 mr-2 text-label">상태</Label>
|
||||
<Select onValueChange={handleRecentPostParamsChange("delYn")}>
|
||||
<SelectTrigger className="w-[10rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="N">정상</SelectItem>
|
||||
<SelectItem value="Y">삭제</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Label className="ml-4 mr-2 text-label">검색</Label>
|
||||
<Select
|
||||
value={recentPostParams.keywordType}
|
||||
onValueChange={handleRecentPostParamsChange("keywordType")}
|
||||
>
|
||||
<SelectTrigger className="h-[3.2rem] w-[10rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="title">제목</SelectItem>
|
||||
<SelectItem value="all">제목+내용</SelectItem>
|
||||
<SelectItem value="writer">작성자</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
value={recentPostParams.keyword}
|
||||
onChange={(e) =>
|
||||
handleRecentPostParamsChange("keyword")(e.target.value)
|
||||
}
|
||||
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<h3 className="text-2xl font-medium text-label">콘텐츠 목록</h3>
|
||||
<div className="flex gap-2">
|
||||
{isDeletePostData ? (
|
||||
<>
|
||||
<AuthorityButton
|
||||
authority="mngAuthrtYn"
|
||||
onClick={onRestorePost}
|
||||
disabled={!isSelectedRow}
|
||||
>
|
||||
게시물 복원
|
||||
</AuthorityButton>
|
||||
<AuthorityButton
|
||||
authority="delAuthrtYn"
|
||||
color="red"
|
||||
onClick={onHardDeletePost}
|
||||
disabled={!isSelectedRow}
|
||||
>
|
||||
완전삭제
|
||||
</AuthorityButton>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<MovePostDialog
|
||||
selectedPosts={table
|
||||
.getFilteredSelectedRowModel()
|
||||
.rows.map((row) => ({
|
||||
fromBbsId: row.original.bbsId,
|
||||
pstNo: row.original.pstNo,
|
||||
}))}
|
||||
boardList={boardList?.content ?? []}
|
||||
onMovePost={movePost}
|
||||
/>
|
||||
<AuthorityButton
|
||||
authority="delAuthrtYn"
|
||||
color="red"
|
||||
onClick={onSoftDeletePost}
|
||||
disabled={!isSelectedRow}
|
||||
>
|
||||
선택삭제
|
||||
</AuthorityButton>
|
||||
</>
|
||||
)}
|
||||
<Select
|
||||
value={table.getState().pagination.pageSize.toString()}
|
||||
onValueChange={(value) => {
|
||||
table.setPageSize(parseInt(value));
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="h-[3.2rem] w-[12rem]">
|
||||
<SelectValue placeholder="페이지 크기" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[10, 20, 30, 40, 50].map((pageSize) => (
|
||||
<SelectItem key={pageSize} value={pageSize.toString()}>
|
||||
{pageSize}개씩 보기
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { RecentPage };
|
||||
@@ -0,0 +1,47 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
Role,
|
||||
RoleList,
|
||||
RoleParams,
|
||||
RoleFormData,
|
||||
RoleService,
|
||||
} from "../model/role-interface";
|
||||
|
||||
export class RoleApiService implements RoleService {
|
||||
public async getRoles(params: RoleParams): Promise<RoleList> {
|
||||
const response = await client.get<RoleList>(ENDPOINT.USER_SERVICE.ROLES, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getRoleInfo(roleId: string): Promise<Role> {
|
||||
const response = await client.get<Role>(
|
||||
`${ENDPOINT.USER_SERVICE.ROLES}/${roleId}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async createRole(data: RoleFormData): Promise<void> {
|
||||
await client.post(ENDPOINT.USER_SERVICE.ROLES, data);
|
||||
}
|
||||
|
||||
public async updateRole(roleId: string, data: RoleFormData): Promise<void> {
|
||||
await client.put(`${ENDPOINT.USER_SERVICE.ROLES}/${roleId}`, data);
|
||||
}
|
||||
|
||||
public async deleteRole(roleId: string): Promise<void> {
|
||||
await client.delete(`${ENDPOINT.USER_SERVICE.ROLES}/${roleId}`);
|
||||
}
|
||||
|
||||
public async checkDuplicateRoleId(roleId: string): Promise<boolean> {
|
||||
const response = await client.get(
|
||||
`${ENDPOINT.USER_SERVICE.ROLES}/check/dup`,
|
||||
{ params: { roleId } },
|
||||
);
|
||||
return response.data as boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export const RoleApi = new RoleApiService();
|
||||
@@ -0,0 +1,3 @@
|
||||
export { RolePage } from "./ui/role-page";
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
@@ -0,0 +1,37 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export interface RoleParams extends PageableParams {
|
||||
keywordType?: string;
|
||||
keyword?: string;
|
||||
}
|
||||
|
||||
export interface Role {
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
roleContent: string;
|
||||
useYn: string;
|
||||
mdfcnDt: string;
|
||||
mdfrNm: string;
|
||||
mngrYn: string;
|
||||
}
|
||||
|
||||
export const roleFormSchema = z.object({
|
||||
roleId: z.string(),
|
||||
roleName: z.string(),
|
||||
roleContent: z.string(),
|
||||
useYn: z.string(),
|
||||
mngrYn: z.string(),
|
||||
});
|
||||
|
||||
export type RoleList = PageableList<Role>;
|
||||
export type RoleFormData = z.infer<typeof roleFormSchema>;
|
||||
|
||||
export interface RoleService {
|
||||
getRoles: (params: RoleParams) => Promise<RoleList>;
|
||||
getRoleInfo: (roleId: string) => Promise<Role>;
|
||||
createRole: (data: RoleFormData) => Promise<void>;
|
||||
updateRole: (roleId: string, data: RoleFormData) => Promise<void>;
|
||||
deleteRole: (roleId: string) => Promise<void>;
|
||||
checkDuplicateRoleId: (roleId: string) => Promise<boolean>;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import dayjs from "dayjs";
|
||||
import { useState } from "react";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { MappingRoleDialog } from "../ui/mapping-role-dialog";
|
||||
import type { Role } from "./role-interface";
|
||||
|
||||
export const columns: ColumnDef<Role>[] = [
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row }) => row.index + 1,
|
||||
},
|
||||
{
|
||||
accessorKey: "roleId",
|
||||
header: "권한ID",
|
||||
},
|
||||
{
|
||||
accessorKey: "roleName",
|
||||
header: "권한명",
|
||||
},
|
||||
{
|
||||
accessorKey: "roleContent",
|
||||
header: "권한내용",
|
||||
},
|
||||
{
|
||||
accessorKey: "mdfrNm",
|
||||
header: "최종수정자",
|
||||
},
|
||||
{
|
||||
accessorKey: "mdfcnDt",
|
||||
header: "최종수정일",
|
||||
cell: ({ row }) => dayjs(row.original.mdfcnDt).format("YYYY-MM-DD"),
|
||||
},
|
||||
{
|
||||
id: "action",
|
||||
header: "관리",
|
||||
cell: ({ row }) => <MappingRoleButton roleId={row.original.roleId} />,
|
||||
},
|
||||
];
|
||||
|
||||
const MappingRoleButton = ({ roleId }: { roleId: string }) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<MappingRoleDialog roleId={roleId} open={open} onOpenChange={setOpen} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { RoleForm } from "./role-form";
|
||||
import { RoleApi } from "../api/role-service";
|
||||
import { roleFormSchema, type RoleFormData } from "../model/role-interface";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createRole } = useMutationWrapper({
|
||||
mutationFn: (data: RoleFormData) => RoleApi.createRole(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<RoleFormData>({
|
||||
resolver: zodResolver(roleFormSchema),
|
||||
defaultValues: {
|
||||
mngrYn: "Y",
|
||||
useYn: "Y",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">권한 등록</h3>
|
||||
</div>
|
||||
<RoleForm form={form} handleSave={createRole} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,145 @@
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type ColumnDef,
|
||||
} from "@tanstack/react-table";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Button,
|
||||
DataTable,
|
||||
Switch,
|
||||
} from "@common/components";
|
||||
import {
|
||||
RoleAuthorizationsApi,
|
||||
type RoleAuthorizationsData,
|
||||
type RoleAuthorizationsByRoleId,
|
||||
} from "@/entities/role-authorization";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
|
||||
type MappingRoleDialogProps = {
|
||||
roleId: string;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
};
|
||||
|
||||
function MappingRoleDialog({
|
||||
roleId,
|
||||
open,
|
||||
onOpenChange,
|
||||
...props
|
||||
}: MappingRoleDialogProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: authorizationList } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.AUTHORIZATIONS],
|
||||
queryFn: () =>
|
||||
RoleAuthorizationsApi.getRoleAuthorizationsListByRoleId({
|
||||
roleId,
|
||||
}),
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const { mutate, isPending } = useMutationWrapper({
|
||||
mutationFn: (data: RoleAuthorizationsData) =>
|
||||
RoleAuthorizationsApi.createRoleAuthorizations(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.AUTHORIZATIONS],
|
||||
});
|
||||
alert("권한 맵핑이 완료되었습니다.");
|
||||
},
|
||||
});
|
||||
|
||||
const applyRoleAuthorization = (apply: boolean, authorizationNo: number) => {
|
||||
mutate([{ roleId, authorizationNo, authYn: apply ? "Y" : "N" }]);
|
||||
};
|
||||
|
||||
const handleApplyAll = (authYn: "Y" | "N") => {
|
||||
mutate(
|
||||
authorizationList?.content.map((authorization) => ({
|
||||
roleId,
|
||||
authorizationNo: authorization.authorizationNo,
|
||||
authYn,
|
||||
})) ?? [],
|
||||
);
|
||||
};
|
||||
|
||||
const table = useReactTable({
|
||||
data: authorizationList?.content ?? [],
|
||||
columns: createColumns(isPending, applyRoleAuthorization),
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange} {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm">권한맵핑</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>모듈 목록</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="max-h-[40rem] overflow-y-auto">
|
||||
<div className="mb-4 flex justify-end gap-2">
|
||||
<Button size="sm" onClick={() => handleApplyAll("Y")}>
|
||||
일괄적용
|
||||
</Button>
|
||||
<Button size="sm" color="gray" onClick={() => handleApplyAll("N")}>
|
||||
일괄해제
|
||||
</Button>
|
||||
</div>
|
||||
<DataTable table={table} />
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
const createColumns = (
|
||||
isPending: boolean,
|
||||
applyRoleAuthorization: (apply: boolean, authorizationNo: number) => void,
|
||||
): ColumnDef<RoleAuthorizationsByRoleId>[] => [
|
||||
{
|
||||
accessorKey: "authorizationName",
|
||||
header: "API명",
|
||||
meta: {
|
||||
width: 130,
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "urlPatternValue",
|
||||
header: "API URL",
|
||||
},
|
||||
{
|
||||
accessorKey: "httpMethodCode",
|
||||
header: "요청 메소드",
|
||||
meta: {
|
||||
width: 90,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "action",
|
||||
header: "사용여부",
|
||||
cell: ({ row }) => (
|
||||
<Switch
|
||||
checked={row.original.createdAt}
|
||||
onCheckedChange={(apply) =>
|
||||
applyRoleAuthorization(apply, row.original.authorizationNo)
|
||||
}
|
||||
disabled={isPending}
|
||||
/>
|
||||
),
|
||||
meta: {
|
||||
width: 80,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export { MappingRoleDialog };
|
||||
@@ -0,0 +1,61 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { RoleForm } from "./role-form";
|
||||
import { RoleApi } from "../api/role-service";
|
||||
import { roleFormSchema, type RoleFormData } from "../model/role-interface";
|
||||
|
||||
function ModifyPage({ roleId }: { roleId: string }) {
|
||||
const router = useRouter();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: roleInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.ROLES, roleId],
|
||||
queryFn: () => RoleApi.getRoleInfo(roleId),
|
||||
});
|
||||
const { mutateAsync: updateRole } = useMutationWrapper({
|
||||
mutationFn: (data: RoleFormData) => RoleApi.updateRole(roleId, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteRole } = useMutationWrapper({
|
||||
mutationFn: () => RoleApi.deleteRole(roleId),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<RoleFormData>({
|
||||
resolver: zodResolver(roleFormSchema),
|
||||
values: {
|
||||
roleId: roleInfo?.roleId ?? "",
|
||||
roleName: roleInfo?.roleName ?? "",
|
||||
roleContent: roleInfo?.roleContent ?? "",
|
||||
useYn: roleInfo?.useYn ?? "",
|
||||
mngrYn: roleInfo?.mngrYn ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">권한 수정</h3>
|
||||
</div>
|
||||
<RoleForm
|
||||
roleId={roleId}
|
||||
form={form}
|
||||
handleSave={updateRole}
|
||||
handleDelete={deleteRole}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,205 @@
|
||||
import { useState } from "react";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
Label,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import { FormWrapper } from "@/widgets/form-wrapper";
|
||||
import { FormField, FormItem, FormControl } from "@/shared/ui/form";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import { RoleApi } from "../api/role-service";
|
||||
import type { RoleFormData } from "../model/role-interface";
|
||||
|
||||
type RoleFormProps = {
|
||||
roleId?: string;
|
||||
form: UseFormReturn<RoleFormData>;
|
||||
handleSave: (data: RoleFormData) => Promise<void>;
|
||||
handleDelete?: () => Promise<void>;
|
||||
};
|
||||
|
||||
function RoleForm({ roleId, form, ...props }: RoleFormProps) {
|
||||
const isModifyMode = !!roleId;
|
||||
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const [isValidRoleId, setIsValidRoleId] = useState(false);
|
||||
|
||||
const { mutateAsync: checkDuplicateRoleId } = useMutationWrapper({
|
||||
mutationFn: (roleId: string) => RoleApi.checkDuplicateRoleId(roleId),
|
||||
onSuccess: (duplicate) => {
|
||||
if (!duplicate) {
|
||||
alert("사용가능한 권한ID입니다.");
|
||||
setIsValidRoleId(true);
|
||||
return;
|
||||
}
|
||||
alert("중복된 권한ID입니다.");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<FormWrapper form={form} isModifyMode={isModifyMode} {...props}>
|
||||
<div className="card">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="15%" />
|
||||
<col width="85%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableHead>권한ID</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="roleId"
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center gap-2">
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
onChange={(e) => {
|
||||
field.onChange(e);
|
||||
setIsValidRoleId(false);
|
||||
}}
|
||||
className="w-[20rem] !text-[1.3rem]"
|
||||
placeholder="권한ID를 입력하세요"
|
||||
disabled={isModifyMode}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
{!isModifyMode && (
|
||||
<Button
|
||||
color="green"
|
||||
className="px-6"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
checkDuplicateRoleId(field.value);
|
||||
}}
|
||||
disabled={!field.value || isValidRoleId}
|
||||
>
|
||||
{isValidRoleId && <i className="diveicon di-check" />}
|
||||
중복확인
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>권한명</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="roleName"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="권한명을 입력하세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>권한내용</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="roleContent"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="권한내용을 입력하세요"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>관리권한여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="mngrYn"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
name="mngrYn"
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="mngrY" />
|
||||
<Label htmlFor="mngrY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="mngrN" />
|
||||
<Label htmlFor="mngrN">사용안함</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>사용여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="useYn"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
name="useYn"
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="Y" id="useY" />
|
||||
<Label htmlFor="useY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="useN" />
|
||||
<Label htmlFor="useN">사용안함</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</FormWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export { RoleForm };
|
||||
@@ -0,0 +1,96 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type PaginationState,
|
||||
} from "@tanstack/react-table";
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { RoleApi } from "../api/role-service";
|
||||
import { columns } from "../model/table-columns";
|
||||
import type { Role, RoleParams } from "../model/role-interface";
|
||||
|
||||
function RolePage() {
|
||||
const router = useRouter();
|
||||
|
||||
const [roleQuery, setRoleQuery] = useState<RoleParams>({
|
||||
keyword: "",
|
||||
});
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: 0,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const { data: roles } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.ROLES, pagination],
|
||||
queryFn: () =>
|
||||
RoleApi.getRoles({
|
||||
...roleQuery,
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
}),
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: roles?.content ?? [],
|
||||
columns,
|
||||
state: {
|
||||
pagination,
|
||||
},
|
||||
rowCount: roles?.totalElements ?? 0,
|
||||
manualPagination: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onPaginationChange: setPagination,
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
const handleRowClick = (row: Role) => {
|
||||
router.push(`/role/register/${row.roleId}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card card-border">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<Label htmlFor="" className="mr-2 text-label">
|
||||
권한명
|
||||
</Label>
|
||||
<Input
|
||||
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
|
||||
value={roleQuery.keyword}
|
||||
onChange={(e) =>
|
||||
setRoleQuery({ ...roleQuery, keyword: e.target.value })
|
||||
}
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<h3 className="text-2xl font-medium text-label">권한 목록</h3>
|
||||
<div className="flex gap-2">
|
||||
<Button onClick={() => router.push("/role/register")}>
|
||||
등록
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] !p-0">
|
||||
<DataTable table={table} onRowClick={handleRowClick} viewPagination />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { RolePage };
|
||||
@@ -0,0 +1,39 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
Schedule,
|
||||
ScheduleFormData,
|
||||
ScheduleParams,
|
||||
ScheduleService,
|
||||
ScheduleUpdateFormData,
|
||||
} from "../model/schedule-interface";
|
||||
|
||||
class ScheduleApiService implements ScheduleService {
|
||||
public async getSchedules(params?: ScheduleParams): Promise<Schedule[]> {
|
||||
const response = await client.get<Schedule[]>(
|
||||
ENDPOINT.CMS_SERVICE.SCHEDULES,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getScheduleInfo(schdlSn: number): Promise<Schedule> {
|
||||
const response = await client.get<Schedule>(
|
||||
`${ENDPOINT.CMS_SERVICE.SCHEDULES}/${schdlSn}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async createSchedule(data: ScheduleFormData): Promise<void> {
|
||||
await client.post(ENDPOINT.CMS_SERVICE.SCHEDULES, data);
|
||||
}
|
||||
|
||||
public async updateSchedule(
|
||||
schdlSn: number,
|
||||
data: ScheduleUpdateFormData,
|
||||
): Promise<void> {
|
||||
await client.put(`${ENDPOINT.CMS_SERVICE.SCHEDULES}/${schdlSn}`, data);
|
||||
}
|
||||
}
|
||||
|
||||
export const ScheduleApi = new ScheduleApiService();
|
||||
@@ -0,0 +1,3 @@
|
||||
export { SchedulePage } from "./ui/schedule-page";
|
||||
export { CreatePage } from "./ui/create-page";
|
||||
export { ModifyPage } from "./ui/modify-page";
|
||||
@@ -0,0 +1,67 @@
|
||||
import dayjs from "dayjs";
|
||||
import type {
|
||||
RepeatDto,
|
||||
ScheduleFormData,
|
||||
ScheduleUpdateFormData,
|
||||
} from "../model/schedule-interface";
|
||||
|
||||
const DAY_BY_BITMASK = {
|
||||
0: 1, // 일요일
|
||||
1: 2, // 월요일
|
||||
2: 4, // 화요일
|
||||
3: 8, // 수요일
|
||||
4: 16, // 목요일
|
||||
5: 32, // 금요일
|
||||
6: 64, // 토요일
|
||||
} as const;
|
||||
|
||||
export const generateRepeatDto = (
|
||||
data: ScheduleFormData | ScheduleUpdateFormData,
|
||||
) => {
|
||||
const reptDto: RepeatDto = { ...data.reptDto };
|
||||
|
||||
switch (data.reptDto?.reptCycleCd) {
|
||||
case "DAILY":
|
||||
break;
|
||||
case "WEEKLY":
|
||||
const beginDay = dayjs(data.schdlBgngDt).day();
|
||||
const endDay = dayjs(data.schdlEndDt).day();
|
||||
|
||||
reptDto.reptDowVl =
|
||||
beginDay === endDay
|
||||
? DAY_BY_BITMASK[beginDay]
|
||||
: calculateDaysBitmask(beginDay, endDay);
|
||||
break;
|
||||
case "MONTHLY":
|
||||
reptDto.reptDayVl = dayjs(data.schdlBgngDt).date();
|
||||
break;
|
||||
case "QUARTERLY":
|
||||
const month = dayjs(data.schdlBgngDt).month();
|
||||
reptDto.reptQuVl = Math.floor(month / 3) + 1;
|
||||
reptDto.reptDayVl = dayjs(data.schdlBgngDt).date();
|
||||
break;
|
||||
case "YEARLY":
|
||||
reptDto.reptMmVl = dayjs(data.schdlBgngDt).month() + 1;
|
||||
reptDto.reptDayVl = dayjs(data.schdlBgngDt).date();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
reptDto.reptCycleCd = data.reptDto?.reptCycleCd;
|
||||
|
||||
return reptDto;
|
||||
};
|
||||
|
||||
const calculateDaysBitmask = (startDay: number, endDay: number) => {
|
||||
const length = ((endDay - startDay + 7) % 7) + 1;
|
||||
return Array.from({ length }, (_, i) => {
|
||||
const day = ((startDay + i) % 7) as keyof typeof DAY_BY_BITMASK;
|
||||
return DAY_BY_BITMASK[day];
|
||||
}).reduce((acc, val) => acc + val, 0);
|
||||
};
|
||||
|
||||
export const calculateEventDuration = (startDate: string, endDate: string) => {
|
||||
const start = dayjs(startDate);
|
||||
const end = dayjs(endDate);
|
||||
const minuteDiff = end.diff(start, "minute");
|
||||
return minuteDiff;
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const REPEAT_CYCLE_CODES = {
|
||||
DAILY: "DAILY",
|
||||
WEEKLY: "WEEKLY",
|
||||
MONTHLY: "MONTHLY",
|
||||
QUARTERLY: "QUARTERLY",
|
||||
YEARLY: "YEARLY",
|
||||
} as const;
|
||||
|
||||
export type RepeatCycleCode =
|
||||
(typeof REPEAT_CYCLE_CODES)[keyof typeof REPEAT_CYCLE_CODES];
|
||||
|
||||
export interface ScheduleParams {
|
||||
siteId?: string;
|
||||
schdlTtl?: string;
|
||||
schdlSeCd?: string;
|
||||
schdlBgngYmd?: string;
|
||||
schdlEndYmd?: string;
|
||||
reptYn?: string;
|
||||
commSchdlYn?: string;
|
||||
useYn?: string;
|
||||
}
|
||||
|
||||
export interface Schedule {
|
||||
schdlSn: number;
|
||||
siteId: string;
|
||||
schdlTtl: string;
|
||||
schdlSeCd: string;
|
||||
schdlSeNm: string;
|
||||
schdlBgngDt: string;
|
||||
schdlEndDt: string;
|
||||
reptYn: string;
|
||||
commSchdlYn: string;
|
||||
}
|
||||
|
||||
const scheduleRepeatSchema = z.object({
|
||||
schdlSn: z.number().nullish(),
|
||||
reptCycleCd: z.nativeEnum(REPEAT_CYCLE_CODES).nullish(),
|
||||
reptDayVl: z.number().nullish(),
|
||||
reptDowVl: z.number().nullish(),
|
||||
reptMmVl: z.number().nullish(),
|
||||
reptQuVl: z.number().nullish(),
|
||||
reptEndDt: z.string().nullish(),
|
||||
});
|
||||
|
||||
export const scheduleFormSchema = z.object({
|
||||
siteId: z.string(),
|
||||
schdlTtl: z.string(),
|
||||
schdlSeCd: z.string(),
|
||||
schdlBgngDt: z.string(),
|
||||
schdlEndDt: z.string(),
|
||||
schdlCn: z.string().nullish(),
|
||||
reptYn: z.string().nullish(),
|
||||
commSchdlYn: z.string().nullish(),
|
||||
useYn: z.string().nullish(),
|
||||
atflCd: z.string().nullish(),
|
||||
reptDto: scheduleRepeatSchema.nullish(),
|
||||
});
|
||||
|
||||
export const scheduleUpdateFormSchema = scheduleFormSchema.omit({
|
||||
siteId: true,
|
||||
});
|
||||
|
||||
export type ScheduleFormData = z.infer<typeof scheduleFormSchema>;
|
||||
export type ScheduleUpdateFormData = z.infer<typeof scheduleUpdateFormSchema>;
|
||||
export type RepeatDto = z.infer<typeof scheduleRepeatSchema>;
|
||||
|
||||
export interface ScheduleService {
|
||||
getSchedules(params?: ScheduleParams): Promise<Schedule[]>;
|
||||
getScheduleInfo(schdlSn: number): Promise<Schedule>;
|
||||
createSchedule(data: ScheduleFormData): Promise<void>;
|
||||
updateSchedule(schdlSn: number, data: ScheduleUpdateFormData): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
"use client";
|
||||
|
||||
import dayjs from "dayjs";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { SITE_ID } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import {
|
||||
scheduleFormSchema,
|
||||
type ScheduleFormData,
|
||||
} from "../model/schedule-interface";
|
||||
import { generateRepeatDto } from "../lib/utils";
|
||||
import { ScheduleApi } from "../api/schedule-service";
|
||||
import { ScheduleForm } from "./schedule-form";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const dateStr = searchParams?.get("dateStr");
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { mutateAsync: createSchedule } = useMutationWrapper({
|
||||
mutationFn: ScheduleApi.createSchedule,
|
||||
onSuccess: () => {
|
||||
alert("일정이 등록되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<ScheduleFormData>({
|
||||
resolver: zodResolver(scheduleFormSchema),
|
||||
defaultValues: {
|
||||
siteId: SITE_ID,
|
||||
schdlBgngDt: dateStr
|
||||
? dayjs(dateStr).format("YYYY-MM-DD 00:00:00")
|
||||
: undefined,
|
||||
schdlEndDt: dateStr
|
||||
? dayjs(dateStr).format("YYYY-MM-DD 23:59:59")
|
||||
: undefined,
|
||||
reptYn: "N",
|
||||
commSchdlYn: "N",
|
||||
useYn: "Y",
|
||||
atflCd: null,
|
||||
reptDto: null,
|
||||
},
|
||||
});
|
||||
|
||||
const handleSave = async (data: ScheduleFormData) => {
|
||||
const reptDto = generateRepeatDto(data);
|
||||
const formData = { ...data, reptDto };
|
||||
createSchedule(formData);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card card-border !mb-0 !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">스케줄 등록</h3>
|
||||
</div>
|
||||
<ScheduleForm form={form} handleSave={handleSave} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CreatePage };
|
||||
@@ -0,0 +1,123 @@
|
||||
"use client";
|
||||
|
||||
import dayjs from "dayjs";
|
||||
import { useState } from "react";
|
||||
import { CalendarIcon } from "lucide-react";
|
||||
import {
|
||||
Button,
|
||||
Calendar,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
ScrollArea,
|
||||
ScrollBar,
|
||||
cn,
|
||||
} from "@common/components";
|
||||
|
||||
type DateTimePickerProps = {
|
||||
date?: Date;
|
||||
classes?: { trigger?: string };
|
||||
onDateChange?: (date: Date) => void;
|
||||
};
|
||||
|
||||
function DateTimePicker({ date, classes, onDateChange }: DateTimePickerProps) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const hours = Array.from({ length: 24 }, (_, i) => i);
|
||||
const minutes = Array.from({ length: 60 }, (_, i) => i);
|
||||
|
||||
const handleDateSelect = (selectedDate: Date | undefined) => {
|
||||
if (!selectedDate) return;
|
||||
onDateChange?.(selectedDate);
|
||||
};
|
||||
|
||||
const handleTimeChange = (type: "hour" | "minute", value: string) => {
|
||||
if (date) {
|
||||
const newDate = new Date(date);
|
||||
if (type === "hour") {
|
||||
newDate.setHours(parseInt(value));
|
||||
} else if (type === "minute") {
|
||||
newDate.setMinutes(parseInt(value));
|
||||
}
|
||||
onDateChange?.(newDate);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"date-picker-trigger",
|
||||
!date && "text-muted-foreground",
|
||||
classes?.trigger,
|
||||
)}
|
||||
>
|
||||
<CalendarIcon className="!size-[1.6rem]" />
|
||||
{date ? (
|
||||
dayjs(date).format("YYYY/MM/DD HH:mm")
|
||||
) : (
|
||||
<span>YYYY/MM/DD HH:mm</span>
|
||||
)}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0">
|
||||
<div className="sm:flex">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={date}
|
||||
onSelect={handleDateSelect}
|
||||
initialFocus
|
||||
/>
|
||||
<div className="flex flex-col divide-y sm:h-[300px] sm:flex-row sm:divide-x sm:divide-y-0">
|
||||
<ScrollArea className="w-64 sm:w-auto">
|
||||
<div className="flex p-2 sm:flex-col">
|
||||
{hours.reverse().map((hour) => (
|
||||
<Button
|
||||
key={hour}
|
||||
size="icon"
|
||||
className={cn(
|
||||
"aspect-square shrink-0 text-label sm:w-full",
|
||||
date && date.getHours() === hour
|
||||
? "!bg-primary text-primary-foreground"
|
||||
: "!bg-background",
|
||||
)}
|
||||
onClick={() => handleTimeChange("hour", hour.toString())}
|
||||
>
|
||||
{hour}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<ScrollBar orientation="horizontal" className="sm:hidden" />
|
||||
</ScrollArea>
|
||||
<ScrollArea className="w-64 sm:w-auto">
|
||||
<div className="flex p-2 sm:flex-col">
|
||||
{minutes.map((minute) => (
|
||||
<Button
|
||||
key={minute}
|
||||
size="icon"
|
||||
className={cn(
|
||||
"aspect-square shrink-0 text-label sm:w-full",
|
||||
date && date.getMinutes() === minute
|
||||
? "!bg-primary text-primary-foreground"
|
||||
: "!bg-background",
|
||||
)}
|
||||
onClick={() =>
|
||||
handleTimeChange("minute", minute.toString())
|
||||
}
|
||||
>
|
||||
{minute.toString().padStart(2, "0")}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<ScrollBar orientation="horizontal" className="sm:hidden" />
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export { DateTimePicker };
|
||||
@@ -0,0 +1,65 @@
|
||||
"use client";
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore, useMutationWrapper } from "@/shared/lib";
|
||||
import {
|
||||
scheduleUpdateFormSchema,
|
||||
type ScheduleUpdateFormData,
|
||||
} from "../model/schedule-interface";
|
||||
import { ScheduleApi } from "../api/schedule-service";
|
||||
import { ScheduleForm } from "./schedule-form";
|
||||
import { generateRepeatDto } from "../lib/utils";
|
||||
|
||||
function ModifyPage({ schdlSn }: { schdlSn: string }) {
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
|
||||
const { data: scheduleInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.SCHEDULES, schdlSn],
|
||||
queryFn: () => ScheduleApi.getScheduleInfo(parseInt(schdlSn)),
|
||||
});
|
||||
|
||||
const { mutateAsync: updateSchedule } = useMutationWrapper({
|
||||
mutationFn: (data: ScheduleUpdateFormData) =>
|
||||
ScheduleApi.updateSchedule(parseInt(schdlSn), data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.SCHEDULES],
|
||||
});
|
||||
alert("일정이 수정되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<ScheduleUpdateFormData>({
|
||||
resolver: zodResolver(scheduleUpdateFormSchema),
|
||||
values: {
|
||||
...scheduleInfo,
|
||||
schdlTtl: scheduleInfo?.schdlTtl ?? "",
|
||||
schdlSeCd: scheduleInfo?.schdlSeCd ?? "",
|
||||
schdlBgngDt: scheduleInfo?.schdlBgngDt ?? "",
|
||||
schdlEndDt: scheduleInfo?.schdlEndDt ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
const handleSave = async (data: ScheduleUpdateFormData) => {
|
||||
const reptDto = generateRepeatDto(data);
|
||||
const formData = { ...data, reptDto };
|
||||
updateSchedule(formData);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card card-border !mb-0 !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">스케줄 수정</h3>
|
||||
</div>
|
||||
<ScheduleForm form={form} handleSave={handleSave} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ModifyPage };
|
||||
@@ -0,0 +1,357 @@
|
||||
import dayjs from "dayjs";
|
||||
import { useState } from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import type { Path, PathValue, UseFormReturn } from "react-hook-form";
|
||||
import {
|
||||
Checkbox,
|
||||
DatePicker,
|
||||
Input,
|
||||
Label,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import { GeneralFileUploader } from "@/widgets/post";
|
||||
import { FormWrapper } from "@/widgets/form-wrapper";
|
||||
import { CodeSelect } from "@/entities/code";
|
||||
import { FormItem, FormControl, FormField } from "@/shared/ui/form";
|
||||
import {
|
||||
type ScheduleFormData,
|
||||
type ScheduleUpdateFormData,
|
||||
} from "../model/schedule-interface";
|
||||
import { DateTimePicker } from "./date-time-picker";
|
||||
|
||||
const Editor = dynamic(
|
||||
() => import("@/entities/editor").then((module) => module.Editor),
|
||||
{ ssr: false },
|
||||
);
|
||||
|
||||
type ScheduleFormProps<T extends ScheduleFormData | ScheduleUpdateFormData> = {
|
||||
form: UseFormReturn<T>;
|
||||
scheduleId?: string;
|
||||
handleSave: (data: T) => Promise<void>;
|
||||
handleDelete?: () => Promise<void>;
|
||||
};
|
||||
|
||||
function ScheduleForm<T extends ScheduleFormData | ScheduleUpdateFormData>({
|
||||
form,
|
||||
scheduleId,
|
||||
...props
|
||||
}: ScheduleFormProps<T>) {
|
||||
const isModifyMode = !!scheduleId;
|
||||
|
||||
const [isAllDay, setIsAllDay] = useState(false);
|
||||
const [deleteAttachmentIds, setDeleteAttachmentIds] = useState<string[]>([]);
|
||||
|
||||
const handleDateTimeChange = (name: Path<T>) => (date?: Date) => {
|
||||
if (!date) return;
|
||||
form.setValue(
|
||||
name,
|
||||
dayjs(date).format("YYYY-MM-DD HH:mm:ss") as PathValue<T, Path<T>>,
|
||||
);
|
||||
setIsAllDay(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<FormWrapper form={form} isModifyMode={isModifyMode} {...props}>
|
||||
<div className="card">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="15%" />
|
||||
<col width="85%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableHead>제목</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"schdlTtl" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={(field.value as string) ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="일정 제목을 입력하십시오."
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>일정 기간</TableHead>
|
||||
<TableCell className="border">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"schdlBgngDt" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<DateTimePicker
|
||||
date={
|
||||
field.value
|
||||
? dayjs(field.value as string).toDate()
|
||||
: undefined
|
||||
}
|
||||
classes={{ trigger: "w-auto px-4 justify-start" }}
|
||||
onDateChange={handleDateTimeChange(
|
||||
"schdlBgngDt" as Path<T>,
|
||||
)}
|
||||
{...field}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
~
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"schdlEndDt" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<DateTimePicker
|
||||
date={
|
||||
field.value
|
||||
? dayjs(field.value as string).toDate()
|
||||
: undefined
|
||||
}
|
||||
classes={{ trigger: "w-auto px-4 justify-start" }}
|
||||
onDateChange={handleDateTimeChange(
|
||||
"schdlEndDt" as Path<T>,
|
||||
)}
|
||||
{...field}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="allDay"
|
||||
checked={isAllDay}
|
||||
onCheckedChange={(checked) => {
|
||||
setIsAllDay(checked === true);
|
||||
if (checked === true) {
|
||||
const schdlBgngDt = form.getValues(
|
||||
"schdlBgngDt" as Path<T>,
|
||||
);
|
||||
const schdlEndDt = form.getValues(
|
||||
"schdlEndDt" as Path<T>,
|
||||
);
|
||||
const allSchdlBgngDt = dayjs(
|
||||
schdlBgngDt as string,
|
||||
).format("YYYY-MM-DD 00:00:00");
|
||||
const allSchdlEndDt = dayjs(
|
||||
schdlEndDt as string,
|
||||
).format("YYYY-MM-DD 23:59:59");
|
||||
form.setValue(
|
||||
"schdlBgngDt" as Path<T>,
|
||||
allSchdlBgngDt as PathValue<T, Path<T>>,
|
||||
);
|
||||
form.setValue(
|
||||
"schdlEndDt" as Path<T>,
|
||||
allSchdlEndDt as PathValue<T, Path<T>>,
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Label htmlFor="allDay">종일</Label>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>일정 반복</TableHead>
|
||||
<TableCell className="border">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"reptYn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<div className="mr-2 flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="reptY"
|
||||
checked={field.value === "Y"}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked ? "Y" : "N");
|
||||
}}
|
||||
/>
|
||||
<Label htmlFor="reptY">반복</Label>
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"reptDto.reptCycleCd" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<CodeSelect
|
||||
{...field}
|
||||
upCd="SCHDLRPTCD"
|
||||
value={(field.value as string) ?? ""}
|
||||
onValueChange={field.onChange}
|
||||
placeholder="반복 주기 선택"
|
||||
disabled={form.watch("reptYn" as Path<T>) === "N"}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"reptDto.reptEndDt" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<DatePicker
|
||||
mode="single"
|
||||
selected={
|
||||
field.value
|
||||
? dayjs(field.value as string).toDate()
|
||||
: undefined
|
||||
}
|
||||
onSelect={(value) => {
|
||||
if (!value) return;
|
||||
field.onChange(value);
|
||||
form.setValue(
|
||||
"reptDto.reptEndDt" as Path<T>,
|
||||
dayjs(value).format(
|
||||
"YYYY-MM-DD 23:59:59",
|
||||
) as PathValue<T, Path<T>>,
|
||||
);
|
||||
}}
|
||||
className="w-auto px-4"
|
||||
placeholder="반복 종료일 선택"
|
||||
disabled={form.watch("reptYn" as Path<T>) === "N"}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>일정 유형</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"schdlSeCd" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<CodeSelect
|
||||
{...field}
|
||||
upCd="SCHDLCLCD"
|
||||
value={(field.value as string) ?? ""}
|
||||
onValueChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>일정 내용</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"schdlCn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Editor
|
||||
value={(field.value as string) ?? ""}
|
||||
onEditorChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>대상 사이트</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"commSchdlYn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="commSchdlY"
|
||||
checked={field.value === "Y"}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked ? "Y" : "N");
|
||||
}}
|
||||
/>
|
||||
<Label htmlFor="commSchdlY">공용</Label>
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>첨부 파일</TableHead>
|
||||
<TableCell className="border">
|
||||
<GeneralFileUploader
|
||||
form={form}
|
||||
deleteAttachmentIds={deleteAttachmentIds}
|
||||
setDeleteAttachmentIds={setDeleteAttachmentIds}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableHead>사용 여부</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={"useYn" as Path<T>}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
value={(field.value as string) ?? ""}
|
||||
onValueChange={field.onChange}
|
||||
className="flex items-center gap-4"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<RadioGroupItem value="Y" id="useY" />
|
||||
<Label htmlFor="useY">사용</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<RadioGroupItem value="N" id="useN" />
|
||||
<Label htmlFor="useN">미사용</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</FormWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export { ScheduleForm };
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user