Merge commit 'c966581a993aa9547a67c65bd4064f7b9b92975f' into iipbs/wr/form_fuction
This commit is contained in:
@@ -149,7 +149,9 @@ export default nextConfig;
|
|||||||
### 6. globals.css(또는 전역 css) 수정
|
### 6. globals.css(또는 전역 css) 수정
|
||||||
|
|
||||||
```css
|
```css
|
||||||
@import "@common/assets/index.css";
|
@import "@common/assets/styles/base.css";
|
||||||
|
@import "@common/assets/styles/diveicon.css";
|
||||||
|
@import "@common/assets/styles/components.css";
|
||||||
|
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
import { MenuPage } from "@/pages/menu";
|
||||||
|
export default MenuPage;
|
||||||
@@ -11,6 +11,11 @@ const compat = new FlatCompat({
|
|||||||
|
|
||||||
const eslintConfig = [
|
const eslintConfig = [
|
||||||
...compat.extends("next/core-web-vitals", "next/typescript"),
|
...compat.extends("next/core-web-vitals", "next/typescript"),
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
"react-hooks/exhaustive-deps": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default eslintConfig;
|
export default eslintConfig;
|
||||||
|
|||||||
@@ -5,10 +5,15 @@ const serverApiUrl =
|
|||||||
|
|
||||||
export function middleware(req: NextRequest) {
|
export function middleware(req: NextRequest) {
|
||||||
const pathname = req.nextUrl.pathname;
|
const pathname = req.nextUrl.pathname;
|
||||||
|
const searchParams = req.nextUrl.searchParams;
|
||||||
|
|
||||||
if (pathname.startsWith("/server")) {
|
if (pathname.startsWith("/server")) {
|
||||||
return NextResponse.rewrite(
|
const queryParams = searchParams.toString();
|
||||||
`${serverApiUrl}${pathname.replace("/server", "")}`,
|
const newUrl = `${serverApiUrl}${pathname.replace("/server", "")}${
|
||||||
);
|
queryParams ? `?${queryParams}` : ""
|
||||||
|
}`;
|
||||||
|
console.log("Rewriting to: ", newUrl);
|
||||||
|
return NextResponse.rewrite(new URL(newUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "NODE_OPTIONS='--inspect' next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
"@common/components": "workspace:*",
|
"@common/components": "workspace:*",
|
||||||
"@frontend-opensource/use-react-hooks": "^1.1.4",
|
"@frontend-opensource/use-react-hooks": "^1.1.4",
|
||||||
"@hookform/resolvers": "^4.1.3",
|
"@hookform/resolvers": "^4.1.3",
|
||||||
|
"@minoru/react-dnd-treeview": "^3.5.0",
|
||||||
"@radix-ui/react-label": "^2.1.2",
|
"@radix-ui/react-label": "^2.1.2",
|
||||||
"@radix-ui/react-slot": "^1.1.2",
|
"@radix-ui/react-slot": "^1.1.2",
|
||||||
"@tanstack/react-query": "^5.67.1",
|
"@tanstack/react-query": "^5.67.1",
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"next": "15.1.7",
|
"next": "15.1.7",
|
||||||
"react-chartjs-2": "^5.3.0",
|
"react-chartjs-2": "^5.3.0",
|
||||||
|
"react-dnd": "^16.0.1",
|
||||||
"react-hook-form": "^7.54.2",
|
"react-hook-form": "^7.54.2",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"zod": "^3.24.2",
|
"zod": "^3.24.2",
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import "./styles/base.css";
|
import "./styles/base.css";
|
||||||
import "./styles/components.css";
|
import "./styles/components.css";
|
||||||
import { AppProvider } from "./providers";
|
import { AppProvider } from "./providers";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
|
const App = async ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||||
|
const theme = (await cookies()).get("site-theme-key");
|
||||||
|
|
||||||
const App = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
|
||||||
return (
|
return (
|
||||||
<html lang="ko">
|
<html lang="ko" data-theme={theme?.value}>
|
||||||
<body>
|
<body>
|
||||||
<AppProvider>{children}</AppProvider>
|
<AppProvider>{children}</AppProvider>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
import { ConfirmProvider } from "@frontend-opensource/use-react-hooks";
|
import { ConfirmProvider } from "@frontend-opensource/use-react-hooks";
|
||||||
import { AuthWrapper } from "@/entities/auth";
|
import { AuthWrapper } from "@/entities/auth";
|
||||||
import { QueryProvider, StoreProvider } from "@/shared/providers";
|
import { StoreProvider } from "@/shared/providers";
|
||||||
|
import { AlertDialog } from "@/shared/ui/alert-dialog";
|
||||||
|
|
||||||
const AppProvider = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
const AppProvider = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||||
return (
|
return (
|
||||||
<StoreProvider>
|
<StoreProvider>
|
||||||
<QueryProvider>
|
<ConfirmProvider>
|
||||||
<ConfirmProvider>
|
<AuthWrapper>
|
||||||
<AuthWrapper>{children}</AuthWrapper>
|
{children}
|
||||||
</ConfirmProvider>
|
<AlertDialog />
|
||||||
</QueryProvider>
|
</AuthWrapper>
|
||||||
|
</ConfirmProvider>
|
||||||
</StoreProvider>
|
</StoreProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,25 +1,87 @@
|
|||||||
@tailwind components;
|
.card {
|
||||||
|
position: relative;
|
||||||
|
margin: 0.6rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: 2rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.6rem;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
@layer components {
|
.card_width10 {width:calc(10% - 12px);}
|
||||||
.card {
|
|
||||||
@apply relative m-[0.6rem] box-border min-h-[2rem] rounded-[0.5rem] p-[0.6rem] text-[1.3rem] text-[#666];
|
.card_width20 {width:calc(20% - 12px);}
|
||||||
}
|
|
||||||
|
.card_width25 {width:calc(25% - 12px);}
|
||||||
|
|
||||||
|
.card_width30 {width:calc(30% - 12px);}
|
||||||
|
|
||||||
|
.card_width33 {width:calc(33.333% - 12px);}
|
||||||
|
|
||||||
|
.card_width40 {width:calc(40% - 12px);}
|
||||||
|
|
||||||
|
.card_width45 {width:calc(45% - 12px);}
|
||||||
|
|
||||||
|
.card_width50 {width:calc(50% - 12px);}
|
||||||
|
|
||||||
|
.card_width60 {width:calc(60% - 12px);}
|
||||||
|
|
||||||
|
.card_width66 {width:calc(66.666% - 12px);}
|
||||||
|
|
||||||
|
.card_width70 {width:calc(70% - 12px);}
|
||||||
|
|
||||||
|
.card_width75 {width:calc(75% - 12px);}
|
||||||
|
|
||||||
|
.card_width80 {width:calc(80% - 12px);}
|
||||||
|
|
||||||
|
.card_width90 {width:calc(90% - 12px);}
|
||||||
|
|
||||||
|
.card_width100 {width:calc(100% - 12px);}
|
||||||
|
|
||||||
|
.card_nopadding {padding:0 !important;}
|
||||||
|
|
||||||
|
.card_nomargin {width:100%;margin:0 !important;padding:0 !important;}
|
||||||
|
|
||||||
|
.topline {border-top: 1px solid #ccc;}
|
||||||
|
|
||||||
|
.bottomline {border-bottom: 1px solid #e6eef3;background: #fff;}
|
||||||
|
|
||||||
|
.card-border {
|
||||||
|
border: 1px solid #dbe2e6;
|
||||||
|
background-color: rgba(255, 255, 255, 0.6);
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
margin-left: -0.6rem;
|
||||||
|
margin-right: -0.6rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-bottom: 1px solid #e1e7eb;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-footer {
|
||||||
|
margin-left: -0.6rem;
|
||||||
|
margin-right: -0.6rem;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-top: 1px solid #e1e7eb;
|
||||||
|
padding-top: 1rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 블랙 테마 */
|
||||||
|
[data-theme="black"] {
|
||||||
.card-border {
|
.card-border {
|
||||||
@apply border border-[#dbe2e6] bg-[rgba(255,255,255,0.6)] shadow-blur;
|
border-color: #3f4042;
|
||||||
|
background-color: rgba(255, 255, 255, 0.065);
|
||||||
}
|
}
|
||||||
.card-header {
|
.card-header {
|
||||||
@apply -mx-[0.6rem] flex items-center justify-between border-b border-b-[#e1e7eb] p-4;
|
border-bottom-color: #3f4042;
|
||||||
}
|
|
||||||
.card-footer {
|
|
||||||
@apply -mx-[0.6rem] mt-2 flex items-center justify-center border-t border-t-[#e1e7eb] py-4;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-mode="dark"] {
|
|
||||||
.card-border {
|
|
||||||
@apply border-[#3f4042] bg-[rgba(255,255,255,0.065)];
|
|
||||||
}
|
|
||||||
.card-header {
|
|
||||||
@apply border-b-[#3f4042];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,47 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { client } from "@/shared/api";
|
import { client } from "@/shared/api";
|
||||||
import { ENDPOINT, AUTH_USER_ID } from "@/shared/config";
|
|
||||||
import { getCookie, useUserStore } from "@/shared/lib";
|
|
||||||
import type { IUserInfo } from "@/shared/store";
|
import type { IUserInfo } from "@/shared/store";
|
||||||
|
import { getCookie, useUserStore } from "@/shared/lib";
|
||||||
|
import { ENDPOINT, AUTH_USER_ID } from "@/shared/config";
|
||||||
import { LoginApi } from "../api/login-service";
|
import { LoginApi } from "../api/login-service";
|
||||||
|
|
||||||
const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { setUserInfo } = useUserStore((state) => state);
|
const { userInfo, setUserInfo } = useUserStore((state) => state);
|
||||||
|
|
||||||
useQuery({
|
async function authCheck() {
|
||||||
queryKey: [ENDPOINT.USER_SERVICE.USERS],
|
const userId = getCookie(AUTH_USER_ID);
|
||||||
queryFn: async () => {
|
if (!userId) {
|
||||||
|
throw new Error("Missing required authentication tokens");
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await client.get<IUserInfo>(
|
||||||
|
`${ENDPOINT.USER_SERVICE.USERS}/${userId}`,
|
||||||
|
);
|
||||||
|
if (!userInfo) setUserInfo(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const userId = getCookie(AUTH_USER_ID);
|
await authCheck();
|
||||||
|
|
||||||
if (!userId) {
|
|
||||||
throw new Error("Missing required authentication tokens");
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await client.get<IUserInfo>(
|
|
||||||
`${ENDPOINT.USER_SERVICE.USERS}/${userId}`,
|
|
||||||
);
|
|
||||||
setUserInfo(response.data);
|
|
||||||
return response;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await LoginApi.silentRefresh();
|
await LoginApi.silentRefresh();
|
||||||
|
await authCheck();
|
||||||
} catch (refreshError) {
|
} catch (refreshError) {
|
||||||
console.error("Token refresh failed:", refreshError);
|
console.error("Token refresh failed:", refreshError);
|
||||||
setUserInfo(null);
|
setUserInfo(null);
|
||||||
router.push("/auth/login");
|
router.push("/auth/login");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
})();
|
||||||
});
|
}, []);
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ import { CodeApi } from "../api/code-service";
|
|||||||
|
|
||||||
type CodeSelectProps = {
|
type CodeSelectProps = {
|
||||||
upCd: string;
|
upCd: string;
|
||||||
value?: string;
|
} & React.ComponentPropsWithoutRef<typeof Select>;
|
||||||
defaultValue?: string;
|
|
||||||
onValueChange?: (value: string) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
function CodeSelect({ upCd, defaultValue, ...props }: CodeSelectProps) {
|
function CodeSelect({ upCd, defaultValue, ...props }: CodeSelectProps) {
|
||||||
const { data: code } = useQuery({
|
const { data: code } = useQuery({
|
||||||
|
|||||||
+3
-3
@@ -2,16 +2,16 @@ import { client } from "@/shared/api";
|
|||||||
import { ENDPOINT } from "@/shared/config";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import {
|
import {
|
||||||
siteFormSchema,
|
siteFormSchema,
|
||||||
type ISiteInfo,
|
|
||||||
type SiteService,
|
type SiteService,
|
||||||
|
type SiteList,
|
||||||
type ISiteDetail,
|
type ISiteDetail,
|
||||||
type ISiteParams,
|
type ISiteParams,
|
||||||
type SiteFormData,
|
type SiteFormData,
|
||||||
} from "../model/site-interface";
|
} from "../model/site-interface";
|
||||||
|
|
||||||
export class SiteApiService implements SiteService {
|
export class SiteApiService implements SiteService {
|
||||||
public async siteInfo(params: ISiteParams): Promise<ISiteInfo> {
|
public async getSiteList(params: ISiteParams): Promise<SiteList> {
|
||||||
const response = await client.get<ISiteInfo>(
|
const response = await client.get<SiteList>(
|
||||||
`${ENDPOINT.CMS_SERVICE.SITES}`,
|
`${ENDPOINT.CMS_SERVICE.SITES}`,
|
||||||
{ params },
|
{ params },
|
||||||
);
|
);
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export { SiteApi } from "./api/site-service";
|
||||||
|
export {
|
||||||
|
siteFormSchema,
|
||||||
|
type ISiteParams,
|
||||||
|
type ISite,
|
||||||
|
type SiteFormData,
|
||||||
|
} from "./model/site-interface";
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
import type { IPageableParams, PageableList } from "@/shared/model";
|
||||||
|
|
||||||
|
export interface ISiteParams extends IPageableParams {
|
||||||
|
siteNm?: string;
|
||||||
|
siteKndCd?: string;
|
||||||
|
useYn?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ISite {
|
||||||
|
siteId: string;
|
||||||
|
siteNm: string;
|
||||||
|
siteKindCode: string;
|
||||||
|
bscSiteYn: string;
|
||||||
|
siteAddr: string;
|
||||||
|
useYn: string;
|
||||||
|
regDt: string;
|
||||||
|
rgTrNm: string;
|
||||||
|
dmnAddr: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ISiteDetail extends SiteFormData {
|
||||||
|
siteId: string;
|
||||||
|
siteKindNm: string;
|
||||||
|
basicSiteYn: string;
|
||||||
|
faxNumber: string;
|
||||||
|
regDt: string;
|
||||||
|
rgTr: string;
|
||||||
|
mdfcnDt: string;
|
||||||
|
mdFr: string;
|
||||||
|
rgTrNm: string;
|
||||||
|
mdFrNm: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const siteFormSchema = z.object({
|
||||||
|
siteId: z.string().max(2).nonempty(),
|
||||||
|
siteNm: z.string().max(100).nonempty(),
|
||||||
|
siteExpln: z.string().max(1000).nullable(),
|
||||||
|
siteKndCd: z.string().max(10).nonempty(),
|
||||||
|
siteAddr: z.string().max(2000).nullable(),
|
||||||
|
faxNo: z.string().max(100).nullable(),
|
||||||
|
telNo: z.string().max(1000).nullable(),
|
||||||
|
lwndCn: z.string().max(2000).nullable(),
|
||||||
|
bscSiteYn: z.string(),
|
||||||
|
bkmkIcon: z.string().max(100).nullable(),
|
||||||
|
useYn: z.string(),
|
||||||
|
siteSkn: z.string().max(10).nullable(),
|
||||||
|
dmnAddr: z.string().nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type SiteFormData = z.infer<typeof siteFormSchema>;
|
||||||
|
export type SiteList = PageableList<ISite[]>;
|
||||||
|
|
||||||
|
export interface SiteService {
|
||||||
|
getSiteList(params: ISiteParams): Promise<SiteList>;
|
||||||
|
siteDetail(siteId: string): Promise<ISiteDetail>;
|
||||||
|
modifySite(siteId: string, data: SiteFormData): Promise<void>;
|
||||||
|
createSite(data: SiteFormData): Promise<void>;
|
||||||
|
}
|
||||||
@@ -4,8 +4,10 @@ import Image from "next/image";
|
|||||||
import { images } from "@common/assets";
|
import { images } from "@common/assets";
|
||||||
import { LoginApi } from "@/entities/auth";
|
import { LoginApi } from "@/entities/auth";
|
||||||
import "./login.css";
|
import "./login.css";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
function LoginPage() {
|
function LoginPage() {
|
||||||
|
const router = useRouter();
|
||||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -13,7 +15,8 @@ function LoginPage() {
|
|||||||
const userId = formData.get("id") as string;
|
const userId = formData.get("id") as string;
|
||||||
const password = formData.get("password") as string;
|
const password = formData.get("password") as string;
|
||||||
|
|
||||||
LoginApi.login({ userId, password });
|
await LoginApi.login({ userId, password });
|
||||||
|
router.push("/site");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { client } from "@/shared/api";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import type { Menu, MenuService, TreeMenu } from "../model/menu-interface";
|
||||||
|
|
||||||
|
export class MenuApiService implements MenuService {
|
||||||
|
public async getTreeMenuList(siteId: string): Promise<Menu[]> {
|
||||||
|
const response = await client.get<Menu[]>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree`,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async modifyTreeMenu(siteId: string, data: TreeMenu[]): Promise<void> {
|
||||||
|
const response = await client.put<void>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree`,
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async modifyMenuName(menuCd: number, name: string): Promise<void> {
|
||||||
|
const response = await client.put<void>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}/${name}`,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MenuApi = new MenuApiService();
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { MenuPage } from "./ui/menu-page";
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import type { DropOptions, NodeModel } from "@minoru/react-dnd-treeview";
|
||||||
|
import type { Menu, TreeMenu } from "../model/menu-interface";
|
||||||
|
|
||||||
|
export const generateTreeData = (data: Menu[]): NodeModel<Menu>[] => {
|
||||||
|
return data.reduce<NodeModel<Menu>[]>((acc, menu) => {
|
||||||
|
const node: NodeModel<Menu> = {
|
||||||
|
id: menu.menuCd ?? 0,
|
||||||
|
parent: menu.parentId ?? 0,
|
||||||
|
text: menu.menuKornNm,
|
||||||
|
droppable: true,
|
||||||
|
data: menu,
|
||||||
|
};
|
||||||
|
|
||||||
|
acc.push(node);
|
||||||
|
|
||||||
|
if (menu.children?.length) {
|
||||||
|
acc.push(...generateTreeData(menu.children));
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const generateNewTreeData = (
|
||||||
|
treeData: NodeModel<Menu>[],
|
||||||
|
options: DropOptions<Menu>,
|
||||||
|
): TreeMenu | null => {
|
||||||
|
const { dragSourceId, dragSource, dropTargetId, dropTarget } = options;
|
||||||
|
|
||||||
|
if (!dragSource?.data) return null;
|
||||||
|
|
||||||
|
const siblings = treeData.filter((node) => node.parent === dropTargetId);
|
||||||
|
|
||||||
|
const newSortSeq =
|
||||||
|
siblings.findIndex((sibling) => sibling.id === dragSourceId) + 1;
|
||||||
|
|
||||||
|
const childNodes = treeData.filter(
|
||||||
|
(node) => node.parent === dragSourceId && node.data,
|
||||||
|
);
|
||||||
|
|
||||||
|
const baseNode = (node: NodeModel<Menu>): TreeMenu => {
|
||||||
|
if (!node.data) return {};
|
||||||
|
return {
|
||||||
|
menuCd: node.data?.menuCd,
|
||||||
|
name: node.data?.menuKornNm,
|
||||||
|
icon: node.data?.iconNm,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const treeMenu: TreeMenu = {
|
||||||
|
...baseNode(dragSource),
|
||||||
|
parentId: dropTargetId === 0 ? null : (dropTargetId as number),
|
||||||
|
sortSeq: newSortSeq,
|
||||||
|
levelNo: (dropTarget?.data?.levelNo ?? 0) + 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const result: TreeMenu = {
|
||||||
|
...treeMenu,
|
||||||
|
children: childNodes.map((child) => ({
|
||||||
|
...baseNode(child),
|
||||||
|
parentId: child.data?.parentId === 0 ? null : (dropTargetId as number),
|
||||||
|
sortSeq: child.data?.sortSeq,
|
||||||
|
levelNo: (treeMenu?.levelNo ?? 0) + 1,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const handleSelectNode =
|
||||||
|
(callback: (node: NodeModel<Menu>) => void) => (node: NodeModel<Menu>) => {
|
||||||
|
callback(node);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const handleDropNode =
|
||||||
|
(callback: (newTree: TreeMenu) => void) =>
|
||||||
|
(newTree: NodeModel<Menu>[], options: DropOptions<Menu>) => {
|
||||||
|
const newTreeData = generateNewTreeData(newTree, options);
|
||||||
|
if (!newTreeData) return;
|
||||||
|
callback(newTreeData);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const handleNodeTextChange =
|
||||||
|
(treeData: NodeModel<Menu>[]) =>
|
||||||
|
(callback: (newTree: NodeModel<Menu>[]) => void) =>
|
||||||
|
(id: NodeModel["id"], value: string) => {
|
||||||
|
const newTree = treeData.map((node) => {
|
||||||
|
if (node.id === id) {
|
||||||
|
return {
|
||||||
|
...node,
|
||||||
|
text: value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
callback(newTree);
|
||||||
|
};
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const MENU_TYPE = {
|
||||||
|
EMPTY: "EMPTY",
|
||||||
|
CONTENTS: "CONTENTS",
|
||||||
|
BOARD: "BOARD",
|
||||||
|
INSIDE: "INSIDE",
|
||||||
|
OUTSIDE: "OUTSIDE",
|
||||||
|
BOTTOM: "BOTTOM",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type MenuType = (typeof MENU_TYPE)[keyof typeof MENU_TYPE];
|
||||||
|
|
||||||
|
export interface TreeMenu {
|
||||||
|
menuCd?: number;
|
||||||
|
name?: string;
|
||||||
|
sortSeq?: number;
|
||||||
|
parentId?: number | null;
|
||||||
|
levelNo?: number;
|
||||||
|
icon?: string;
|
||||||
|
children?: TreeMenu[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Menu extends Omit<TreeMenu, "name" | "icon" | "children"> {
|
||||||
|
menuKornNm: string;
|
||||||
|
menuEngNm: string;
|
||||||
|
iconNm: string;
|
||||||
|
children: Menu[];
|
||||||
|
urlPath: string;
|
||||||
|
menuLnkgTypeCd: string;
|
||||||
|
menuLnkgSn: number;
|
||||||
|
qrcd: string;
|
||||||
|
useYn: string;
|
||||||
|
otptYn: string;
|
||||||
|
requiredUrlPath: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const menuFormSchema = z.object({
|
||||||
|
siteId: z.string(),
|
||||||
|
menuKornNm: z.string(),
|
||||||
|
menuSubKornNm: z.string().nullish(),
|
||||||
|
menuEngNm: z.string().nullish(),
|
||||||
|
menuSubEngNm: z.string().nullish(),
|
||||||
|
levelNo: z.number(),
|
||||||
|
urlPath: z.string().nullish(),
|
||||||
|
iconNm: z.string().nullish(),
|
||||||
|
menuLnkgTypeCd: z.enum([
|
||||||
|
MENU_TYPE.EMPTY,
|
||||||
|
MENU_TYPE.CONTENTS,
|
||||||
|
MENU_TYPE.BOARD,
|
||||||
|
MENU_TYPE.INSIDE,
|
||||||
|
MENU_TYPE.OUTSIDE,
|
||||||
|
MENU_TYPE.BOTTOM,
|
||||||
|
]),
|
||||||
|
menuLnkgSn: z.number().nullish(),
|
||||||
|
otptYn: z.enum(["Y", "N"]).default("Y").nullish(),
|
||||||
|
prntMenuCd: z.number().nullish(),
|
||||||
|
sortSeq: z.number(),
|
||||||
|
evlUseYn: z.enum(["Y", "N"]).nullish(),
|
||||||
|
qrcd: z.string().nullish(),
|
||||||
|
useYn: z.enum(["Y", "N"]).default("Y").nullish(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type MenuFormData = z.infer<typeof menuFormSchema>;
|
||||||
|
|
||||||
|
export interface MenuService {
|
||||||
|
getTreeMenuList: (siteId: string) => Promise<Menu[]>;
|
||||||
|
modifyTreeMenu: (siteId: string, data: TreeMenu[]) => Promise<void>;
|
||||||
|
modifyMenuName: (menuCd: number, name: string) => Promise<void>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import {
|
||||||
|
IconFinder,
|
||||||
|
Input,
|
||||||
|
Label,
|
||||||
|
RadioGroup,
|
||||||
|
RadioGroupItem,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
} from "@common/components";
|
||||||
|
import {
|
||||||
|
FormItem,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/shared/ui/form";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
|
||||||
|
export function BaseBottomMenuForm({
|
||||||
|
form,
|
||||||
|
}: {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
}) {
|
||||||
|
const handleIconClick = (icon: string) => {
|
||||||
|
form.setValue("iconNm", icon);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴 서브명</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="menuSubKornNm"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
className="!text-[1.3rem]"
|
||||||
|
placeholder="메뉴 서브명을 입력하십시오."
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴 아이콘</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
|
{form.watch("iconNm")}
|
||||||
|
</div>
|
||||||
|
<IconFinder handleClick={handleIconClick} />
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>출력 여부</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="otptYn"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="Y" id="otptY" />
|
||||||
|
<Label htmlFor="otptY">출력</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="N" id="otptN" />
|
||||||
|
<Label htmlFor="otptN">출력안함</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>사용 여부</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="useYn"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import {
|
||||||
|
Input,
|
||||||
|
Label,
|
||||||
|
RadioGroup,
|
||||||
|
RadioGroupItem,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
} from "@common/components";
|
||||||
|
import {
|
||||||
|
FormItem,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/shared/ui/form";
|
||||||
|
import { MENU_TYPE, type MenuFormData } from "../model/menu-interface";
|
||||||
|
|
||||||
|
interface BaseMenuFormProps {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
menuId?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function BaseMenuForm({ form, menuId }: BaseMenuFormProps) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴ID</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
|
{menuId}
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴명</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="menuKornNm"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
className="!text-[1.3rem]"
|
||||||
|
placeholder="메뉴명을 입력하십시오."
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴 영문명</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="menuEngNm"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
|
className="!text-[1.3rem]"
|
||||||
|
placeholder="메뉴 영문명을 입력하십시오."
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴 유형</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="menuLnkgTypeCd"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
{Object.entries(MENU_TYPE).map(([key, value]) => (
|
||||||
|
<div
|
||||||
|
key={key}
|
||||||
|
className="flex items-center space-x-2"
|
||||||
|
>
|
||||||
|
<RadioGroupItem
|
||||||
|
value={value}
|
||||||
|
id={`menuType${key}`}
|
||||||
|
/>
|
||||||
|
<Label htmlFor={`menuType${key}`}>
|
||||||
|
{key === "EMPTY" && "빈메뉴"}
|
||||||
|
{key === "CONTENTS" && "콘텐츠"}
|
||||||
|
{key === "BOARD" && "게시판"}
|
||||||
|
{key === "INSIDE" && "내부링크"}
|
||||||
|
{key === "OUTSIDE" && "외부링크"}
|
||||||
|
{key === "BOTTOM" && "하단메뉴"}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import {
|
||||||
|
Label,
|
||||||
|
RadioGroup,
|
||||||
|
RadioGroupItem,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
} from "@common/components";
|
||||||
|
import {
|
||||||
|
FormItem,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/shared/ui/form";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseBottomMenuForm } from "./base-bottom-menu-form";
|
||||||
|
|
||||||
|
export function BoardMenuForm({ form }: { form: UseFormReturn<MenuFormData> }) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>게시판</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
|
{form.watch("menuLnkgSn")}
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>연결 형태</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="evlUseYn"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="self" id="self" />
|
||||||
|
<Label htmlFor="self">현재창</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="blank" id="blank" />
|
||||||
|
<Label htmlFor="blank">새창</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴 평가 사용 여부</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="evlUseYn"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="Y" id="evlUseY" />
|
||||||
|
<Label htmlFor="evlUseY">사용</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="N" id="evlUseN" />
|
||||||
|
<Label htmlFor="evlUseN">사용안함</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<BaseBottomMenuForm form={form} />
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>QR코드</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="qrcd"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="Y" id="qrcdY" />
|
||||||
|
<Label htmlFor="qrcdY">사용</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="N" id="qrcdN" />
|
||||||
|
<Label htmlFor="qrcdN">사용안함</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>담당자</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
|
{form.watch("menuLnkgSn")}
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import { Table, TableBody } from "@common/components";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseBottomMenuForm } from "./base-bottom-menu-form";
|
||||||
|
|
||||||
|
export function BottomMenuForm({
|
||||||
|
form,
|
||||||
|
}: {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<BaseBottomMenuForm form={form} />
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import {
|
||||||
|
Label,
|
||||||
|
RadioGroup,
|
||||||
|
RadioGroupItem,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
} from "@common/components";
|
||||||
|
import {
|
||||||
|
FormItem,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/shared/ui/form";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseBottomMenuForm } from "./base-bottom-menu-form";
|
||||||
|
|
||||||
|
export function ContentMenuForm({
|
||||||
|
form,
|
||||||
|
}: {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>콘텐츠</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
|
{form.watch("menuLnkgSn")}
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>연결 형태</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="evlUseYn"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="self" id="self" />
|
||||||
|
<Label htmlFor="self">현재창</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="blank" id="blank" />
|
||||||
|
<Label htmlFor="blank">새창</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>메뉴 평가 사용 여부</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="evlUseYn"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="Y" id="evlUseY" />
|
||||||
|
<Label htmlFor="evlUseY">사용</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="N" id="evlUseN" />
|
||||||
|
<Label htmlFor="evlUseN">사용안함</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<BaseBottomMenuForm form={form} />
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>QR코드</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="qrcd"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value ?? ""}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="Y" id="qrcdY" />
|
||||||
|
<Label htmlFor="qrcdY">사용</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem value="N" id="qrcdN" />
|
||||||
|
<Label htmlFor="qrcdN">사용안함</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>담당자</TableHead>
|
||||||
|
<TableCell className="border">
|
||||||
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
|
{form.watch("menuLnkgSn")}
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import { Table, TableBody } from "@common/components";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseBottomMenuForm } from "./base-bottom-menu-form";
|
||||||
|
|
||||||
|
export function EmptyMenuForm({ form }: { form: UseFormReturn<MenuFormData> }) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<BaseBottomMenuForm form={form} />
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import { Table, TableBody } from "@common/components";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseBottomMenuForm } from "./base-bottom-menu-form";
|
||||||
|
|
||||||
|
export function InsideMenuForm({
|
||||||
|
form,
|
||||||
|
}: {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<BaseBottomMenuForm form={form} />
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import { Button } from "@common/components";
|
||||||
|
import { Form } from "@/shared/ui/form";
|
||||||
|
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||||
|
import { MENU_TYPE, type MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseMenuForm } from "./base-menu-form";
|
||||||
|
import { EmptyMenuForm } from "./empty-menu-form";
|
||||||
|
import { ContentMenuForm } from "./content-menu-form";
|
||||||
|
import { BoardMenuForm } from "./board-menu-form";
|
||||||
|
import { InsideMenuForm } from "./inside-menu-form";
|
||||||
|
import { OutsideMenuForm } from "./outside-menu-form";
|
||||||
|
import { BottomMenuForm } from "./bottom-menu-form";
|
||||||
|
|
||||||
|
interface MenuFormProps {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
menuId?: number;
|
||||||
|
handleSave: (data: MenuFormData) => Promise<void>;
|
||||||
|
handleDelete?: () => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MenuForm({
|
||||||
|
form,
|
||||||
|
menuId,
|
||||||
|
handleSave,
|
||||||
|
handleDelete,
|
||||||
|
}: MenuFormProps) {
|
||||||
|
const isModifyMode = !!menuId;
|
||||||
|
const { confirm } = useConfirm();
|
||||||
|
const [onConfirm, setOnConfirm] = useState(false);
|
||||||
|
|
||||||
|
const onSubmit = async (data: MenuFormData) => {
|
||||||
|
const confirmMessage = isModifyMode
|
||||||
|
? "수정하시겠습니까?"
|
||||||
|
: "저장하시겠습니까?";
|
||||||
|
|
||||||
|
setOnConfirm(true);
|
||||||
|
if (await confirm(confirmMessage)) {
|
||||||
|
setOnConfirm(false);
|
||||||
|
handleSave(data);
|
||||||
|
}
|
||||||
|
setOnConfirm(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDelete = async () => {
|
||||||
|
setOnConfirm(true);
|
||||||
|
if (await confirm("삭제하시겠습니까?")) {
|
||||||
|
setOnConfirm(false);
|
||||||
|
handleDelete?.();
|
||||||
|
}
|
||||||
|
setOnConfirm(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const menuType = form.watch("menuLnkgTypeCd");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={form.handleSubmit(onSubmit)}>
|
||||||
|
<div className="card card-border">
|
||||||
|
<div className="card-header">
|
||||||
|
<h3 className="text-2xl font-medium text-label">
|
||||||
|
메뉴 등록/수정
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div className="card">
|
||||||
|
<BaseMenuForm form={form} menuId={menuId} />
|
||||||
|
<div className="-mt-[0.1rem]">
|
||||||
|
{renderMenuTypeComponent(menuType, form)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-center gap-4 pb-12 pt-10">
|
||||||
|
<Button size="lg" type="submit">
|
||||||
|
저장
|
||||||
|
</Button>
|
||||||
|
{isModifyMode && (
|
||||||
|
<Button size="lg" color="red" type="button" onClick={onDelete}>
|
||||||
|
삭제
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
<ConfirmDialog open={onConfirm} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderMenuTypeComponent(
|
||||||
|
menuType: string,
|
||||||
|
form: UseFormReturn<MenuFormData>,
|
||||||
|
) {
|
||||||
|
switch (menuType) {
|
||||||
|
case MENU_TYPE.EMPTY:
|
||||||
|
return <EmptyMenuForm form={form} />;
|
||||||
|
case MENU_TYPE.CONTENTS:
|
||||||
|
return <ContentMenuForm form={form} />;
|
||||||
|
case MENU_TYPE.BOARD:
|
||||||
|
return <BoardMenuForm form={form} />;
|
||||||
|
case MENU_TYPE.INSIDE:
|
||||||
|
return <InsideMenuForm form={form} />;
|
||||||
|
case MENU_TYPE.OUTSIDE:
|
||||||
|
return <OutsideMenuForm form={form} />;
|
||||||
|
case MENU_TYPE.BOTTOM:
|
||||||
|
return <BottomMenuForm form={form} />;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import type { NodeModel } from "@minoru/react-dnd-treeview";
|
||||||
|
import { cn } from "@common/components/lib";
|
||||||
|
import { Button, Input } from "@common/components/ui";
|
||||||
|
import type { Menu } from "../model/menu-interface";
|
||||||
|
import { MenuApi } from "../api/menu-service";
|
||||||
|
|
||||||
|
type MenuNodeProps = {
|
||||||
|
node: NodeModel<Menu>;
|
||||||
|
depth: number;
|
||||||
|
isOpen: boolean;
|
||||||
|
isSelected: boolean;
|
||||||
|
onToggle: (id: NodeModel["id"]) => void;
|
||||||
|
onSelect: (node: NodeModel<Menu>) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function MenuNode({
|
||||||
|
node,
|
||||||
|
depth,
|
||||||
|
isOpen,
|
||||||
|
isSelected,
|
||||||
|
onToggle,
|
||||||
|
onSelect,
|
||||||
|
}: MenuNodeProps) {
|
||||||
|
const { id, text, data } = node;
|
||||||
|
const indent = depth * 10 + 5;
|
||||||
|
|
||||||
|
const { mutateAsync: modifyMenuName } = useMutation({
|
||||||
|
mutationFn: (nodeName: string) => {
|
||||||
|
const encodedName = encodeURIComponent(nodeName);
|
||||||
|
return MenuApi.modifyMenuName(id as number, encodedName);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [editMode, setEditMode] = useState(false);
|
||||||
|
const [nodeName, setNodeName] = useState(text);
|
||||||
|
|
||||||
|
const handleToggle = () => onToggle(id);
|
||||||
|
const handleSelect = () => onSelect(node);
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
await modifyMenuName(nodeName);
|
||||||
|
setEditMode(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{ paddingInlineStart: indent }}
|
||||||
|
className={cn(
|
||||||
|
"group flex cursor-pointer items-center justify-between gap-2 rounded-sm p-2 hover:bg-accent",
|
||||||
|
isSelected && "!bg-[rgba(32,148,250,0.2)]",
|
||||||
|
)}
|
||||||
|
onClick={handleSelect}
|
||||||
|
>
|
||||||
|
<div className="flex items-center">
|
||||||
|
{editMode ? (
|
||||||
|
<>
|
||||||
|
<Input
|
||||||
|
value={nodeName}
|
||||||
|
onChange={(e) => setNodeName(e.target.value)}
|
||||||
|
className="h-[2.5rem] !text-[1.3rem] text-foreground"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{data?.children?.length && (
|
||||||
|
<i
|
||||||
|
className={cn(
|
||||||
|
"diveicon di-arrow-forward mr-2 text-base text-label",
|
||||||
|
isOpen && "rotate-90",
|
||||||
|
)}
|
||||||
|
onClick={handleToggle}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<span className="text-[1.4rem] font-medium text-label">{text}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{editMode ? (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="size-8 !bg-transparent"
|
||||||
|
onClick={handleSave}
|
||||||
|
>
|
||||||
|
<i className="diveicon di-check text-2xl" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="size-8 !bg-transparent"
|
||||||
|
onClick={() => {
|
||||||
|
setEditMode(false);
|
||||||
|
setNodeName(text);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<i className="diveicon di-x" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="invisible !bg-transparent group-hover:visible"
|
||||||
|
onClick={() => setEditMode(true)}
|
||||||
|
>
|
||||||
|
<i className="diveicon di-pencil" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { MenuNode };
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@common/components/ui";
|
||||||
|
import { SiteApi } from "@/entities/site";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import { PageLayout } from "@/shared/ui/page-layout";
|
||||||
|
import { MenuApi } from "../api/menu-service";
|
||||||
|
import {
|
||||||
|
MENU_TYPE,
|
||||||
|
menuFormSchema,
|
||||||
|
type MenuFormData,
|
||||||
|
} from "../model/menu-interface";
|
||||||
|
import { MenuTree } from "./menu-tree";
|
||||||
|
import { MenuForm } from "./menu-form";
|
||||||
|
import { generateTreeData } from "../lib/utils";
|
||||||
|
|
||||||
|
function MenuPage() {
|
||||||
|
const [siteId, setSiteId] = useState("");
|
||||||
|
|
||||||
|
const { data: treeData } = useQuery({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.MENUS, siteId],
|
||||||
|
queryFn: () => MenuApi.getTreeMenuList(siteId),
|
||||||
|
select: (data) => generateTreeData(data),
|
||||||
|
enabled: !!siteId,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data: options } = useQuery({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||||
|
queryFn: () => SiteApi.getSiteList({}),
|
||||||
|
select: (data) =>
|
||||||
|
data.content.map((site) => ({
|
||||||
|
label: site.siteNm,
|
||||||
|
value: site.siteId,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = useForm<MenuFormData>({
|
||||||
|
resolver: zodResolver(menuFormSchema),
|
||||||
|
defaultValues: {
|
||||||
|
menuLnkgTypeCd: MENU_TYPE.EMPTY,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleSave = async (data: MenuFormData) => {
|
||||||
|
console.log(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async () => {};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageLayout pageTitle="메뉴 관리">
|
||||||
|
<div className="card flex gap-2">
|
||||||
|
<div className="card card-border w-[24rem]">
|
||||||
|
<Select value={siteId} onValueChange={setSiteId}>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="선택하세요" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{options?.map((option) => (
|
||||||
|
<SelectItem key={option.value} value={option.value}>
|
||||||
|
{option.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
{treeData && (
|
||||||
|
<>
|
||||||
|
<div className="my-4 flex gap-2">
|
||||||
|
<Button size="sm" color="primary" className="flex-1">
|
||||||
|
메뉴 추가
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" color="red" className="flex-1">
|
||||||
|
메뉴 삭제
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="card card-border !mx-0">
|
||||||
|
<MenuTree treeData={treeData ?? []} siteId={siteId} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="card card-border flex-1">
|
||||||
|
<MenuForm
|
||||||
|
form={form}
|
||||||
|
handleSave={handleSave}
|
||||||
|
handleDelete={handleDelete}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { MenuPage };
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { DndProvider } from "react-dnd";
|
||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
Tree,
|
||||||
|
MultiBackend,
|
||||||
|
getBackendOptions,
|
||||||
|
type NodeModel,
|
||||||
|
} from "@minoru/react-dnd-treeview";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import { MenuApi } from "../api/menu-service";
|
||||||
|
import type { Menu, TreeMenu } from "../model/menu-interface";
|
||||||
|
import { handleDropNode, handleSelectNode } from "../lib/utils";
|
||||||
|
import { MenuNode } from "./menu-node";
|
||||||
|
|
||||||
|
type MenuTreeProps = {
|
||||||
|
treeData: NodeModel<Menu>[];
|
||||||
|
siteId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
function MenuTree({ treeData, siteId }: MenuTreeProps) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const { mutate: modifyTreeMenu } = useMutation({
|
||||||
|
mutationFn: (newTree: TreeMenu) =>
|
||||||
|
MenuApi.modifyTreeMenu(siteId, [newTree]),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.MENUS],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [selectedNode, setSelectedNode] = useState<NodeModel<Menu> | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DndProvider backend={MultiBackend} options={getBackendOptions()}>
|
||||||
|
<Tree
|
||||||
|
tree={treeData}
|
||||||
|
rootId={0}
|
||||||
|
render={(node: NodeModel<Menu>, { depth, isOpen, onToggle }) => (
|
||||||
|
<MenuNode
|
||||||
|
node={node}
|
||||||
|
depth={depth}
|
||||||
|
isOpen={isOpen}
|
||||||
|
isSelected={selectedNode?.id === node.id}
|
||||||
|
onToggle={onToggle}
|
||||||
|
onSelect={handleSelectNode(setSelectedNode)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
onDrop={handleDropNode(modifyTreeMenu)}
|
||||||
|
classes={{
|
||||||
|
root: "p-4",
|
||||||
|
container: "flex flex-col",
|
||||||
|
dropTarget: "!bg-[rgba(32,148,250,0.5)] rounded-sm",
|
||||||
|
placeholder: "relative",
|
||||||
|
}}
|
||||||
|
sort={false}
|
||||||
|
dropTargetOffset={5}
|
||||||
|
insertDroppableFirst={false}
|
||||||
|
canDrop={(_, { dragSource, dropTargetId }) => {
|
||||||
|
if (dragSource?.parent === dropTargetId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
placeholderRender={(_, { depth }) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="absolute right-0 top-0 h-[0.2rem] bg-primary"
|
||||||
|
style={{ left: depth * 10 + 5 }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</DndProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { MenuTree };
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
|
import { Table, TableBody } from "@common/components";
|
||||||
|
import type { MenuFormData } from "../model/menu-interface";
|
||||||
|
import { BaseBottomMenuForm } from "./base-bottom-menu-form";
|
||||||
|
|
||||||
|
export function OutsideMenuForm({
|
||||||
|
form,
|
||||||
|
}: {
|
||||||
|
form: UseFormReturn<MenuFormData>;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Table variant="secondary">
|
||||||
|
<colgroup>
|
||||||
|
<col width="20%" />
|
||||||
|
<col width="80%" />
|
||||||
|
</colgroup>
|
||||||
|
<TableBody>
|
||||||
|
<BaseBottomMenuForm form={form} />
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { client } from "@/shared/api";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import type {
|
||||||
|
Domain,
|
||||||
|
DomainService,
|
||||||
|
DomainList,
|
||||||
|
IDomainParams,
|
||||||
|
} from "../model/domain-interface";
|
||||||
|
|
||||||
|
export class DomainApiService implements DomainService {
|
||||||
|
public async getDomainList(params: IDomainParams): Promise<DomainList> {
|
||||||
|
const response = await client.get<DomainList>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.DOMAINS}`,
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async saveDomainList(body: Domain[]): Promise<void> {
|
||||||
|
const response = await client.post<void>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.DOMAINS}`,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DomainApi = new DomainApiService();
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { client } from "@/shared/api";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import type { IIpParams, IP, IpList, IpService } from "../model/ip-interface";
|
||||||
|
|
||||||
|
export class IpApiService implements IpService {
|
||||||
|
public async getIpList(params: IIpParams): Promise<IpList> {
|
||||||
|
const response = await client.get<IpList>(`${ENDPOINT.CMS_SERVICE.IPS}`, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async saveIpList(body: IP[]): Promise<void> {
|
||||||
|
const response = await client.post<void>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.IPS}`,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const IpApi = new IpApiService();
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
import type { IPageableParams, PageableList } from "@/shared/model";
|
||||||
|
|
||||||
|
export interface IDomainParams extends IPageableParams {
|
||||||
|
keywordType?: string;
|
||||||
|
keyword?: string;
|
||||||
|
siteId?: string;
|
||||||
|
useYn?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const domainSchema = z.object({
|
||||||
|
siteDmnNo: z.number().nullish(),
|
||||||
|
siteId: z.string(),
|
||||||
|
dmnAddr: z.string().nonempty(),
|
||||||
|
useYn: z.string(),
|
||||||
|
rprsDmnYn: z.string(),
|
||||||
|
mode: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const domainFormSchema = z.object({
|
||||||
|
domains: z.array(domainSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Domain = z.infer<typeof domainSchema>;
|
||||||
|
export type DomainFormData = z.infer<typeof domainFormSchema>;
|
||||||
|
export type DomainList = PageableList<Domain[]>;
|
||||||
|
|
||||||
|
export interface DomainService {
|
||||||
|
getDomainList(params: IDomainParams): Promise<DomainList>;
|
||||||
|
saveDomainList(body: Domain[]): Promise<void>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
import type { IPageableParams, PageableList } from "@/shared/model";
|
||||||
|
|
||||||
|
export interface IIpParams extends IPageableParams {
|
||||||
|
siteId: string;
|
||||||
|
ipAddr?: string;
|
||||||
|
prmYn?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ipSchema = z.object({
|
||||||
|
mngNo: z.number().nullish(),
|
||||||
|
siteId: z.string(),
|
||||||
|
ipAddr: z.string().nonempty(),
|
||||||
|
prmYn: z.string(),
|
||||||
|
mode: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ipFormSchema = z.object({
|
||||||
|
ips: z.array(ipSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type IP = z.infer<typeof ipSchema>;
|
||||||
|
export type IPFormData = z.infer<typeof ipFormSchema>;
|
||||||
|
export type IpList = PageableList<IP[]>;
|
||||||
|
|
||||||
|
export interface IpService {
|
||||||
|
getIpList(params: IIpParams): Promise<IpList>;
|
||||||
|
saveIpList(body: IP[]): Promise<void>;
|
||||||
|
}
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
export interface ISiteParams {
|
|
||||||
siteNm: string;
|
|
||||||
siteKndCd: string;
|
|
||||||
useYn: string;
|
|
||||||
page: number;
|
|
||||||
size: number;
|
|
||||||
sort: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISite {
|
|
||||||
siteId: string;
|
|
||||||
siteNm: string;
|
|
||||||
siteKindCode: string;
|
|
||||||
bscSiteYn: string;
|
|
||||||
siteAddr: string;
|
|
||||||
useYn: string;
|
|
||||||
regDt: string;
|
|
||||||
rgTrNm: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISiteInfo {
|
|
||||||
totalPages: number;
|
|
||||||
totalElements: number;
|
|
||||||
number: number;
|
|
||||||
sort: {
|
|
||||||
empty: boolean;
|
|
||||||
sorted: boolean;
|
|
||||||
unsorted: boolean;
|
|
||||||
};
|
|
||||||
size: number;
|
|
||||||
content: ISite[];
|
|
||||||
pageable: {
|
|
||||||
sort: {
|
|
||||||
empty: boolean;
|
|
||||||
sorted: boolean;
|
|
||||||
unsorted: boolean;
|
|
||||||
};
|
|
||||||
offset: number;
|
|
||||||
pageNumber: number;
|
|
||||||
pageSize: number;
|
|
||||||
paged: boolean;
|
|
||||||
unpaged: boolean;
|
|
||||||
};
|
|
||||||
numberOfElements: number;
|
|
||||||
first: boolean;
|
|
||||||
last: boolean;
|
|
||||||
empty: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISiteDetail extends SiteFormData {
|
|
||||||
siteId: string;
|
|
||||||
siteKindNm: string;
|
|
||||||
basicSiteYn: string;
|
|
||||||
faxNumber: string;
|
|
||||||
regDt: string;
|
|
||||||
rgTr: string;
|
|
||||||
mdfcnDt: string;
|
|
||||||
mdFr: string;
|
|
||||||
rgTrNm: string;
|
|
||||||
mdFrNm: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const siteFormSchema = z.object({
|
|
||||||
siteId: z.string().max(2).nonempty(),
|
|
||||||
siteNm: z.string().max(100).nonempty(),
|
|
||||||
siteExpln: z.string().max(1000).optional(),
|
|
||||||
siteKndCd: z.string().max(10).nonempty(),
|
|
||||||
siteAddr: z.string().max(2000).optional(),
|
|
||||||
faxNo: z.string().max(100).optional(),
|
|
||||||
telNo: z.string().max(1000).optional(),
|
|
||||||
lwndCn: z.string().max(2000).optional(),
|
|
||||||
bscSiteYn: z.string(),
|
|
||||||
bkmkIcon: z.string().max(100).optional(),
|
|
||||||
useYn: z.string(),
|
|
||||||
siteSkn: z.string().max(10).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type SiteFormData = z.infer<typeof siteFormSchema>;
|
|
||||||
|
|
||||||
export interface SiteService {
|
|
||||||
siteInfo(query: ISiteParams): Promise<ISiteInfo>;
|
|
||||||
siteDetail(siteId: string): Promise<ISiteDetail>;
|
|
||||||
modifySite(siteId: string, data: SiteFormData): Promise<void>;
|
|
||||||
createSite(data: SiteFormData): Promise<void>;
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { createColumnHelper } from "@tanstack/react-table";
|
import { createColumnHelper } from "@tanstack/react-table";
|
||||||
import type { ISite } from "./site-interface";
|
import type { ISite } from "@/entities/site";
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<ISite>();
|
const columnHelper = createColumnHelper<ISite>();
|
||||||
|
|
||||||
@@ -17,8 +17,8 @@ const columns = [
|
|||||||
id: "siteNm",
|
id: "siteNm",
|
||||||
header: "사이트명",
|
header: "사이트명",
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor("siteAddr", {
|
columnHelper.accessor("dmnAddr", {
|
||||||
id: "siteAddr",
|
id: "dmnAddr",
|
||||||
header: "대표 URL",
|
header: "대표 URL",
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor("bscSiteYn", {
|
columnHelper.accessor("bscSiteYn", {
|
||||||
|
|||||||
@@ -1,53 +1,46 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { SiteApi } from "../api/site-service";
|
import { SiteApi, siteFormSchema, type SiteFormData } from "@/entities/site";
|
||||||
import { siteFormSchema, type SiteFormData } from "../model/site-interface";
|
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||||
import { SitePageLayout } from "./layout";
|
import { PageLayout } from "@/shared/ui/page-layout";
|
||||||
import { SiteForm } from "./site-form";
|
import { SiteForm } from "./site-form";
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogClose,
|
|
||||||
DialogContent,
|
|
||||||
DialogFooter,
|
|
||||||
} from "@common/components/ui";
|
|
||||||
|
|
||||||
function CreatePage() {
|
function CreatePage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { setMessage: alert } = useAlertStore((state) => state);
|
||||||
const { mutateAsync: createSite } = useMutation({
|
const { mutateAsync: createSite } = useMutation({
|
||||||
mutationFn: (data: SiteFormData) => SiteApi.createSite(data),
|
mutationFn: (data: SiteFormData) => SiteApi.createSite(data),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setIsCreateSuccess(true);
|
alert("등록되었습니다.", router.back);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const [isCreateSuccess, setIsCreateSuccess] = useState(false);
|
|
||||||
|
|
||||||
const form = useForm<SiteFormData>({
|
const form = useForm<SiteFormData>({
|
||||||
resolver: zodResolver(siteFormSchema),
|
resolver: zodResolver(siteFormSchema),
|
||||||
|
defaultValues: {
|
||||||
|
siteId: "",
|
||||||
|
siteNm: "",
|
||||||
|
siteExpln: "",
|
||||||
|
siteKndCd: "",
|
||||||
|
siteAddr: "",
|
||||||
|
faxNo: "",
|
||||||
|
telNo: "",
|
||||||
|
lwndCn: "",
|
||||||
|
bscSiteYn: "",
|
||||||
|
bkmkIcon: "",
|
||||||
|
useYn: "",
|
||||||
|
siteSkn: "",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SitePageLayout>
|
<PageLayout pageTitle="사이트 관리">
|
||||||
<SiteForm form={form} handleSave={createSite} />
|
<SiteForm form={form} handleSave={createSite} />
|
||||||
<Dialog open={isCreateSuccess} onOpenChange={() => router.back()}>
|
</PageLayout>
|
||||||
<DialogContent aria-describedby={undefined}>
|
|
||||||
<div className="py-10">
|
|
||||||
<p className="text-center text-[1.4rem]">등록되었습니다.</p>
|
|
||||||
</div>
|
|
||||||
<DialogFooter className="!justify-center">
|
|
||||||
<DialogClose asChild>
|
|
||||||
<Button>확인</Button>
|
|
||||||
</DialogClose>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
</SitePageLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||||
|
import { useForm, useFieldArray } from "react-hook-form";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
@@ -13,197 +17,304 @@ import {
|
|||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
Input,
|
Input,
|
||||||
Checkbox,
|
RadioGroup,
|
||||||
Select,
|
RadioGroupItem,
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
Checkbox,
|
||||||
} from "@common/components";
|
} from "@common/components";
|
||||||
|
import {
|
||||||
export type Domain = {
|
Form,
|
||||||
id: number;
|
FormControl,
|
||||||
domainUrl: string;
|
FormField,
|
||||||
isRepresentative: boolean;
|
FormItem,
|
||||||
isActive: "true" | "false";
|
FormMessage,
|
||||||
};
|
} from "@/shared/ui/form";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import { DomainApi } from "../api/domain-service";
|
||||||
|
import {
|
||||||
|
domainFormSchema,
|
||||||
|
type Domain,
|
||||||
|
type DomainFormData,
|
||||||
|
} from "../model/domain-interface";
|
||||||
|
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||||
|
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||||
|
|
||||||
type DomainManagementDialogProps = {
|
type DomainManagementDialogProps = {
|
||||||
triggerDisabled?: boolean;
|
siteId: string;
|
||||||
handleSave: (rows: Domain[]) => void;
|
open?: boolean;
|
||||||
|
onOpenChange?: (open: boolean) => void;
|
||||||
|
handleSaveDomain?: (rows: Domain[]) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
function DomainManagementDialog({
|
function DomainManagementDialog({
|
||||||
triggerDisabled,
|
siteId,
|
||||||
handleSave,
|
handleSaveDomain,
|
||||||
|
...props
|
||||||
}: DomainManagementDialogProps) {
|
}: DomainManagementDialogProps) {
|
||||||
const [rows, setRows] = useState<Domain[]>([]);
|
const { confirm } = useConfirm();
|
||||||
const [rowSelection, setRowSelection] = useState<Domain["id"][]>([]);
|
const { setMessage: alert } = useAlertStore((state) => state);
|
||||||
|
|
||||||
const onSave = () => {
|
const { data: domainList } = useQuery({
|
||||||
handleSave(rows);
|
queryKey: [ENDPOINT.CMS_SERVICE.DOMAINS, props.open],
|
||||||
|
queryFn: () => DomainApi.getDomainList({ siteId }),
|
||||||
|
select: (data) => {
|
||||||
|
const domains = data.content.map((item) => ({
|
||||||
|
...item,
|
||||||
|
mode: "U",
|
||||||
|
}));
|
||||||
|
|
||||||
|
initialForm();
|
||||||
|
return domains;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutateAsync } = useMutation({
|
||||||
|
mutationFn: (body: Domain[]) => DomainApi.saveDomainList(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = useForm<DomainFormData>({
|
||||||
|
resolver: zodResolver(domainFormSchema),
|
||||||
|
values: {
|
||||||
|
domains: domainList ?? [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { fields, append, remove, update } = useFieldArray({
|
||||||
|
control: form.control,
|
||||||
|
name: "domains",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [onConfirm, setOnConfirm] = useState(false);
|
||||||
|
const [selectedRows, setSelectedRows] = useState<number[]>([]);
|
||||||
|
|
||||||
|
const initialForm = () => {
|
||||||
|
form.reset();
|
||||||
|
setSelectedRows([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSubmit = async (data: DomainFormData) => {
|
||||||
|
setOnConfirm(true);
|
||||||
|
if (await confirm("저장하시겠습니까?")) {
|
||||||
|
setOnConfirm(false);
|
||||||
|
await mutateAsync(data.domains);
|
||||||
|
handleSaveDomain?.(data.domains);
|
||||||
|
alert("저장되었습니다.");
|
||||||
|
}
|
||||||
|
setOnConfirm(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddDomain = () => {
|
const handleAddDomain = () => {
|
||||||
const newDomain: Domain = {
|
append({
|
||||||
id: Date.now(),
|
siteDmnNo: null,
|
||||||
domainUrl: "",
|
siteId,
|
||||||
isRepresentative: rows.length === 0,
|
dmnAddr: "",
|
||||||
isActive: "true",
|
useYn: "Y",
|
||||||
};
|
rprsDmnYn: "N",
|
||||||
setRows([...rows, newDomain]);
|
mode: "C",
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteDomain = () => {
|
|
||||||
const filteredRows = rows.filter((row) => !rowSelection.includes(row.id));
|
|
||||||
const hasRepresentative = filteredRows.some((row) => row.isRepresentative);
|
|
||||||
|
|
||||||
let updatedRows = filteredRows;
|
|
||||||
if (!hasRepresentative && filteredRows.length > 0) {
|
|
||||||
updatedRows = filteredRows.map((row, index) =>
|
|
||||||
index === 0 ? { ...row, isRepresentative: true } : row,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
setRows(updatedRows);
|
|
||||||
setRowSelection([]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDomainUrlChange = (id: number, value: string) => {
|
|
||||||
setRows(
|
|
||||||
rows.map((row) => (row.id === id ? { ...row, domainUrl: value } : row)),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRepresentativeChange = (id: number) => {
|
|
||||||
setRows(
|
|
||||||
rows.map((row) => ({
|
|
||||||
...row,
|
|
||||||
isRepresentative: row.id === id,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleActiveChange = (id: number, value: "true" | "false") => {
|
|
||||||
setRows(
|
|
||||||
rows.map((row) => (row.id === id ? { ...row, isActive: value } : row)),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleRowSelection = (id: number) => {
|
|
||||||
setRowSelection((prev) => {
|
|
||||||
if (prev.includes(id)) {
|
|
||||||
return prev.filter((item) => item !== id);
|
|
||||||
} else {
|
|
||||||
return [...prev, id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSelectAll = () => {
|
||||||
|
if (selectedRows.length === fields.length) {
|
||||||
|
setSelectedRows([]);
|
||||||
|
} else {
|
||||||
|
setSelectedRows(fields.map((_, index) => index));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectRow = (i: number) => {
|
||||||
|
setSelectedRows((prev) =>
|
||||||
|
prev.includes(i) ? prev.filter((j) => j !== i) : [...prev, i],
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteDomain = async () => {
|
||||||
|
if (selectedRows.length === 0) return;
|
||||||
|
|
||||||
|
const sortedIndices = [...selectedRows].sort((a, b) => b - a);
|
||||||
|
sortedIndices.forEach((i) => {
|
||||||
|
const field = fields[i];
|
||||||
|
if (field?.siteDmnNo) {
|
||||||
|
update(i, {
|
||||||
|
...field,
|
||||||
|
mode: "D",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
remove(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setSelectedRows([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeRprsDmnYn = (i: number) => {
|
||||||
|
fields.forEach((_, j) => {
|
||||||
|
if (j === i) return;
|
||||||
|
form.setValue(`domains.${j}.rprsDmnYn`, "N");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const isAllSelected =
|
||||||
|
fields.length > 0 && selectedRows.length === fields.length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<>
|
||||||
<DialogTrigger asChild>
|
<Dialog {...props}>
|
||||||
<Button disabled={triggerDisabled}>도메인 관리</Button>
|
<DialogTrigger asChild>
|
||||||
</DialogTrigger>
|
<Button>도메인 관리</Button>
|
||||||
<DialogContent className="sm:max-w-[60rem]">
|
</DialogTrigger>
|
||||||
<DialogHeader>
|
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||||
<DialogTitle>도메인 관리</DialogTitle>
|
<DialogHeader>
|
||||||
</DialogHeader>
|
<DialogTitle>도메인 관리</DialogTitle>
|
||||||
<div className="mb-4 flex justify-end gap-2">
|
</DialogHeader>
|
||||||
<Button size="sm" color="white" onClick={handleAddDomain}>
|
<Form {...form}>
|
||||||
항목 추가
|
<form
|
||||||
</Button>
|
onSubmit={(e) => {
|
||||||
<Button
|
e.preventDefault();
|
||||||
size="sm"
|
e.stopPropagation();
|
||||||
color="red"
|
form.handleSubmit(onSubmit)(e);
|
||||||
onClick={handleDeleteDomain}
|
}}
|
||||||
disabled={rowSelection.length === 0}
|
>
|
||||||
>
|
<div className="mb-4 flex justify-end gap-2">
|
||||||
항목 삭제
|
<Button type="button" size="sm" onClick={handleAddDomain}>
|
||||||
</Button>
|
항목 추가
|
||||||
</div>
|
</Button>
|
||||||
<div className="card card-border">
|
<Button
|
||||||
<Table variant="secondary">
|
type="button"
|
||||||
<colgroup>
|
size="sm"
|
||||||
<col width="8%" />
|
color="red"
|
||||||
<col width="12%" />
|
onClick={handleDeleteDomain}
|
||||||
<col width="40%" />
|
disabled={selectedRows.length === 0}
|
||||||
<col width="20%" />
|
>
|
||||||
<col width="20%" />
|
항목 삭제
|
||||||
</colgroup>
|
</Button>
|
||||||
<TableHeader>
|
</div>
|
||||||
<TableRow>
|
<div className="card card-border max-h-[28.5rem] overflow-auto">
|
||||||
<TableHead>NO</TableHead>
|
<Table variant="secondary">
|
||||||
<TableHead>선택</TableHead>
|
<colgroup>
|
||||||
<TableHead>도메인URL</TableHead>
|
<col width="10%" />
|
||||||
<TableHead>대표URL</TableHead>
|
<col width="auto" />
|
||||||
<TableHead>사용여부</TableHead>
|
<col width="15%" />
|
||||||
</TableRow>
|
<col width="25%" />
|
||||||
</TableHeader>
|
</colgroup>
|
||||||
<TableBody>
|
<TableHeader className="sticky -top-[0.6rem]">
|
||||||
{rows.map((row, idx) => (
|
<TableRow>
|
||||||
<TableRow key={row.id}>
|
<TableHead className="!px-0">
|
||||||
<TableCell align="center">{idx + 1}</TableCell>
|
<Checkbox
|
||||||
<TableCell align="center">
|
checked={isAllSelected}
|
||||||
<Checkbox
|
onCheckedChange={handleSelectAll}
|
||||||
checked={rowSelection.includes(row.id)}
|
/>
|
||||||
onCheckedChange={() => toggleRowSelection(row.id)}
|
</TableHead>
|
||||||
className="cursor-pointer"
|
<TableHead>도메인 주소</TableHead>
|
||||||
/>
|
<TableHead>대표 URL</TableHead>
|
||||||
</TableCell>
|
<TableHead>사용여부</TableHead>
|
||||||
<TableCell align="center">
|
</TableRow>
|
||||||
<Input
|
</TableHeader>
|
||||||
value={row.domainUrl}
|
<TableBody>
|
||||||
onChange={(e) =>
|
{fields.map((field, i) => {
|
||||||
handleDomainUrlChange(row.id, e.target.value)
|
if (field.mode === "D") return null;
|
||||||
}
|
return (
|
||||||
className="!text-[1.3rem]"
|
<TableRow key={field.id}>
|
||||||
/>
|
<TableCell align="center" className="!px-0">
|
||||||
</TableCell>
|
<Checkbox
|
||||||
<TableCell align="center">
|
checked={selectedRows.includes(i)}
|
||||||
<Checkbox
|
onCheckedChange={() => handleSelectRow(i)}
|
||||||
checked={row.isRepresentative}
|
/>
|
||||||
onCheckedChange={() => handleRepresentativeChange(row.id)}
|
</TableCell>
|
||||||
className="cursor-pointer"
|
<TableCell align="center">
|
||||||
/>
|
<FormField
|
||||||
</TableCell>
|
control={form.control}
|
||||||
<TableCell align="center">
|
name={`domains.${i}.dmnAddr`}
|
||||||
<Select
|
render={({ field }) => (
|
||||||
value={row.isActive}
|
<FormItem>
|
||||||
onValueChange={(value: "true" | "false") =>
|
<FormControl>
|
||||||
handleActiveChange(row.id, value)
|
<Input
|
||||||
}
|
{...field}
|
||||||
>
|
className="!text-[1.3rem]"
|
||||||
<SelectTrigger className="mx-auto w-[10rem]">
|
/>
|
||||||
<SelectValue placeholder="선택" />
|
</FormControl>
|
||||||
</SelectTrigger>
|
<FormMessage className="text-left" />
|
||||||
<SelectContent>
|
</FormItem>
|
||||||
<SelectItem value="true">예</SelectItem>
|
)}
|
||||||
<SelectItem value="false">아니오</SelectItem>
|
/>
|
||||||
</SelectContent>
|
</TableCell>
|
||||||
</Select>
|
<TableCell align="center">
|
||||||
</TableCell>
|
<FormField
|
||||||
</TableRow>
|
control={form.control}
|
||||||
))}
|
name={`domains.${i}.rprsDmnYn`}
|
||||||
</TableBody>
|
render={({ field }) => (
|
||||||
</Table>
|
<FormItem>
|
||||||
</div>
|
<FormControl>
|
||||||
<DialogFooter className="!justify-center">
|
<Checkbox
|
||||||
<DialogClose asChild>
|
checked={field.value === "Y"}
|
||||||
<Button size="lg" onClick={onSave}>
|
onCheckedChange={(checked) => {
|
||||||
저장
|
field.onChange(checked ? "Y" : "N");
|
||||||
</Button>
|
handleChangeRprsDmnYn(i);
|
||||||
</DialogClose>
|
}}
|
||||||
<DialogClose asChild>
|
/>
|
||||||
<Button size="lg" color="white">
|
</FormControl>
|
||||||
취소
|
<FormMessage />
|
||||||
</Button>
|
</FormItem>
|
||||||
</DialogClose>
|
)}
|
||||||
</DialogFooter>
|
/>
|
||||||
</DialogContent>
|
</TableCell>
|
||||||
</Dialog>
|
<TableCell align="center">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name={`domains.${i}.useYn`}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RadioGroup
|
||||||
|
value={field.value}
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
className="flex justify-center"
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value="Y"
|
||||||
|
id={`useY-${i}`}
|
||||||
|
/>
|
||||||
|
<label htmlFor={`useY-${i}`}>예</label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value="N"
|
||||||
|
id={`useN-${i}`}
|
||||||
|
/>
|
||||||
|
<label htmlFor={`useN-${i}`}>
|
||||||
|
아니오
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
<DialogFooter className="!justify-center">
|
||||||
|
<Button type="submit" size="lg">
|
||||||
|
저장
|
||||||
|
</Button>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="button" size="lg" color="white">
|
||||||
|
취소
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
<ConfirmDialog open={onConfirm} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||||
|
import { useForm, useFieldArray } from "react-hook-form";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
@@ -15,162 +19,266 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
RadioGroup,
|
RadioGroup,
|
||||||
RadioGroupItem,
|
RadioGroupItem,
|
||||||
Checkbox,
|
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
Checkbox,
|
||||||
} from "@common/components";
|
} from "@common/components";
|
||||||
|
import {
|
||||||
type IP = {
|
Form,
|
||||||
id: number;
|
FormControl,
|
||||||
ipAddress: string;
|
FormField,
|
||||||
allowed: boolean;
|
FormItem,
|
||||||
};
|
FormMessage,
|
||||||
|
} from "@/shared/ui/form";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import { IpApi } from "../api/ip-service";
|
||||||
|
import { ipFormSchema, type IP, type IPFormData } from "../model/ip-interface";
|
||||||
|
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||||
|
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||||
|
|
||||||
type IPManagementDialogProps = {
|
type IPManagementDialogProps = {
|
||||||
|
siteId: string;
|
||||||
triggerDisabled?: boolean;
|
triggerDisabled?: boolean;
|
||||||
|
open?: boolean;
|
||||||
|
onOpenChange?: (open: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
function IPManagementDialog({ triggerDisabled }: IPManagementDialogProps) {
|
function IPManagementDialog({
|
||||||
const [rows, setRows] = useState<IP[]>([]);
|
siteId,
|
||||||
const [rowSelection, setRowSelection] = useState<IP["id"][]>([]);
|
triggerDisabled,
|
||||||
|
...props
|
||||||
|
}: IPManagementDialogProps) {
|
||||||
|
const { confirm } = useConfirm();
|
||||||
|
const { setMessage: alert } = useAlertStore((state) => state);
|
||||||
|
|
||||||
const onSave = () => {};
|
const { data: ipList } = useQuery({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.IPS, props.open],
|
||||||
|
queryFn: () => IpApi.getIpList({ siteId, sort: [] }),
|
||||||
|
select: (data) => {
|
||||||
|
const ips = data.content.map((item) => ({
|
||||||
|
...item,
|
||||||
|
mode: "U",
|
||||||
|
}));
|
||||||
|
|
||||||
|
initialForm();
|
||||||
|
return ips;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutateAsync } = useMutation({
|
||||||
|
mutationFn: (body: IP[]) => IpApi.saveIpList(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = useForm<IPFormData>({
|
||||||
|
resolver: zodResolver(ipFormSchema),
|
||||||
|
values: {
|
||||||
|
ips: ipList ?? [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { fields, append, remove, update } = useFieldArray({
|
||||||
|
control: form.control,
|
||||||
|
name: "ips",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [onConfirm, setOnConfirm] = useState(false);
|
||||||
|
const [selectedRows, setSelectedRows] = useState<number[]>([]);
|
||||||
|
|
||||||
|
const initialForm = () => {
|
||||||
|
form.reset();
|
||||||
|
setSelectedRows([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSubmit = async (data: IPFormData) => {
|
||||||
|
setOnConfirm(true);
|
||||||
|
if (await confirm("저장하시겠습니까?")) {
|
||||||
|
setOnConfirm(false);
|
||||||
|
await mutateAsync(data.ips);
|
||||||
|
alert("저장되었습니다.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleAddIP = () => {
|
const handleAddIP = () => {
|
||||||
const newIP: IP = {
|
append({
|
||||||
id: Date.now(),
|
mngNo: null,
|
||||||
ipAddress: "",
|
siteId,
|
||||||
allowed: true,
|
ipAddr: "",
|
||||||
};
|
prmYn: "Y",
|
||||||
setRows([...rows, newIP]);
|
mode: "C",
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteIP = () => {
|
|
||||||
const filteredRows = rows.filter((row) => !rowSelection.includes(row.id));
|
|
||||||
setRows(filteredRows);
|
|
||||||
setRowSelection([]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleIPAddressChange = (id: number, value: string) => {
|
|
||||||
setRows(
|
|
||||||
rows.map((row) => (row.id === id ? { ...row, ipAddress: value } : row)),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAllowedChange = (id: number, value: boolean) => {
|
|
||||||
setRows(
|
|
||||||
rows.map((row) => (row.id === id ? { ...row, allowed: value } : row)),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleRowSelection = (id: number) => {
|
|
||||||
setRowSelection((prev) => {
|
|
||||||
if (prev.includes(id)) {
|
|
||||||
return prev.filter((item) => item !== id);
|
|
||||||
} else {
|
|
||||||
return [...prev, id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSelectAll = () => {
|
||||||
|
if (selectedRows.length === fields.length) {
|
||||||
|
setSelectedRows([]);
|
||||||
|
} else {
|
||||||
|
setSelectedRows(fields.map((_, index) => index));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectRow = (i: number) => {
|
||||||
|
setSelectedRows((prev) =>
|
||||||
|
prev.includes(i) ? prev.filter((j) => j !== i) : [...prev, i],
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteIP = async () => {
|
||||||
|
if (selectedRows.length === 0) return;
|
||||||
|
|
||||||
|
const sortedIndices = [...selectedRows].sort((a, b) => b - a);
|
||||||
|
sortedIndices.forEach((i) => {
|
||||||
|
const field = fields[i];
|
||||||
|
if (field?.mngNo) {
|
||||||
|
update(i, {
|
||||||
|
...field,
|
||||||
|
mode: "D",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
remove(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setSelectedRows([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isAllSelected =
|
||||||
|
fields.length > 0 && selectedRows.length === fields.length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<>
|
||||||
<DialogTrigger asChild>
|
<Dialog {...props}>
|
||||||
<Button disabled={triggerDisabled}>IP 관리</Button>
|
<DialogTrigger asChild>
|
||||||
</DialogTrigger>
|
<Button disabled={triggerDisabled}>IP 관리</Button>
|
||||||
<DialogContent className="sm:max-w-[60rem]">
|
</DialogTrigger>
|
||||||
<DialogHeader>
|
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||||
<DialogTitle>IP 관리</DialogTitle>
|
<DialogHeader>
|
||||||
</DialogHeader>
|
<DialogTitle>IP 관리</DialogTitle>
|
||||||
<div className="mb-4 flex justify-end gap-2">
|
</DialogHeader>
|
||||||
<Button size="sm" color="green">
|
<Form {...form}>
|
||||||
엑셀 업로드
|
<form
|
||||||
</Button>
|
onSubmit={(e) => {
|
||||||
<Button size="sm" color="white" onClick={handleAddIP}>
|
e.preventDefault();
|
||||||
항목 추가
|
e.stopPropagation();
|
||||||
</Button>
|
form.handleSubmit(onSubmit)(e);
|
||||||
<Button
|
}}
|
||||||
size="sm"
|
>
|
||||||
color="red"
|
<div className="mb-4 flex justify-end gap-2">
|
||||||
onClick={handleDeleteIP}
|
<Button type="button" size="sm" onClick={handleAddIP}>
|
||||||
disabled={rowSelection.length === 0}
|
항목 추가
|
||||||
>
|
</Button>
|
||||||
항목 삭제
|
<Button
|
||||||
</Button>
|
type="button"
|
||||||
</div>
|
size="sm"
|
||||||
<div className="card card-border">
|
color="red"
|
||||||
<Table variant="secondary">
|
onClick={handleDeleteIP}
|
||||||
<colgroup>
|
disabled={selectedRows.length === 0}
|
||||||
<col width="10%" />
|
>
|
||||||
<col width="10%" />
|
항목 삭제
|
||||||
<col width="55%" />
|
</Button>
|
||||||
<col width="25%" />
|
</div>
|
||||||
</colgroup>
|
<div className="card card-border max-h-[28.5rem] overflow-auto">
|
||||||
<TableHeader>
|
<Table variant="secondary">
|
||||||
<TableRow>
|
<colgroup>
|
||||||
<TableHead>NO</TableHead>
|
<col width="10%" />
|
||||||
<TableHead>선택</TableHead>
|
<col width="65%" />
|
||||||
<TableHead>IP 주소</TableHead>
|
<col width="25%" />
|
||||||
<TableHead>허용여부</TableHead>
|
</colgroup>
|
||||||
</TableRow>
|
<TableHeader className="sticky -top-[0.6rem]">
|
||||||
</TableHeader>
|
<TableRow>
|
||||||
<TableBody>
|
<TableHead className="!px-0">
|
||||||
{rows.map((row, idx) => (
|
<Checkbox
|
||||||
<TableRow key={row.id}>
|
checked={isAllSelected}
|
||||||
<TableCell align="center">{idx + 1}</TableCell>
|
onCheckedChange={handleSelectAll}
|
||||||
<TableCell align="center">
|
/>
|
||||||
<Checkbox
|
</TableHead>
|
||||||
checked={rowSelection.includes(row.id)}
|
<TableHead>IP 주소</TableHead>
|
||||||
onCheckedChange={() => toggleRowSelection(row.id)}
|
<TableHead>허용여부</TableHead>
|
||||||
className="cursor-pointer"
|
</TableRow>
|
||||||
/>
|
</TableHeader>
|
||||||
</TableCell>
|
<TableBody>
|
||||||
<TableCell align="center">
|
{fields.map((field, i) => {
|
||||||
<Input
|
if (field.mode === "D") return null;
|
||||||
value={row.ipAddress}
|
return (
|
||||||
onChange={(e) =>
|
<TableRow key={field.id}>
|
||||||
handleIPAddressChange(row.id, e.target.value)
|
<TableCell align="center" className="!px-0">
|
||||||
}
|
<Checkbox
|
||||||
className="!text-[1.3rem]"
|
checked={selectedRows.includes(i)}
|
||||||
/>
|
onCheckedChange={() => handleSelectRow(i)}
|
||||||
</TableCell>
|
/>
|
||||||
<TableCell align="center">
|
</TableCell>
|
||||||
<RadioGroup
|
<TableCell align="center">
|
||||||
value={row.allowed ? "true" : "false"}
|
<FormField
|
||||||
onValueChange={(value) =>
|
control={form.control}
|
||||||
handleAllowedChange(row.id, value === "true")
|
name={`ips.${i}.ipAddr`}
|
||||||
}
|
render={({ field }) => (
|
||||||
className="flex justify-center"
|
<FormItem>
|
||||||
>
|
<FormControl>
|
||||||
<div className="flex items-center space-x-2">
|
<Input
|
||||||
<RadioGroupItem value="true" id={`allow-${row.id}`} />
|
{...field}
|
||||||
<label htmlFor={`allow-${row.id}`}>예</label>
|
className="!text-[1.3rem]"
|
||||||
</div>
|
/>
|
||||||
<div className="flex items-center space-x-2">
|
</FormControl>
|
||||||
<RadioGroupItem value="false" id={`deny-${row.id}`} />
|
<FormMessage className="text-left" />
|
||||||
<label htmlFor={`deny-${row.id}`}>아니오</label>
|
</FormItem>
|
||||||
</div>
|
)}
|
||||||
</RadioGroup>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
<TableCell align="center">
|
||||||
))}
|
<FormField
|
||||||
</TableBody>
|
control={form.control}
|
||||||
</Table>
|
name={`ips.${i}.prmYn`}
|
||||||
</div>
|
render={({ field }) => (
|
||||||
<DialogFooter className="!justify-center">
|
<FormItem>
|
||||||
<DialogClose asChild>
|
<FormControl>
|
||||||
<Button size="lg" onClick={onSave}>
|
<RadioGroup
|
||||||
저장
|
value={field.value}
|
||||||
</Button>
|
onValueChange={field.onChange}
|
||||||
</DialogClose>
|
className="flex justify-center"
|
||||||
<DialogClose asChild>
|
>
|
||||||
<Button size="lg" color="white">
|
<div className="flex items-center space-x-2">
|
||||||
취소
|
<RadioGroupItem
|
||||||
</Button>
|
value="Y"
|
||||||
</DialogClose>
|
id={`prmY-${i}`}
|
||||||
</DialogFooter>
|
/>
|
||||||
</DialogContent>
|
<label htmlFor={`prmY-${i}`}>예</label>
|
||||||
</Dialog>
|
</div>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value="N"
|
||||||
|
id={`prmN-${i}`}
|
||||||
|
/>
|
||||||
|
<label htmlFor={`prmN-${i}`}>
|
||||||
|
아니오
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
<DialogFooter className="!justify-center">
|
||||||
|
<Button type="submit" size="lg">
|
||||||
|
저장
|
||||||
|
</Button>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button type="button" size="lg" color="white">
|
||||||
|
취소
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
<ConfirmDialog open={onConfirm} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,94 +1,76 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { SiteApi, siteFormSchema, type SiteFormData } from "@/entities/site";
|
||||||
import { ENDPOINT } from "@/shared/config";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import { SiteApi } from "../api/site-service";
|
import { PageLayout } from "@/shared/ui/page-layout";
|
||||||
import {
|
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||||
siteFormSchema,
|
|
||||||
type ISiteDetail,
|
|
||||||
type SiteFormData,
|
|
||||||
} from "../model/site-interface";
|
|
||||||
import { SitePageLayout } from "./layout";
|
|
||||||
import { SiteForm } from "./site-form";
|
import { SiteForm } from "./site-form";
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogClose,
|
|
||||||
DialogContent,
|
|
||||||
DialogFooter,
|
|
||||||
} from "@common/components/ui";
|
|
||||||
|
|
||||||
function ModifyPage({ siteId }: { siteId: string }) {
|
function ModifyPage({ siteId }: { siteId: string }) {
|
||||||
const isModifyMode = !!siteId;
|
const isModifyMode = !!siteId;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { setMessage: alert } = useAlertStore((state) => state);
|
||||||
|
|
||||||
const { data: siteDetail } = useQuery({
|
const { data: siteDetail } = useQuery({
|
||||||
queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId],
|
queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId],
|
||||||
queryFn: () => SiteApi.siteDetail(siteId),
|
queryFn: () => SiteApi.siteDetail(siteId),
|
||||||
select: (data) => ({
|
select: (data) => {
|
||||||
...data,
|
const keys = Object.keys(siteFormSchema.shape);
|
||||||
faxNo: data.faxNumber,
|
const filteredData = Object.fromEntries(
|
||||||
bscSiteYn: data.basicSiteYn,
|
Object.entries(data).filter(([key]) => keys.includes(key)),
|
||||||
}),
|
);
|
||||||
|
return {
|
||||||
|
...filteredData,
|
||||||
|
faxNo: data.faxNumber,
|
||||||
|
bscSiteYn: data.basicSiteYn,
|
||||||
|
};
|
||||||
|
},
|
||||||
enabled: isModifyMode,
|
enabled: isModifyMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { mutateAsync: modifySite } = useMutation({
|
const { mutateAsync: modifySite } = useMutation({
|
||||||
mutationFn: (data: SiteFormData) => SiteApi.modifySite(siteId, data),
|
mutationFn: (data: SiteFormData) => SiteApi.modifySite(siteId, data),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setMessage("수정되었습니다.");
|
alert("수정되었습니다.", () => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { mutateAsync: deleteSite } = useMutation({
|
const { mutateAsync: deleteSite } = useMutation({
|
||||||
mutationFn: () => SiteApi.deleteSite(siteId),
|
mutationFn: () => SiteApi.deleteSite(siteId),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setMessage("삭제되었습니다.");
|
alert("삭제되었습니다.", () => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const [message, setMessage] = useState("");
|
|
||||||
|
|
||||||
const form = useForm<SiteFormData>({
|
const form = useForm<SiteFormData>({
|
||||||
resolver: zodResolver(siteFormSchema),
|
resolver: zodResolver(siteFormSchema),
|
||||||
|
values: siteDetail as SiteFormData,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!siteDetail) return;
|
|
||||||
|
|
||||||
const keys = Object.keys(siteFormSchema.shape);
|
|
||||||
for (const key of keys) {
|
|
||||||
form.setValue(
|
|
||||||
key as keyof SiteFormData,
|
|
||||||
siteDetail[key as keyof ISiteDetail] ?? "",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [siteDetail]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SitePageLayout>
|
<PageLayout pageTitle="사이트 관리">
|
||||||
<SiteForm
|
<SiteForm
|
||||||
form={form}
|
form={form}
|
||||||
siteId={siteId}
|
siteId={siteId}
|
||||||
handleSave={modifySite}
|
handleSave={modifySite}
|
||||||
handleDelete={deleteSite}
|
handleDelete={deleteSite}
|
||||||
/>
|
/>
|
||||||
<Dialog open={!!message} onOpenChange={() => router.back()}>
|
</PageLayout>
|
||||||
<DialogContent aria-describedby={undefined}>
|
|
||||||
<div className="py-10">
|
|
||||||
<p className="text-center text-[1.4rem]">{message}</p>
|
|
||||||
</div>
|
|
||||||
<DialogFooter className="!justify-center">
|
|
||||||
<DialogClose asChild>
|
|
||||||
<Button>확인</Button>
|
|
||||||
</DialogClose>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
</SitePageLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
|||||||
import { type UseFormReturn } from "react-hook-form";
|
import { type UseFormReturn } from "react-hook-form";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
|
||||||
DialogClose,
|
|
||||||
DialogContent,
|
|
||||||
DialogFooter,
|
|
||||||
Input,
|
Input,
|
||||||
Label,
|
Label,
|
||||||
RadioGroup,
|
RadioGroup,
|
||||||
@@ -19,6 +15,7 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from "@common/components";
|
} from "@common/components";
|
||||||
import { CodeSelect } from "@/entities/code";
|
import { CodeSelect } from "@/entities/code";
|
||||||
|
import type { SiteFormData } from "@/entities/site";
|
||||||
import {
|
import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -26,47 +23,54 @@ import {
|
|||||||
Form,
|
Form,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/shared/ui/form";
|
} from "@/shared/ui/form";
|
||||||
import { type ISiteDetail, type SiteFormData } from "../model/site-interface";
|
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||||
|
import type { Domain } from "../model/domain-interface";
|
||||||
import { IPManagementDialog } from "./ip-management-dialog";
|
import { IPManagementDialog } from "./ip-management-dialog";
|
||||||
import {
|
import { DomainManagementDialog } from "./domain-management-dialog";
|
||||||
DomainManagementDialog,
|
|
||||||
type Domain,
|
|
||||||
} from "./domain-management-dialog";
|
|
||||||
|
|
||||||
type SiteFormProps = {
|
type SiteFormProps = {
|
||||||
form: UseFormReturn<SiteFormData>;
|
form: UseFormReturn<SiteFormData>;
|
||||||
siteId?: string;
|
siteId?: string;
|
||||||
handleSave: (data: SiteFormData) => void;
|
handleSave: (data: SiteFormData) => Promise<void>;
|
||||||
handleDelete?: () => void;
|
handleDelete?: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||||
const router = useRouter();
|
|
||||||
const { message, confirm, onConfirm, onCancel } = useConfirm();
|
|
||||||
|
|
||||||
const [viewState, setViewState] = useState<Partial<ISiteDetail>>({});
|
|
||||||
const [representativeDomain, setRepresentativeDomain] = useState<string>("");
|
|
||||||
|
|
||||||
const isModifyMode = !!siteId;
|
const isModifyMode = !!siteId;
|
||||||
|
|
||||||
const handleViewStateChange = (key: keyof ISiteDetail) => (value: string) => {
|
const router = useRouter();
|
||||||
setViewState({ ...viewState, [key]: value });
|
const { confirm } = useConfirm();
|
||||||
};
|
const [onConfirm, setOnConfirm] = useState(false);
|
||||||
|
const [isIpManagementOpen, setIsIpManagementOpen] = useState(false);
|
||||||
|
const [isDomainManagementOpen, setIsDomainManagementOpen] = useState(false);
|
||||||
|
|
||||||
const handleDomainSave = (rows: Domain[]) => {
|
const handleSaveDomain = (rows: Domain[]) => {
|
||||||
setRepresentativeDomain(
|
form.setValue(
|
||||||
rows.find((row) => row.isRepresentative)?.domainUrl || "",
|
"dmnAddr",
|
||||||
|
rows.find((row) => row.rprsDmnYn === "Y")?.dmnAddr || "",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = (data: SiteFormData) => {
|
const onSubmit = async (data: SiteFormData) => {
|
||||||
handleSave(data);
|
const confirmMessage = isModifyMode
|
||||||
|
? "수정하시겠습니까?"
|
||||||
|
: "저장하시겠습니까?";
|
||||||
|
|
||||||
|
setOnConfirm(true);
|
||||||
|
if (await confirm(confirmMessage)) {
|
||||||
|
setOnConfirm(false);
|
||||||
|
handleSave(data);
|
||||||
|
}
|
||||||
|
setOnConfirm(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDelete = async () => {
|
const onDelete = async () => {
|
||||||
if (await confirm("정말 삭제하시겠습니까?")) {
|
setOnConfirm(true);
|
||||||
|
if (await confirm("삭제하시겠습니까?")) {
|
||||||
|
setOnConfirm(false);
|
||||||
handleDelete?.();
|
handleDelete?.();
|
||||||
}
|
}
|
||||||
|
setOnConfirm(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -97,6 +101,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="w-[12rem] !text-[1.3rem]"
|
className="w-[12rem] !text-[1.3rem]"
|
||||||
disabled={isModifyMode}
|
disabled={isModifyMode}
|
||||||
/>
|
/>
|
||||||
@@ -120,10 +125,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<CodeSelect
|
<CodeSelect
|
||||||
{...field}
|
{...field}
|
||||||
upCd="SITEKNDCD"
|
upCd="SITEKNDCD"
|
||||||
onValueChange={(value) => {
|
onValueChange={field.onChange}
|
||||||
handleViewStateChange("siteKndCd")(value);
|
|
||||||
field.onChange(value);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
@@ -132,7 +134,10 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
/>
|
/>
|
||||||
{isModifyMode && (
|
{isModifyMode && (
|
||||||
<IPManagementDialog
|
<IPManagementDialog
|
||||||
triggerDisabled={viewState.siteKndCd === "O"}
|
siteId={siteId}
|
||||||
|
triggerDisabled={form.watch("siteKndCd") === "O"}
|
||||||
|
open={isIpManagementOpen}
|
||||||
|
onOpenChange={setIsIpManagementOpen}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -149,6 +154,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<CodeSelect
|
<CodeSelect
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
upCd="SITESKINCD"
|
upCd="SITESKINCD"
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
/>
|
/>
|
||||||
@@ -170,6 +176,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="사이트명을 입력하십시오."
|
placeholder="사이트명을 입력하십시오."
|
||||||
/>
|
/>
|
||||||
@@ -191,6 +198,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="사이트 설명을 입력하십시오."
|
placeholder="사이트 설명을 입력하십시오."
|
||||||
/>
|
/>
|
||||||
@@ -207,10 +215,13 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<TableCell className="border">
|
<TableCell className="border">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
<div className="h-[3.2rem] w-[21.5rem] cursor-not-allowed rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||||
{representativeDomain}
|
{form.watch("dmnAddr")}
|
||||||
</div>
|
</div>
|
||||||
<DomainManagementDialog
|
<DomainManagementDialog
|
||||||
handleSave={handleDomainSave}
|
siteId={siteId}
|
||||||
|
open={isDomainManagementOpen}
|
||||||
|
onOpenChange={setIsDomainManagementOpen}
|
||||||
|
handleSaveDomain={handleSaveDomain}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
@@ -227,6 +238,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="사이트 하단 주소를 입력하십시오."
|
placeholder="사이트 하단 주소를 입력하십시오."
|
||||||
/>
|
/>
|
||||||
@@ -248,6 +260,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="사이트 하단 전화번호를 입력하십시오."
|
placeholder="사이트 하단 전화번호를 입력하십시오."
|
||||||
/>
|
/>
|
||||||
@@ -269,6 +282,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="사이트 하단 팩스번호를 입력하십시오."
|
placeholder="사이트 하단 팩스번호를 입력하십시오."
|
||||||
/>
|
/>
|
||||||
@@ -290,6 +304,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="사이트 표기 내용을 입력하십시오. (ex. COPYRIGHT c 2013 KECO. ALL RIGHTS RESERVED.)"
|
placeholder="사이트 표기 내용을 입력하십시오. (ex. COPYRIGHT c 2013 KECO. ALL RIGHTS RESERVED.)"
|
||||||
/>
|
/>
|
||||||
@@ -311,6 +326,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
value={field.value ?? ""}
|
||||||
className="!text-[1.3rem]"
|
className="!text-[1.3rem]"
|
||||||
placeholder="아이콘 파일 경로 및 파일명을 입력하여 주십시오."
|
placeholder="아이콘 파일 경로 및 파일명을 입력하여 주십시오."
|
||||||
/>
|
/>
|
||||||
@@ -405,25 +421,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
<Dialog open={!!message} onOpenChange={onCancel}>
|
<ConfirmDialog open={onConfirm} />
|
||||||
<DialogContent aria-describedby={undefined}>
|
|
||||||
<div className="py-10">
|
|
||||||
<p className="text-center text-[1.4rem]">{message}</p>
|
|
||||||
</div>
|
|
||||||
<DialogFooter className="!justify-center">
|
|
||||||
<DialogClose asChild>
|
|
||||||
<Button color="red" onClick={onConfirm}>
|
|
||||||
삭제
|
|
||||||
</Button>
|
|
||||||
</DialogClose>
|
|
||||||
<DialogClose asChild>
|
|
||||||
<Button color="white" onClick={onCancel}>
|
|
||||||
취소
|
|
||||||
</Button>
|
|
||||||
</DialogClose>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,32 +6,26 @@ import { ENDPOINT } from "@/shared/config/api";
|
|||||||
import { Button, DataTable, Input } from "@common/components";
|
import { Button, DataTable, Input } from "@common/components";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
||||||
import { useRouter } from "next/navigation";
|
import { Button, DataTable, Input } from "@common/components";
|
||||||
import { useEffect, useState } from "react";
|
import { SiteApi, type ISite, type ISiteParams } from "@/entities/site";
|
||||||
import { SiteApi } from "../api/site-service";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import { type ISite, type ISiteParams } from "../model/site-interface";
|
import { PageLayout } from "@/shared/ui/page-layout";
|
||||||
import { columns } from "../model/table-columns";
|
import { columns } from "../model/table-columns";
|
||||||
import { SitePageLayout } from "./layout";
|
|
||||||
|
|
||||||
function SitePage() {
|
function SitePage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { data: siteInfo, refetch } = useQuery({
|
const { data: siteList, refetch } = useQuery({
|
||||||
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||||
queryFn: () => SiteApi.siteInfo(siteQuery),
|
queryFn: () => SiteApi.getSiteList(siteQuery),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [siteQuery, setSiteQuery] = useState<ISiteParams>({
|
const [siteQuery, setSiteQuery] = useState<ISiteParams>({
|
||||||
siteNm: "",
|
siteNm: "",
|
||||||
siteKndCd: "",
|
|
||||||
useYn: "",
|
|
||||||
page: 0,
|
|
||||||
size: 0,
|
|
||||||
sort: [],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: siteInfo?.content ?? [],
|
data: siteList?.content ?? [],
|
||||||
columns,
|
columns,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
});
|
});
|
||||||
@@ -47,23 +41,20 @@ function SitePage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refetch();
|
refetch();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SitePageLayout>
|
<PageLayout pageTitle="사이트 관리">
|
||||||
<div className="card card-border !mt-6">
|
<div className="card card-border !mt-6">
|
||||||
<div className="card card-border !border-[#dbe2e6] !bg-[#eef7ff]">
|
<div className="card card-border">
|
||||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||||
<label htmlFor="" className="mr-2 text-[#657481]">
|
<label htmlFor="" className="mr-2 text-label">
|
||||||
사이트명
|
사이트명
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
|
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
|
||||||
value={siteQuery.siteNm}
|
value={siteQuery.siteNm}
|
||||||
onChange={(e) =>
|
onChange={(e) => setSiteQuery({ siteNm: e.target.value })}
|
||||||
setSiteQuery({ ...siteQuery, siteNm: e.target.value })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Button className="h-[3.2rem]" type="submit">
|
<Button className="h-[3.2rem]" type="submit">
|
||||||
조회
|
조회
|
||||||
@@ -72,7 +63,7 @@ function SitePage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="card card-border">
|
<div className="card card-border">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<h3 className="text-2xl font-medium text-[#666]">사이트 목록</h3>
|
<h3 className="text-2xl font-medium text-label">사이트 목록</h3>
|
||||||
<Button onClick={() => router.push("/site/register")}>등록</Button>
|
<Button onClick={() => router.push("/site/register")}>등록</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="card !m-[1.2rem] h-[49rem] overflow-auto !p-0">
|
<div className="card !m-[1.2rem] h-[49rem] overflow-auto !p-0">
|
||||||
@@ -80,7 +71,7 @@ function SitePage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</SitePageLayout>
|
</PageLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ export const ENDPOINT = {
|
|||||||
CMS_SERVICE: {
|
CMS_SERVICE: {
|
||||||
SITES: "/cms-service/api/v1/sites",
|
SITES: "/cms-service/api/v1/sites",
|
||||||
CODE: "/cms-service/api/v1/code/cache",
|
CODE: "/cms-service/api/v1/code/cache",
|
||||||
|
IPS: "/cms-service/api/v1/site-ips",
|
||||||
|
DOMAINS: "/cms-service/api/v1/site-dmns",
|
||||||
|
MENUS: "/cms-service/api/v1/menus",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { useStore } from "zustand";
|
||||||
|
import { useContext } from "react";
|
||||||
|
import type { AlertStore } from "../store/alert-store";
|
||||||
|
import { StoreContext } from "../providers/store-provider";
|
||||||
|
|
||||||
|
export const useAlertStore = <T>(selector: (store: AlertStore) => T): T => {
|
||||||
|
const storeContext = useContext(StoreContext);
|
||||||
|
|
||||||
|
if (!storeContext) {
|
||||||
|
throw new Error("useAlertStore must be used within StoreProvider");
|
||||||
|
}
|
||||||
|
|
||||||
|
return useStore(storeContext.alertStore, selector);
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useStore } from "zustand";
|
import { useStore } from "zustand";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { type UserStore } from "@/shared/store/user-store";
|
import type { UserStore } from "../store/user-store";
|
||||||
import { StoreContext } from "../providers/store-provider";
|
import { StoreContext } from "../providers/store-provider";
|
||||||
|
|
||||||
export const useUserStore = <T>(selector: (store: UserStore) => T): T => {
|
export const useUserStore = <T>(selector: (store: UserStore) => T): T => {
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
interface SortConfig {
|
||||||
|
empty: boolean;
|
||||||
|
sorted: boolean;
|
||||||
|
unsorted: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PageableConfig {
|
||||||
|
sort: SortConfig;
|
||||||
|
offset: number;
|
||||||
|
pageNumber: number;
|
||||||
|
pageSize: number;
|
||||||
|
paged: boolean;
|
||||||
|
unpaged: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PageableList<T> {
|
||||||
|
content: T;
|
||||||
|
pageable: PageableConfig;
|
||||||
|
sort: SortConfig;
|
||||||
|
totalPages: number;
|
||||||
|
totalElements: number;
|
||||||
|
number: number;
|
||||||
|
numberOfElements: number;
|
||||||
|
size: number;
|
||||||
|
first: boolean;
|
||||||
|
last: boolean;
|
||||||
|
empty: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPageableParams {
|
||||||
|
page?: number;
|
||||||
|
size?: number;
|
||||||
|
sort?: string[];
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./api-interface";
|
||||||
@@ -1,2 +1 @@
|
|||||||
export { QueryProvider } from "./query-provider";
|
|
||||||
export { StoreProvider } from "./store-provider";
|
export { StoreProvider } from "./store-provider";
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { createContext, useRef } from "react";
|
import { createContext, useRef } from "react";
|
||||||
import { createUserStore } from "@/shared/store/user-store";
|
import { createAlertStore } from "../store/alert-store";
|
||||||
|
import { createUserStore } from "../store/user-store";
|
||||||
|
|
||||||
type StoreContextType = {
|
type StoreContextType = {
|
||||||
|
alertStore: ReturnType<typeof createAlertStore>;
|
||||||
userStore: ReturnType<typeof createUserStore>;
|
userStore: ReturnType<typeof createUserStore>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -15,6 +17,7 @@ export const StoreProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
const storeRef = useRef<StoreContextType | null>(null);
|
const storeRef = useRef<StoreContextType | null>(null);
|
||||||
if (storeRef.current === null) {
|
if (storeRef.current === null) {
|
||||||
storeRef.current = {
|
storeRef.current = {
|
||||||
|
alertStore: createAlertStore(),
|
||||||
userStore: createUserStore(),
|
userStore: createUserStore(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { createStore } from "zustand/vanilla";
|
||||||
|
|
||||||
|
export type AlertState = {
|
||||||
|
message: string;
|
||||||
|
callback?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AlertActions = {
|
||||||
|
setMessage: (message: string, callback?: () => void) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AlertStore = AlertState & AlertActions;
|
||||||
|
|
||||||
|
export const defaultInitState: AlertState = {
|
||||||
|
message: "",
|
||||||
|
callback: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createAlertStore = (initState: AlertState = defaultInitState) => {
|
||||||
|
return createStore<AlertStore>()((set) => ({
|
||||||
|
...initState,
|
||||||
|
setMessage: (message: string, callback?: () => void) =>
|
||||||
|
set(() => ({ message, callback })),
|
||||||
|
}));
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogClose,
|
||||||
|
Button,
|
||||||
|
} from "@common/components/ui";
|
||||||
|
import { useAlertStore } from "../lib/use-alert-store";
|
||||||
|
|
||||||
|
function AlertDialog() {
|
||||||
|
const { message, callback, setMessage } = useAlertStore((state) => state);
|
||||||
|
const handleOpenChange = () => {
|
||||||
|
setMessage("");
|
||||||
|
callback?.();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Dialog open={!!message} onOpenChange={handleOpenChange}>
|
||||||
|
<DialogContent aria-describedby={undefined}>
|
||||||
|
<div className="py-10">
|
||||||
|
<p className="text-center text-[1.4rem] text-foreground">{message}</p>
|
||||||
|
</div>
|
||||||
|
<DialogFooter className="!justify-center">
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button>확인</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AlertDialog };
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogClose,
|
||||||
|
Button,
|
||||||
|
type ButtonProps,
|
||||||
|
} from "@common/components/ui";
|
||||||
|
|
||||||
|
type ConfirmDialogProps = {
|
||||||
|
open: boolean;
|
||||||
|
confirmButtonProps?: ButtonProps & { label?: string };
|
||||||
|
cancelButtonProps?: ButtonProps & { label?: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
function ConfirmDialog({
|
||||||
|
open,
|
||||||
|
confirmButtonProps,
|
||||||
|
cancelButtonProps,
|
||||||
|
}: ConfirmDialogProps) {
|
||||||
|
const { message, onConfirm, onCancel } = useConfirm();
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={onCancel}>
|
||||||
|
<DialogContent aria-describedby={undefined}>
|
||||||
|
<div className="py-10">
|
||||||
|
<p className="text-center text-[1.4rem] text-foreground">{message}</p>
|
||||||
|
</div>
|
||||||
|
<DialogFooter className="!justify-center">
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button onClick={onConfirm} {...confirmButtonProps}>
|
||||||
|
{confirmButtonProps?.label ?? "확인"}
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button onClick={onCancel} color="white" {...cancelButtonProps}>
|
||||||
|
{cancelButtonProps?.label ?? "취소"}
|
||||||
|
</Button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ConfirmDialog };
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
function SitePageLayout({ children }: { children: React.ReactNode }) {
|
function PageLayout({
|
||||||
|
children,
|
||||||
|
pageTitle,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
pageTitle: string;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="h-auto min-h-full bg-container">
|
<div className="h-auto min-h-full bg-container">
|
||||||
<h2 className="px-[1.8rem] pt-[2rem] text-[2.4rem] font-semibold text-title">
|
<h2 className="px-[1.8rem] pt-[2rem] text-[2.4rem] font-semibold text-title">
|
||||||
사이트 관리
|
{pageTitle}
|
||||||
</h2>
|
</h2>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SitePageLayout };
|
export { PageLayout };
|
||||||
@@ -4,7 +4,6 @@ import presetConfig from "../../tailwind.config.preset";
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
presets: [presetConfig],
|
presets: [presetConfig],
|
||||||
darkMode: ["class", "[data-mode='dark']"],
|
|
||||||
content: [
|
content: [
|
||||||
"./src/**/*.{js,ts,jsx,tsx,mdx}",
|
"./src/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
"../../packages/common/components/src/ui/**/*.{js,ts,jsx,tsx,mdx}",
|
"../../packages/common/components/src/ui/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { ScrollArea, SearchDiv, SelectBox, UiTable } from '@common/business_components';
|
||||||
|
import { Button } from '@common/components';
|
||||||
|
import { PublicReuseFaciltyFormInsert } from '../../../../components/ui/publicReuseInsertForm';
|
||||||
|
import { useWrStore } from '../../../store';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function PublicReuseFaciltyInsert() {
|
||||||
|
const {pubFac} = useWrStore((state) => state);
|
||||||
|
const { pubFacHeadList, publicReuseFacilityData} = pubFac;
|
||||||
|
const searchDiv = '하수재이용시설 '
|
||||||
|
const selectBox = [{ text: '서울하수처리시설', val: "1_hasu" }, { text: '서울1하수처리시설', val: "2_hasu" }, { text: '서울2하수처리시설', val: "3_hasu" }]
|
||||||
|
const headName = () => {
|
||||||
|
return (
|
||||||
|
<h1 className="pl-3 text-xl">○공공 하수처리시설 등록</h1>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const onSelectValue = (val: string) => {
|
||||||
|
console.log(val)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="grid grid-cols-2 gap-4 h-full">
|
||||||
|
<div className='col-span-4'>
|
||||||
|
<h1 className="pl-3 text-xl" > 하수재이용시설 등록</h1>
|
||||||
|
<div className="m-8">
|
||||||
|
<SearchDiv>
|
||||||
|
<div className='w-4/5 grid grid-cols-12 gap-1 mx-4'>
|
||||||
|
<SelectBox className='col-span-4' label={searchDiv} selectArray={selectBox} onSelectValue={onSelectValue} />
|
||||||
|
</div>
|
||||||
|
<div className='w-1/5 flex items-center justify-end'>
|
||||||
|
<Button className='mr-4 rounded-lg'>조회</Button>
|
||||||
|
<Button className='mr-4 rounded-lg'>신규추가</Button>
|
||||||
|
</div>
|
||||||
|
</SearchDiv>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-1 pl-11">
|
||||||
|
<UiTable tableData={publicReuseFacilityData} headlist={pubFacHeadList} pageSize={100} total={10} headName={headName()} children={undefined}/>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-1 pr-6 max-h-full overflow-y-scroll">
|
||||||
|
<ScrollArea>
|
||||||
|
<PublicReuseFaciltyFormInsert />
|
||||||
|
{/* <ScrollBar orientation="vertical"></ScrollBar> */}
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
--container: #f1f6f9;
|
--container: #f1f6f9;
|
||||||
--title: #4c5e6f;
|
--title: #4c5e6f;
|
||||||
}
|
}
|
||||||
[data-mode="dark"] {
|
[data-theme="black"] {
|
||||||
--background: #0a0a0a;
|
--background: #0a0a0a;
|
||||||
--foreground: #fafafa;
|
--foreground: #fafafa;
|
||||||
--card: #0a0a0a;
|
--card: #0a0a0a;
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
.card {
|
||||||
|
position: relative;
|
||||||
|
margin: 0.6rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-height: 2rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.6rem;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card_width10 {width:calc(10% - 12px);}
|
||||||
|
|
||||||
|
.card_width20 {width:calc(20% - 12px);}
|
||||||
|
|
||||||
|
.card_width25 {width:calc(25% - 12px);}
|
||||||
|
|
||||||
|
.card_width30 {width:calc(30% - 12px);}
|
||||||
|
|
||||||
|
.card_width33 {width:calc(33.333% - 12px);}
|
||||||
|
|
||||||
|
.card_width40 {width:calc(40% - 12px);}
|
||||||
|
|
||||||
|
.card_width45 {width:calc(45% - 12px);}
|
||||||
|
|
||||||
|
.card_width50 {width:calc(50% - 12px);}
|
||||||
|
|
||||||
|
.card_width60 {width:calc(60% - 12px);}
|
||||||
|
|
||||||
|
.card_width66 {width:calc(66.666% - 12px);}
|
||||||
|
|
||||||
|
.card_width70 {width:calc(70% - 12px);}
|
||||||
|
|
||||||
|
.card_width75 {width:calc(75% - 12px);}
|
||||||
|
|
||||||
|
.card_width80 {width:calc(80% - 12px);}
|
||||||
|
|
||||||
|
.card_width90 {width:calc(90% - 12px);}
|
||||||
|
|
||||||
|
.card_width100 {width:calc(100% - 12px);}
|
||||||
|
|
||||||
|
.card_nopadding {padding:0 !important;}
|
||||||
|
|
||||||
|
.card_nomargin {width:100%;margin:0 !important;padding:0 !important;}
|
||||||
|
|
||||||
|
.topline {border-top: 1px solid #ccc;}
|
||||||
|
|
||||||
|
.bottomline {border-bottom: 1px solid #e6eef3;background: #fff;}
|
||||||
|
|
||||||
|
.card-border {
|
||||||
|
border: 1px solid #dbe2e6;
|
||||||
|
background-color: rgba(255, 255, 255, 0.6);
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
margin-left: -0.6rem;
|
||||||
|
margin-right: -0.6rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-bottom: 1px solid #e1e7eb;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-footer {
|
||||||
|
margin-left: -0.6rem;
|
||||||
|
margin-right: -0.6rem;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-top: 1px solid #e1e7eb;
|
||||||
|
padding-top: 1rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 블랙 테마 */
|
||||||
|
[data-theme="black"] {
|
||||||
|
.card-border {
|
||||||
|
border-color: #3f4042;
|
||||||
|
background-color: rgba(255, 255, 255, 0.065);
|
||||||
|
}
|
||||||
|
.card-header {
|
||||||
|
border-bottom-color: #3f4042;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ export const styles = {
|
|||||||
base: require("./base.css"),
|
base: require("./base.css"),
|
||||||
diveicon: require("./diveicon.css"),
|
diveicon: require("./diveicon.css"),
|
||||||
grid: require("./grid.css"),
|
grid: require("./grid.css"),
|
||||||
|
components: require("./components.css"),
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type StyleType = keyof typeof styles;
|
export type StyleType = keyof typeof styles;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default defineConfig({
|
|||||||
"src/styles/base.css",
|
"src/styles/base.css",
|
||||||
"src/styles/diveicon.css",
|
"src/styles/diveicon.css",
|
||||||
"src/styles/grid.css",
|
"src/styles/grid.css",
|
||||||
|
"src/styles/components.css",
|
||||||
],
|
],
|
||||||
format: ["cjs", "esm"],
|
format: ["cjs", "esm"],
|
||||||
dts: true,
|
dts: true,
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
@import "@common/assets/styles/base.css";
|
||||||
|
@import "@common/assets/styles/diveicon.css";
|
||||||
|
@import "@common/assets/styles/components.css";
|
||||||
|
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
@@ -70,4 +74,4 @@
|
|||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground;
|
@apply bg-background text-foreground;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,9 @@ export * from "./search_input";
|
|||||||
export * from "./search_input_select";
|
export * from "./search_input_select";
|
||||||
export * from "./select";
|
export * from "./select";
|
||||||
export * from "./table";
|
export * from "./table";
|
||||||
|
export * from "./main_content_div";
|
||||||
|
export * from "./title";
|
||||||
|
export * from "./search_form_left";
|
||||||
|
export * from "./search_form_right";
|
||||||
|
export * from "./table_div";
|
||||||
|
export * from "./tab";
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function MainContentDiv(props: {children: React.ReactNode}) {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-gray-50 p-8">
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { MainContentDiv };
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
function SearchDiv ({children}:{ children: React.ReactNode; }) {
|
function SearchDiv ({children}:{ children: React.ReactNode; }) {
|
||||||
return (
|
return (
|
||||||
<div className="flex border border-black m-4 rounded-lg min-h-[80px]">
|
<div className="flex bg-white rounded-lg shadow-sm mb-6 p-6">
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function SearchFormLeft(props: {children: React.ReactNode}) {
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-12 gap-4 w-4/5 mx-4">
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { SearchFormLeft };
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function SearchFormRight(props: {children: React.ReactNode}) {
|
||||||
|
return (
|
||||||
|
<div className="w-1/5 mx-5 flex items-center justify-end space-x-2">
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { SearchFormRight };
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
import { Input, Label } from "@common/components";
|
import { Input, Label } from "@common/components";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const SearchInput = React.forwardRef<
|
const SearchInput = React.forwardRef<HTMLInputElement, {className:string, label:string, textValue:string, setText:(val:string)=>void}>(({className, label, textValue, setText}, ref) => {
|
||||||
HTMLDivElement& HTMLInputElement,
|
const changeText=(e:React.ChangeEvent<HTMLInputElement>)=>{
|
||||||
React.HTMLAttributes<HTMLDivElement> & {className:string, label:string}>
|
if(e?.target?.value) setText(e.target.value)
|
||||||
(({className, label}, ref) => {
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className+" flex"} >
|
<div className={className+" flex items-center"} >
|
||||||
{label && <Label className="m-4 text-2xl w-1/4">{label}</Label>}
|
{label && <Label className="w-20 text-base text-gray-600">{label}</Label>}
|
||||||
<Input className="ml-8 w-3/4 text-lg" ref={ref}></Input>
|
<Input className="flex-1 h-10 p-2 border rounded" value={textValue} onChange={changeText}></Input>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
export { SearchInput };
|
export { SearchInput };
|
||||||
@@ -11,19 +11,23 @@ export type SelectDataType = {
|
|||||||
* @param label - string label
|
* @param label - string label
|
||||||
* @param selectData - SelectDataType[] 선택 데이터
|
* @param selectData - SelectDataType[] 선택 데이터
|
||||||
* @param onSelectValue - (val:string)=>void 선택 값 콜백
|
* @param onSelectValue - (val:string)=>void 선택 값 콜백
|
||||||
|
* @param textValue - string 입력 값
|
||||||
|
* @param setText - (val:string)=>void 입력 값 설정 콜백
|
||||||
|
* @param selectValue - string select 선택 값
|
||||||
* @param refs - React.forwardRef<HTMLInputElement> | null 입력값 ref
|
* @param refs - React.forwardRef<HTMLInputElement> | null 입력값 ref
|
||||||
* @returns React.FC
|
* @returns React.FC
|
||||||
*/
|
*/
|
||||||
const SearchInputSelect = React.forwardRef<HTMLInputElement, {className:string, label:string, selectData: SelectDataType[], onSelectValue:(val:string)=>void, textValue:string, setText:(val:string)=>void}>(({className, label, selectData, onSelectValue, textValue, setText}) => {
|
const SearchInputSelect = React.forwardRef<HTMLInputElement, {className:string, label:string, selectData: SelectDataType[], onSelectValue:(val:string)=>void, textValue:string, setText:(val:string)=>void, selectValue:string}>(({className, label, selectData, onSelectValue, textValue, setText, selectValue}, ref) => {
|
||||||
const changeText=(e:React.ChangeEvent<HTMLInputElement>)=>{
|
const changeText=(e:React.ChangeEvent<HTMLInputElement>)=>{
|
||||||
if(e?.target?.value) setText(e.target.value)
|
if(e?.target?.value) setText(e.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className+" flex items-center"} >
|
<div className={className+" flex items-center"} >
|
||||||
{label && <Label className="m-4 text-2xl w-1/4">{label}</Label>}
|
{label && <Label className="w-20 text-base text-gray-600">{label}</Label>}
|
||||||
<div className="flex w-full items-center">
|
<div className="flex w-full items-center">
|
||||||
<Input className="w-2/3 text-lg" value={textValue} onChange={changeText} />
|
<Input className="w-2/3 text-lg h-10 p-2 border rounded" value={textValue} onChange={changeText} />
|
||||||
<Select onValueChange={onSelectValue}>
|
<Select onValueChange={onSelectValue} value={selectValue}>
|
||||||
<SelectTrigger className="ml-2 w-1/3 text-lg" >
|
<SelectTrigger className="ml-2 w-1/3 text-lg" >
|
||||||
<SelectValue placeholder={selectData?.[0]?.text ?? ""} />
|
<SelectValue placeholder={selectData?.[0]?.text ?? ""} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
@@ -38,4 +42,4 @@ const SearchInputSelect = React.forwardRef<HTMLInputElement, {className:string,
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
export { SearchInputSelect };
|
export { SearchInputSelect };
|
||||||
@@ -4,16 +4,16 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
|
|||||||
|
|
||||||
/** 차트 기본 스타일 */
|
/** 차트 기본 스타일 */
|
||||||
interface SelectBox1 {
|
interface SelectBox1 {
|
||||||
text:string,
|
text:string|number,
|
||||||
val:string
|
val:string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SelectBox = React.forwardRef<
|
const SelectBox = React.forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
React.HTMLAttributes<HTMLDivElement> & {label:string, selectClass:string|undefined, className:string, selectArray:SelectBox1[], onSelectValue:(val:string)=>void}
|
React.HTMLAttributes<HTMLDivElement> & {label:string, selectClass:string|undefined, className:string, selectArray:SelectBox1[], onSelectValue:(val:string)=>void , defaultValue:string|number|undefined }
|
||||||
>(({ label, className, selectClass, selectArray, onSelectValue }, ref)=>{
|
>(({ label, className, selectClass, selectArray, onSelectValue, defaultValue }, ref)=>{
|
||||||
const placeHolder = selectArray?.[0]?.text ?? "";
|
const placeHolder = defaultValue ? selectArray.find(item => defaultValue === item.val)?.text : selectArray?.[0]?.text;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className+" flex items-center"} ref={ref}>
|
<div className={className+" flex items-center"} ref={ref}>
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Tabs, TabsList, TabsTrigger } from '@common/components/ui';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface TabItem {
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UITabProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
defaultValue?: string;
|
||||||
|
tabList: TabItem[];
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UITab = React.forwardRef<
|
||||||
|
HTMLDivElement,
|
||||||
|
UITabProps
|
||||||
|
>(({defaultValue, tabList, children}, ref)=>{
|
||||||
|
return (
|
||||||
|
<Tabs defaultValue={defaultValue || tabList[0]?.value} className={"w-full space-x-1 border-b border-gray-200"}>
|
||||||
|
<TabsList className="flex space-x-1">
|
||||||
|
{tabList.map((tab) => (
|
||||||
|
<TabsTrigger
|
||||||
|
key={tab.value}
|
||||||
|
value={tab.value}
|
||||||
|
className="py-2 px-4 text-sm font-medium border-b-2 focus:outline-none data-[state=active]:border-blue-500 data-[state=active]:text-blue-600 data-[state=inactive]:border-transparent data-[state=inactive]:text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||||
|
>
|
||||||
|
{tab.label}
|
||||||
|
</TabsTrigger>
|
||||||
|
))}
|
||||||
|
</TabsList>
|
||||||
|
{children}
|
||||||
|
</Tabs>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
export { UITab };
|
||||||
@@ -8,7 +8,7 @@ type UiTableProps = {
|
|||||||
pageSize: number;
|
pageSize: number;
|
||||||
total: number;
|
total: number;
|
||||||
children: React.ReactNode | undefined;
|
children: React.ReactNode | undefined;
|
||||||
cellClick : (index:number)=>void | undefined;
|
cellClick : ((index:number|undefined)=>void) | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
type UiHeadProps = {
|
type UiHeadProps = {
|
||||||
@@ -21,21 +21,22 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{headName ? headName : <></>}
|
{headName ? <div className="font-bold m-3">
|
||||||
<Table>
|
{headName}
|
||||||
|
</div> : <></>}
|
||||||
|
<Table className="w-full">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
{children ? <>{children}</> : <TableRow>
|
{children ? <>{children}</> : <TableRow>
|
||||||
{headlist?.map((head) => (
|
{headlist?.map((head) => (
|
||||||
<TableHead key={head.id}>{head.title}</TableHead>
|
<TableHead key={head.id}>{head.title}</TableHead>
|
||||||
))}
|
))}
|
||||||
</TableRow>}
|
</TableRow>}
|
||||||
|
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody className='text-center'>
|
<TableBody className='text-center'>
|
||||||
{tableData?.map((el: { [key: string]: string | number | boolean }, index) => (
|
{tableData?.map((el: { [key: string]: string | number | boolean }, index) => (
|
||||||
<TableRow key={index + "row"} >
|
<TableRow key={index + "row"} >
|
||||||
{headlist.map((head) => (
|
{headlist.map((head) => (
|
||||||
<TableCell onClick={()=>cellClick(index)} key={head.id + index}>{el[head.id]}</TableCell>
|
<TableCell className="cursor-pointer" onClick={()=>cellClick && cellClick(index)} key={head.id + index}>{el[head.id]}</TableCell>
|
||||||
))}
|
))}
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function ContentsDiv(props: {children: React.ReactNode}) {
|
||||||
|
return (
|
||||||
|
<div className="bg-white rounded-lg shadow-sm mb-6 p-6">
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ContentsDiv };
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function Title(props: {title: string}) {
|
||||||
|
return (
|
||||||
|
<h1 className="text-2xl font-bold mb-6">{props.title}</h1>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Title };
|
||||||
@@ -25,10 +25,10 @@ const preview: Preview = {
|
|||||||
withThemeByDataAttribute({
|
withThemeByDataAttribute({
|
||||||
themes: {
|
themes: {
|
||||||
light: "light",
|
light: "light",
|
||||||
dark: "dark",
|
black: "black",
|
||||||
},
|
},
|
||||||
defaultTheme: "light",
|
defaultTheme: "light",
|
||||||
attributeName: "data-mode",
|
attributeName: "data-theme",
|
||||||
}),
|
}),
|
||||||
(Story) => (
|
(Story) => (
|
||||||
<div className="rounded-lg bg-background px-28 py-16">
|
<div className="rounded-lg bg-background px-28 py-16">
|
||||||
|
|||||||
@@ -26,9 +26,11 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@common/assets": "workspace:*",
|
"@common/assets": "workspace:*",
|
||||||
|
"@frontend-opensource/use-react-hooks": "^1.1.4",
|
||||||
"@minoru/react-dnd-treeview": "^3.5.0",
|
"@minoru/react-dnd-treeview": "^3.5.0",
|
||||||
"@radix-ui/react-accordion": "^1.2.3",
|
"@radix-ui/react-accordion": "^1.2.3",
|
||||||
"@radix-ui/react-checkbox": "^1.1.4",
|
"@radix-ui/react-checkbox": "^1.1.4",
|
||||||
|
"@radix-ui/react-collapsible": "^1.1.3",
|
||||||
"@radix-ui/react-dialog": "^1.1.6",
|
"@radix-ui/react-dialog": "^1.1.6",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||||
"@radix-ui/react-label": "^2.1.2",
|
"@radix-ui/react-label": "^2.1.2",
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
export * from "./client";
|
export * from "./client";
|
||||||
|
export * from "./menu";
|
||||||
|
export * from "./site";
|
||||||
export * from "./user";
|
export * from "./user";
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { client } from "./client";
|
||||||
|
import { ENDPOINT } from "../config";
|
||||||
|
|
||||||
|
export interface MenuItem {
|
||||||
|
menuCd: number;
|
||||||
|
menuKornNm: string;
|
||||||
|
menuEngNm: string;
|
||||||
|
parentId: number | null;
|
||||||
|
sortSeq: number;
|
||||||
|
iconNm?: string;
|
||||||
|
children: MenuItem[] | null;
|
||||||
|
levelNo: number;
|
||||||
|
urlPath: string;
|
||||||
|
menuLnkgTypeCd: string;
|
||||||
|
menuLnkgSn: number;
|
||||||
|
qrcd: string;
|
||||||
|
useYn: string;
|
||||||
|
otptYn: string;
|
||||||
|
requiredUrlPath: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getMenuList = async (siteId: string) => {
|
||||||
|
const response = await client.get<MenuItem[]>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { client } from "./client";
|
||||||
|
import { ENDPOINT } from "../config";
|
||||||
|
|
||||||
|
export interface SiteInfo {
|
||||||
|
siteId: string;
|
||||||
|
siteNm: string;
|
||||||
|
siteExpln: string;
|
||||||
|
siteKndCd: string;
|
||||||
|
siteKindNm: string;
|
||||||
|
siteAddr: string;
|
||||||
|
faxNumber: string;
|
||||||
|
telNo: string;
|
||||||
|
lwndCn: string;
|
||||||
|
basicSiteYn: string;
|
||||||
|
bkmkIcon: string;
|
||||||
|
useYn: string;
|
||||||
|
siteSkn: string;
|
||||||
|
regDt: string;
|
||||||
|
rgTr: string;
|
||||||
|
mdfcnDt: string;
|
||||||
|
mdFr: string;
|
||||||
|
rgTrNm: string;
|
||||||
|
mdFrNm: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getSiteInfo = async (siteId: string) => {
|
||||||
|
const response = await client.get<SiteInfo>(
|
||||||
|
`${ENDPOINT.CMS_SERVICE.SITES}/${siteId}`,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ENDPOINT } from "../config";
|
|
||||||
import { client } from "./client";
|
import { client } from "./client";
|
||||||
|
import { ENDPOINT } from "../config";
|
||||||
|
|
||||||
export interface IUser {
|
export interface IUser {
|
||||||
regDt: string;
|
regDt: string;
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { PROXY_HOST } from "./env";
|
|||||||
export const BASE_URL = `${PROXY_HOST}/server`;
|
export const BASE_URL = `${PROXY_HOST}/server`;
|
||||||
|
|
||||||
export const ENDPOINT = {
|
export const ENDPOINT = {
|
||||||
|
CMS_SERVICE: {
|
||||||
|
MENU_ROLES: "/cms-service/api/v1/menu-roles",
|
||||||
|
SITES: "/cms-service/api/v1/sites",
|
||||||
|
},
|
||||||
USER_SERVICE: {
|
USER_SERVICE: {
|
||||||
USERS: "/user-service/api/v1/users",
|
USERS: "/user-service/api/v1/users",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export function getCookie(name: string): string | undefined {
|
|||||||
export function setCookie(
|
export function setCookie(
|
||||||
name: string,
|
name: string,
|
||||||
value: string,
|
value: string,
|
||||||
options: Cookies.CookieAttributes,
|
options?: Cookies.CookieAttributes,
|
||||||
): void {
|
): void {
|
||||||
if (typeof window === "undefined") {
|
if (typeof window === "undefined") {
|
||||||
return;
|
return;
|
||||||
@@ -20,29 +20,10 @@ export function setCookie(
|
|||||||
|
|
||||||
export function removeCookie(
|
export function removeCookie(
|
||||||
name: string,
|
name: string,
|
||||||
options: Cookies.CookieAttributes,
|
options?: Cookies.CookieAttributes,
|
||||||
): void {
|
): void {
|
||||||
if (typeof window === "undefined") {
|
if (typeof window === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Cookies.remove(name, options);
|
Cookies.remove(name, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getToken(key: string): string | undefined {
|
|
||||||
return getCookie(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setToken(
|
|
||||||
key: string,
|
|
||||||
token: string,
|
|
||||||
options: Cookies.CookieAttributes,
|
|
||||||
): void {
|
|
||||||
setCookie(key, token, {
|
|
||||||
...options,
|
|
||||||
path: "/",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeToken(key: string): void {
|
|
||||||
removeCookie(key, { path: "/" });
|
|
||||||
}
|
|
||||||
|
|||||||
+9
-4
@@ -1,9 +1,14 @@
|
|||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
export function QueryProvider({
|
||||||
|
children,
|
||||||
export const QueryProvider = ({ children }: { children: React.ReactNode }) => {
|
client,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
client?: QueryClient;
|
||||||
|
}) {
|
||||||
|
const queryClient = client ?? new QueryClient();
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
@@ -10,16 +10,16 @@
|
|||||||
|
|
||||||
/* 버튼 색상 */
|
/* 버튼 색상 */
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="primary"] {
|
div[role="radiogroup"][data-variant="button"][data-color="primary"] {
|
||||||
@apply border border-primary dark:border-[#404040];
|
@apply border border-primary;
|
||||||
}
|
}
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="primary"] button {
|
div[role="radiogroup"][data-variant="button"][data-color="primary"] button {
|
||||||
@apply text-[#6f98bd] hover:bg-[#ecf3f9] hover:text-[#498bc7] data-[state=checked]:bg-primary data-[state=checked]:text-white dark:bg-[#505050] dark:text-[#aeb7bf] dark:hover:bg-[#525e69] dark:data-[state=checked]:bg-primary dark:data-[state=checked]:text-white;
|
@apply text-[#6f98bd] hover:bg-[#ecf3f9] hover:text-[#498bc7] data-[state=checked]:bg-primary data-[state=checked]:text-white;
|
||||||
}
|
}
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"] {
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"] {
|
||||||
@apply border border-[#ababab] dark:border-[#808080];
|
@apply border border-[#ababab];
|
||||||
}
|
}
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"] button {
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"] button {
|
||||||
@apply bg-[#f3f3f3] text-[#8a8a8a] hover:bg-[#ececec] hover:text-[#808080] data-[state=checked]:bg-[#848484] data-[state=checked]:text-white dark:bg-[#505050] dark:text-[#a5a5a5] dark:hover:bg-[#444444] dark:data-[state=checked]:bg-[#848484] dark:data-[state=checked]:text-white;
|
@apply bg-[#f3f3f3] text-[#8a8a8a] hover:bg-[#ececec] hover:text-[#808080] data-[state=checked]:bg-[#848484] data-[state=checked]:text-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 버튼 모양 */
|
/* 버튼 모양 */
|
||||||
@@ -28,13 +28,37 @@
|
|||||||
}
|
}
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="primary"][data-shape="rounded"]
|
div[role="radiogroup"][data-variant="button"][data-color="primary"][data-shape="rounded"]
|
||||||
button {
|
button {
|
||||||
@apply bg-[#70bcff] text-white hover:bg-[#6bb0ec] data-[state=checked]:bg-primary dark:bg-[#505050] dark:hover:bg-[#525e69] dark:data-[state=checked]:bg-primary;
|
@apply bg-[#70bcff] text-white hover:bg-[#6bb0ec] data-[state=checked]:bg-primary;
|
||||||
}
|
}
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"] {
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"] {
|
||||||
@apply border-[#7b7b7b];
|
@apply border-[#7b7b7b];
|
||||||
}
|
}
|
||||||
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"]
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"]
|
||||||
button {
|
button {
|
||||||
@apply bg-[#b7b7b7] text-white hover:bg-[#a9a9a9] data-[state=checked]:bg-[#797979] dark:bg-[#505050] dark:hover:bg-[#444444] dark:data-[state=checked]:bg-[#797979];
|
@apply bg-[#b7b7b7] text-white hover:bg-[#a9a9a9] data-[state=checked]:bg-[#797979];
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="black"] {
|
||||||
|
div[role="radiogroup"][data-variant="button"][data-color="primary"] {
|
||||||
|
@apply border-[#404040];
|
||||||
|
}
|
||||||
|
div[role="radiogroup"][data-variant="button"][data-color="primary"] button {
|
||||||
|
@apply bg-[#505050] text-[#aeb7bf] hover:bg-[#525e69] data-[state=checked]:bg-primary data-[state=checked]:text-white;
|
||||||
|
}
|
||||||
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"] {
|
||||||
|
@apply border-[#808080];
|
||||||
|
}
|
||||||
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"]
|
||||||
|
button {
|
||||||
|
@apply bg-[#505050] text-[#a5a5a5] hover:bg-[#444444] data-[state=checked]:bg-[#848484] data-[state=checked]:text-white;
|
||||||
|
}
|
||||||
|
div[role="radiogroup"][data-variant="button"][data-color="primary"][data-shape="rounded"]
|
||||||
|
button {
|
||||||
|
@apply bg-[#505050] hover:bg-[#525e69] data-[state=checked]:bg-primary;
|
||||||
|
}
|
||||||
|
div[role="radiogroup"][data-variant="button"][data-color="secondary"][data-shape="rounded"]
|
||||||
|
button {
|
||||||
|
@apply bg-[#505050] hover:bg-[#444444] data-[state=checked]:bg-[#797979];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
|
||||||
|
|
||||||
|
const Collapsible = CollapsiblePrimitive.Root
|
||||||
|
|
||||||
|
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger
|
||||||
|
|
||||||
|
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent
|
||||||
|
|
||||||
|
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { images } from "@common/assets";
|
import { images } from "@common/assets";
|
||||||
import { getUserInfo } from "../../api";
|
import { getCookie, setCookie } from "../../lib";
|
||||||
import { AUTH_USER_ID, ENDPOINT } from "../../config";
|
import { getSiteInfo, getUserInfo } from "../../api";
|
||||||
import { getToken } from "../../lib";
|
import { AUTH_USER_ID, ENDPOINT, SITE_ID } from "../../config";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
@@ -12,15 +12,30 @@ import {
|
|||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
|
|
||||||
export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
||||||
const userUniqId = getToken(AUTH_USER_ID) ?? "";
|
const userUniqId = getCookie(AUTH_USER_ID) ?? "";
|
||||||
|
|
||||||
const { data: userInfo } = useQuery({
|
const { data: userInfo } = useQuery({
|
||||||
queryKey: [ENDPOINT.USER_SERVICE.USERS],
|
queryKey: [ENDPOINT.USER_SERVICE.USERS],
|
||||||
queryFn: () => getUserInfo(userUniqId),
|
queryFn: () => getUserInfo(userUniqId),
|
||||||
enabled: !viewOnly,
|
enabled: !viewOnly,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { data: siteInfo } = useQuery({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.SITES, SITE_ID],
|
||||||
|
queryFn: () => getSiteInfo(SITE_ID),
|
||||||
|
select: (data) => {
|
||||||
|
if (data.siteSkn) {
|
||||||
|
const siteSkin = data.siteSkn.toLowerCase();
|
||||||
|
setCookie("site-theme-key", siteSkin);
|
||||||
|
document.documentElement.setAttribute("data-theme", siteSkin);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
enabled: !viewOnly,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="sticky top-0 box-border flex h-[5rem] w-full items-center justify-between border-b border-solid border-border bg-background">
|
<header className="sticky top-0 z-30 box-border flex h-[5rem] w-full items-center justify-between border-b border-solid border-border bg-background">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<div className="MobMenuBtn">
|
<div className="MobMenuBtn">
|
||||||
<img src={images.menuBtn} />
|
<img src={images.menuBtn} />
|
||||||
@@ -28,7 +43,7 @@ export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
|||||||
<h1 className="flex items-center gap-4">
|
<h1 className="flex items-center gap-4">
|
||||||
<img src={images.logo} className="h-[3rem]" alt="logo" />
|
<img src={images.logo} className="h-[3rem]" alt="logo" />
|
||||||
<span className="text-[1.8rem] font-semibold text-foreground">
|
<span className="text-[1.8rem] font-semibold text-foreground">
|
||||||
통합플랫폼관리
|
{siteInfo?.siteNm}
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,592 @@
|
|||||||
|
export default [
|
||||||
|
"account-box",
|
||||||
|
"account-circle",
|
||||||
|
"add-image",
|
||||||
|
"add-Note",
|
||||||
|
"alarm-add",
|
||||||
|
"alarm-clock",
|
||||||
|
"alarm-off",
|
||||||
|
"alarm-on",
|
||||||
|
"alarm",
|
||||||
|
"alternate",
|
||||||
|
"analytics",
|
||||||
|
"android",
|
||||||
|
"announcement",
|
||||||
|
"app-indicator",
|
||||||
|
"app-list",
|
||||||
|
"app-square",
|
||||||
|
"apple",
|
||||||
|
"apps-square",
|
||||||
|
"apps",
|
||||||
|
"archive-fill",
|
||||||
|
"archive",
|
||||||
|
"arrow-90left-down",
|
||||||
|
"arrow-90left-up",
|
||||||
|
"arrow-90left",
|
||||||
|
"arrow-90right-down",
|
||||||
|
"arrow-90right-up",
|
||||||
|
"arrow-90right",
|
||||||
|
"arrow-back-square-fill",
|
||||||
|
"arrow-back",
|
||||||
|
"arrow-down-square-fill",
|
||||||
|
"arrow-down-square",
|
||||||
|
"arrow-down",
|
||||||
|
"arrow-forward-square-fill",
|
||||||
|
"arrow-forward",
|
||||||
|
"arrow-left-right",
|
||||||
|
"arrow-left-square-fill",
|
||||||
|
"arrow-left-square",
|
||||||
|
"arrow-left",
|
||||||
|
"arrow-lr-up-down",
|
||||||
|
"arrow-reflash",
|
||||||
|
"arrow-reset",
|
||||||
|
"arrow-right-square-fill",
|
||||||
|
"arrow-right-square",
|
||||||
|
"arrow-right",
|
||||||
|
"arrow-up-down",
|
||||||
|
"arrow-up-square-fill",
|
||||||
|
"arrow-up-square",
|
||||||
|
"arrow-up",
|
||||||
|
"arrows-angle-contract",
|
||||||
|
"arrows-angle-expand",
|
||||||
|
"arrows-fullscreen",
|
||||||
|
"aspect-ratio-fill",
|
||||||
|
"aspect-ratio",
|
||||||
|
"assignment-ind",
|
||||||
|
"assignment-turned-in",
|
||||||
|
"assignment",
|
||||||
|
"asterisk",
|
||||||
|
"atm",
|
||||||
|
"badge-4k-fill",
|
||||||
|
"badge-4k",
|
||||||
|
"badge-8k-fill",
|
||||||
|
"badge-8k",
|
||||||
|
"badge-ad-fill",
|
||||||
|
"badge-ad",
|
||||||
|
"badge-cc-fill",
|
||||||
|
"badge-cc",
|
||||||
|
"badge-hd-fill",
|
||||||
|
"badge-hd",
|
||||||
|
"badge-tm-fill",
|
||||||
|
"badge-tm",
|
||||||
|
"bag-check-fill",
|
||||||
|
"bag-check",
|
||||||
|
"bag-fill",
|
||||||
|
"bag",
|
||||||
|
"bags",
|
||||||
|
"bar-chart-fill",
|
||||||
|
"bar-chart",
|
||||||
|
"battery-charging",
|
||||||
|
"battery-emty",
|
||||||
|
"battery-full",
|
||||||
|
"battery-harf",
|
||||||
|
"bell-alert-box-fill",
|
||||||
|
"bell-alert-box",
|
||||||
|
"bell-alert-fill",
|
||||||
|
"bell-alert",
|
||||||
|
"bell-notification-fill",
|
||||||
|
"bell-notification-on-fill",
|
||||||
|
"bell-notification-on",
|
||||||
|
"bell-notification",
|
||||||
|
"bike",
|
||||||
|
"bluetooth",
|
||||||
|
"boat",
|
||||||
|
"book",
|
||||||
|
"bookmark-check-fill",
|
||||||
|
"bookmark-check",
|
||||||
|
"bookmark-fill",
|
||||||
|
"bookmark-new-fill",
|
||||||
|
"bookmark-new",
|
||||||
|
"bookmark-star-fill",
|
||||||
|
"bookmark-star",
|
||||||
|
"bookmark",
|
||||||
|
"boostzone",
|
||||||
|
"box-arrow-backup",
|
||||||
|
"box-arrow-download",
|
||||||
|
"box-arrow-link-blank",
|
||||||
|
"box-arrow-upload",
|
||||||
|
"box-seam",
|
||||||
|
"box",
|
||||||
|
"braces",
|
||||||
|
"briefcase-fill",
|
||||||
|
"briefcase",
|
||||||
|
"brightness-fill",
|
||||||
|
"brightness",
|
||||||
|
"broadcast-pin",
|
||||||
|
"broadcast",
|
||||||
|
"bug-fill",
|
||||||
|
"bug",
|
||||||
|
"building",
|
||||||
|
"bus",
|
||||||
|
"calculator-fill",
|
||||||
|
"calculator",
|
||||||
|
"calendar-check-fill",
|
||||||
|
"calendar-check",
|
||||||
|
"calendar-day-fill",
|
||||||
|
"calendar-day",
|
||||||
|
"calendar-event-fill",
|
||||||
|
"calendar-event",
|
||||||
|
"calendar-fill",
|
||||||
|
"calendar-week-fill",
|
||||||
|
"calendar-week",
|
||||||
|
"calendar",
|
||||||
|
"call-end",
|
||||||
|
"call",
|
||||||
|
"camera-fill",
|
||||||
|
"camera-video-fill",
|
||||||
|
"camera-video",
|
||||||
|
"camera",
|
||||||
|
"car",
|
||||||
|
"card-fill",
|
||||||
|
"card",
|
||||||
|
"caret-down-fill",
|
||||||
|
"caret-down-square-fill",
|
||||||
|
"caret-down-square",
|
||||||
|
"caret-left-fill",
|
||||||
|
"caret-left-square-fill",
|
||||||
|
"caret-left-square",
|
||||||
|
"caret-right-fill",
|
||||||
|
"caret-right-square-fill",
|
||||||
|
"caret-right-square",
|
||||||
|
"caret-up-fill",
|
||||||
|
"caret-up-square-fill",
|
||||||
|
"caret-up-square",
|
||||||
|
"cart-fill",
|
||||||
|
"cart",
|
||||||
|
"cash-stack",
|
||||||
|
"cash",
|
||||||
|
"cast",
|
||||||
|
"cctv",
|
||||||
|
"chat-box-left-dots-fill",
|
||||||
|
"chat-box-left-dots",
|
||||||
|
"chat-box-left-fill",
|
||||||
|
"chat-box-left-text-fill",
|
||||||
|
"chat-box-left-text",
|
||||||
|
"chat-box-left",
|
||||||
|
"chat-box-right-dots-fill",
|
||||||
|
"chat-box-right-dots",
|
||||||
|
"chat-box-right-fill",
|
||||||
|
"chat-box-right-text-fill",
|
||||||
|
"chat-box-right-text",
|
||||||
|
"chat-box-right",
|
||||||
|
"chat-circle-left-dot-fill",
|
||||||
|
"chat-circle-left-dot",
|
||||||
|
"chat-circle-left-fill",
|
||||||
|
"chat-circle-left-text-fill",
|
||||||
|
"chat-circle-left-text",
|
||||||
|
"chat-circle-left",
|
||||||
|
"chat-circle-right-dot-fill",
|
||||||
|
"chat-circle-right-dot",
|
||||||
|
"chat-circle-right-fill",
|
||||||
|
"chat-circle-right-text-fill",
|
||||||
|
"chat-circle-right-text",
|
||||||
|
"chat-circle-right",
|
||||||
|
"check-box",
|
||||||
|
"check-circle-fill",
|
||||||
|
"check-circle-line",
|
||||||
|
"check-circle",
|
||||||
|
"check-square-fill",
|
||||||
|
"check-square-line",
|
||||||
|
"check-square",
|
||||||
|
"check",
|
||||||
|
"chevron-bar-contract",
|
||||||
|
"chevron-bar-down",
|
||||||
|
"chevron-bar-expand",
|
||||||
|
"chevron-bar-left",
|
||||||
|
"chevron-bar-right",
|
||||||
|
"chevron-bar-up",
|
||||||
|
"chevron-contract",
|
||||||
|
"chevron-double-down",
|
||||||
|
"chevron-double-left",
|
||||||
|
"chevron-double-right",
|
||||||
|
"chevron-double-up",
|
||||||
|
"chevron-down",
|
||||||
|
"chevron-expand",
|
||||||
|
"chevron-left",
|
||||||
|
"chevron-right",
|
||||||
|
"chevron-up",
|
||||||
|
"clipboard-check",
|
||||||
|
"clipboard-data",
|
||||||
|
"clipboard-text",
|
||||||
|
"clipboard",
|
||||||
|
"clock-fill",
|
||||||
|
"clock-history",
|
||||||
|
"clock",
|
||||||
|
"cloud-arrow-down-fill",
|
||||||
|
"cloud-arrow-down",
|
||||||
|
"cloud-arrow-up-fill",
|
||||||
|
"cloud-arrow-up",
|
||||||
|
"cloud-check-fill",
|
||||||
|
"cloud-check",
|
||||||
|
"cloud-fill",
|
||||||
|
"cloud",
|
||||||
|
"code-square",
|
||||||
|
"code",
|
||||||
|
"collection-fill",
|
||||||
|
"collection",
|
||||||
|
"compass-fill",
|
||||||
|
"compass",
|
||||||
|
"cone",
|
||||||
|
"controller-fill",
|
||||||
|
"controller",
|
||||||
|
"copyright-sign",
|
||||||
|
"copyright-symbol",
|
||||||
|
"COVID-19-fill",
|
||||||
|
"COVID-19",
|
||||||
|
"cpu-fill",
|
||||||
|
"cpu",
|
||||||
|
"crop",
|
||||||
|
"cup-fill",
|
||||||
|
"cup-straw",
|
||||||
|
"cup",
|
||||||
|
"cursor-fill",
|
||||||
|
"cursor-text",
|
||||||
|
"cursor",
|
||||||
|
"dash-circle-fill",
|
||||||
|
"dash-circle",
|
||||||
|
"dash-square-fill",
|
||||||
|
"dash-square",
|
||||||
|
"dash",
|
||||||
|
"dashboard",
|
||||||
|
"diagram",
|
||||||
|
"diamond-fill",
|
||||||
|
"diamond",
|
||||||
|
"diamond2",
|
||||||
|
"display-fill",
|
||||||
|
"display",
|
||||||
|
"dns",
|
||||||
|
"door-closed-fill",
|
||||||
|
"door-closed",
|
||||||
|
"download_app",
|
||||||
|
"download",
|
||||||
|
"email-fill-notification",
|
||||||
|
"email-fill-open",
|
||||||
|
"email-fill",
|
||||||
|
"email-notification",
|
||||||
|
"email-open",
|
||||||
|
"email",
|
||||||
|
"emergenc_call",
|
||||||
|
"emergenc",
|
||||||
|
"exclamation-chat-fill",
|
||||||
|
"exclamation-chat",
|
||||||
|
"exclamation-circle-fill",
|
||||||
|
"exclamation-circle",
|
||||||
|
"exclamation-diamond-fill",
|
||||||
|
"exclamation-diamond",
|
||||||
|
"exclamation-square-circle",
|
||||||
|
"exclamation-square-fill",
|
||||||
|
"exclamation-square",
|
||||||
|
"exclamation-triangle-fill",
|
||||||
|
"exclamation-triangle",
|
||||||
|
"exclamation",
|
||||||
|
"exclude",
|
||||||
|
"face-id",
|
||||||
|
"facebook-circle",
|
||||||
|
"facebook-square",
|
||||||
|
"favorite-hart",
|
||||||
|
"favorite-star",
|
||||||
|
"file-copy",
|
||||||
|
"file-excel",
|
||||||
|
"file-image",
|
||||||
|
"file-keynote",
|
||||||
|
"file-numbers",
|
||||||
|
"file-powerpoint",
|
||||||
|
"file-text",
|
||||||
|
"file-word",
|
||||||
|
"file",
|
||||||
|
"filter-circle-fill",
|
||||||
|
"filter-circle",
|
||||||
|
"filter-left",
|
||||||
|
"filter-right",
|
||||||
|
"filter-square-fill",
|
||||||
|
"filter-square",
|
||||||
|
"filter",
|
||||||
|
"finder-folder",
|
||||||
|
"finder",
|
||||||
|
"fingerprint",
|
||||||
|
"flag-fill",
|
||||||
|
"flag",
|
||||||
|
"flashlight",
|
||||||
|
"folder-check",
|
||||||
|
"folder-delet",
|
||||||
|
"folder-fill",
|
||||||
|
"folder-open-fill",
|
||||||
|
"folder-open",
|
||||||
|
"folder-plus",
|
||||||
|
"folder-share",
|
||||||
|
"folder-x",
|
||||||
|
"folder",
|
||||||
|
"font",
|
||||||
|
"fullscreen-exit",
|
||||||
|
"fullscreen",
|
||||||
|
"gear-fill",
|
||||||
|
"gear-square-fill",
|
||||||
|
"gear-system-update",
|
||||||
|
"gear",
|
||||||
|
"gem",
|
||||||
|
"geo-alt",
|
||||||
|
"geo-location",
|
||||||
|
"geo-my-location",
|
||||||
|
"gift-fill",
|
||||||
|
"gift",
|
||||||
|
"graph-down",
|
||||||
|
"graph-up",
|
||||||
|
"grid-2-fill",
|
||||||
|
"grid-3-fill",
|
||||||
|
"grid",
|
||||||
|
"grip-horizontal",
|
||||||
|
"grip-vertical",
|
||||||
|
"group",
|
||||||
|
"group2",
|
||||||
|
"hand-index",
|
||||||
|
"harf",
|
||||||
|
"hart-fill",
|
||||||
|
"hart-half",
|
||||||
|
"hash",
|
||||||
|
"hdd-network",
|
||||||
|
"hdd",
|
||||||
|
"hexagon-fill",
|
||||||
|
"hexagon-harf",
|
||||||
|
"hexagon",
|
||||||
|
"history",
|
||||||
|
"home-fill",
|
||||||
|
"home",
|
||||||
|
"hotel_bed",
|
||||||
|
"hotel",
|
||||||
|
"image-fill",
|
||||||
|
"image",
|
||||||
|
"images",
|
||||||
|
"info-box",
|
||||||
|
"info-circle",
|
||||||
|
"info-fill",
|
||||||
|
"info",
|
||||||
|
"instagram-circle",
|
||||||
|
"instagram-fill",
|
||||||
|
"instagram",
|
||||||
|
"intersect",
|
||||||
|
"justify-left",
|
||||||
|
"justify-right",
|
||||||
|
"justify",
|
||||||
|
"kakao-alim-talk",
|
||||||
|
"kakao-circle",
|
||||||
|
"kakao-firend-talk",
|
||||||
|
"kakao-story-circle",
|
||||||
|
"kakao-story",
|
||||||
|
"kakao-talk",
|
||||||
|
"key",
|
||||||
|
"keyboard",
|
||||||
|
"label",
|
||||||
|
"language",
|
||||||
|
"laptop-fill",
|
||||||
|
"laptop",
|
||||||
|
"layer-back",
|
||||||
|
"layer-front",
|
||||||
|
"layer",
|
||||||
|
"lightning-fill",
|
||||||
|
"lightning",
|
||||||
|
"list-check",
|
||||||
|
"list",
|
||||||
|
"local-airport-land",
|
||||||
|
"local-airport",
|
||||||
|
"local-atm",
|
||||||
|
"local-bar",
|
||||||
|
"local-cafe",
|
||||||
|
"local-dining",
|
||||||
|
"local-ev-station",
|
||||||
|
"local-fastfood",
|
||||||
|
"local-gas-station",
|
||||||
|
"local-hospital",
|
||||||
|
"local-laundry",
|
||||||
|
"local-library",
|
||||||
|
"local-museum",
|
||||||
|
"local-restaurant",
|
||||||
|
"local-store",
|
||||||
|
"lock-open",
|
||||||
|
"lock",
|
||||||
|
"map-fill",
|
||||||
|
"map",
|
||||||
|
"menu-close-fill",
|
||||||
|
"menu-close",
|
||||||
|
"menu-open-fill",
|
||||||
|
"menu-open",
|
||||||
|
"mic-fill",
|
||||||
|
"mic-mute-fill",
|
||||||
|
"mic-mute",
|
||||||
|
"mic",
|
||||||
|
"minus",
|
||||||
|
"mobile-android",
|
||||||
|
"mobile-flip",
|
||||||
|
"mobile-fold",
|
||||||
|
"mobile-ios",
|
||||||
|
"mobile-pad",
|
||||||
|
"mobile-store",
|
||||||
|
"mobile",
|
||||||
|
"moon-crescent",
|
||||||
|
"moon-half",
|
||||||
|
"moon",
|
||||||
|
"more-horiz",
|
||||||
|
"more-vert",
|
||||||
|
"movie-fill",
|
||||||
|
"movie",
|
||||||
|
"music-backward-fill",
|
||||||
|
"music-backward",
|
||||||
|
"music-forward-fill",
|
||||||
|
"music-forward",
|
||||||
|
"music-list",
|
||||||
|
"music-pause-fill",
|
||||||
|
"music-pause",
|
||||||
|
"music-play-fill",
|
||||||
|
"music-play",
|
||||||
|
"music-stop-fill",
|
||||||
|
"music-stop",
|
||||||
|
"music",
|
||||||
|
"naver-blog",
|
||||||
|
"naver-circle",
|
||||||
|
"naver",
|
||||||
|
"news",
|
||||||
|
"option",
|
||||||
|
"paperclip",
|
||||||
|
"payment",
|
||||||
|
"pen-fill",
|
||||||
|
"pen",
|
||||||
|
"pencil-fill",
|
||||||
|
"pencil-square",
|
||||||
|
"pencil",
|
||||||
|
"person-fill",
|
||||||
|
"person",
|
||||||
|
"personal-information",
|
||||||
|
"pet",
|
||||||
|
"power",
|
||||||
|
"print",
|
||||||
|
"problem",
|
||||||
|
"profile-smile",
|
||||||
|
"profile",
|
||||||
|
"push-assemble",
|
||||||
|
"push-fill",
|
||||||
|
"push-notification",
|
||||||
|
"push",
|
||||||
|
"question-answer",
|
||||||
|
"question-circle-fill",
|
||||||
|
"question-circle",
|
||||||
|
"question-diamond-fill",
|
||||||
|
"question-diamond",
|
||||||
|
"question-square-fill",
|
||||||
|
"question-square",
|
||||||
|
"question",
|
||||||
|
"radio",
|
||||||
|
"receipt",
|
||||||
|
"refresh-fill",
|
||||||
|
"refresh",
|
||||||
|
"reset-fill",
|
||||||
|
"reset",
|
||||||
|
"rotation-lock",
|
||||||
|
"rotation",
|
||||||
|
"rwis",
|
||||||
|
"search",
|
||||||
|
"server",
|
||||||
|
"share",
|
||||||
|
"shield",
|
||||||
|
"shift-fill",
|
||||||
|
"shift",
|
||||||
|
"shuffle",
|
||||||
|
"silent",
|
||||||
|
"sim",
|
||||||
|
"slash",
|
||||||
|
"sliders",
|
||||||
|
"smart-watch",
|
||||||
|
"sort-alpha-down-alt",
|
||||||
|
"sort-alpha-down",
|
||||||
|
"sort-alpha-up-alt",
|
||||||
|
"sort-alpha-up",
|
||||||
|
"sort-down-alt",
|
||||||
|
"sort-down",
|
||||||
|
"sort-numeric-down-alt",
|
||||||
|
"sort-numeric-down",
|
||||||
|
"sort-numeric-up-alt",
|
||||||
|
"sort-numeric-up",
|
||||||
|
"sort-up-alt",
|
||||||
|
"sort-up",
|
||||||
|
"sound",
|
||||||
|
"soundwave",
|
||||||
|
"square-fill",
|
||||||
|
"square",
|
||||||
|
"star-circle",
|
||||||
|
"star-fill",
|
||||||
|
"star",
|
||||||
|
"statistics-circle",
|
||||||
|
"statistics",
|
||||||
|
"sticky-fill",
|
||||||
|
"sticky",
|
||||||
|
"stoplights-fill",
|
||||||
|
"stoplights",
|
||||||
|
"sunny",
|
||||||
|
"tab",
|
||||||
|
"table",
|
||||||
|
"terminal-fill",
|
||||||
|
"terminal",
|
||||||
|
"ternnel",
|
||||||
|
"textarea-t",
|
||||||
|
"textarea",
|
||||||
|
"thermometer-full",
|
||||||
|
"thermometer-half",
|
||||||
|
"thermometer",
|
||||||
|
"time-end",
|
||||||
|
"time-full",
|
||||||
|
"time-start",
|
||||||
|
"toggle-off",
|
||||||
|
"toggle-on",
|
||||||
|
"toggle",
|
||||||
|
"train",
|
||||||
|
"trash-fill",
|
||||||
|
"trash",
|
||||||
|
"truck-fill",
|
||||||
|
"truck",
|
||||||
|
"ui-checks-grid",
|
||||||
|
"ui-radios-grid",
|
||||||
|
"upload",
|
||||||
|
"vibration",
|
||||||
|
"vms",
|
||||||
|
"volume-down-fill",
|
||||||
|
"volume-down",
|
||||||
|
"volume-mute-fill",
|
||||||
|
"volume-mute",
|
||||||
|
"volume-off-fill",
|
||||||
|
"volume-off",
|
||||||
|
"volume-up-fill",
|
||||||
|
"volume-up",
|
||||||
|
"weather-cloud-fill",
|
||||||
|
"weather-cloud",
|
||||||
|
"weather-cloudy-gusts",
|
||||||
|
"weather-cloudy-windy",
|
||||||
|
"weather-cloudy",
|
||||||
|
"weather-fahrenheit",
|
||||||
|
"weather-fog",
|
||||||
|
"weather-hail",
|
||||||
|
"weather-humidity",
|
||||||
|
"weather-hurricane",
|
||||||
|
"weather-lightning",
|
||||||
|
"weather-rain",
|
||||||
|
"weather-rainny",
|
||||||
|
"weather-snow",
|
||||||
|
"weather-snowflake",
|
||||||
|
"weather-sunny-overcast",
|
||||||
|
"weather-sunny",
|
||||||
|
"weather-thunderstorm",
|
||||||
|
"weather-umbrella",
|
||||||
|
"weather-windy",
|
||||||
|
"whater",
|
||||||
|
"whather-celsius",
|
||||||
|
"wifi-1",
|
||||||
|
"wifi-2",
|
||||||
|
"wifi-off",
|
||||||
|
"wifi",
|
||||||
|
"window",
|
||||||
|
"x-circle-fill",
|
||||||
|
"x-circle",
|
||||||
|
"x-square-fill",
|
||||||
|
"x-square",
|
||||||
|
"x",
|
||||||
|
"zoom-in",
|
||||||
|
"zoom-out",
|
||||||
|
"server-line",
|
||||||
|
];
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import type { Meta, StoryObj } from "@storybook/react";
|
||||||
|
import { IconFinder } from "./index";
|
||||||
|
|
||||||
|
const meta: Meta<typeof IconFinder> = {
|
||||||
|
title: "UI/IconFinder",
|
||||||
|
component: IconFinder,
|
||||||
|
tags: ["autodocs"],
|
||||||
|
argTypes: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof IconFinder>;
|
||||||
|
|
||||||
|
export const Default: Story = {
|
||||||
|
render: () => <IconFinder />,
|
||||||
|
};
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { cn } from "../../lib";
|
||||||
|
import { Button } from "../button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from "../dialog";
|
||||||
|
import { Input } from "../input";
|
||||||
|
import iconNames from "./data";
|
||||||
|
|
||||||
|
type IconFinderProps = {
|
||||||
|
handleClick?: (icon: string) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const IconFinder = ({ handleClick }: IconFinderProps) => {
|
||||||
|
const [selectedIcon, setSelectedIcon] = useState("");
|
||||||
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
const [filteredIconNames, setFilteredIconNames] = useState(iconNames);
|
||||||
|
|
||||||
|
const handleIconClick = (icon: string) => {
|
||||||
|
setSelectedIcon(icon);
|
||||||
|
handleClick?.(icon);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = e.target.value;
|
||||||
|
setInputValue(value);
|
||||||
|
setFilteredIconNames(iconNames.filter((icon) => icon.includes(value)));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button className="leading-none">
|
||||||
|
<i className="diveicon di-search" />
|
||||||
|
아이콘 찾기
|
||||||
|
</Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent className="flex h-[65rem] max-w-[65rem] flex-col items-start overflow-y-auto">
|
||||||
|
<div className="sticky top-0 z-10 w-full bg-background">
|
||||||
|
<DialogHeader className="w-full">
|
||||||
|
<DialogTitle className="-mt-6 flex items-center justify-between bg-background pt-6">
|
||||||
|
아이콘 찾기
|
||||||
|
<DialogClose asChild>
|
||||||
|
<button className="flex size-6 items-center justify-center rounded-full">
|
||||||
|
<i className="diveicon di-x text-base text-muted-foreground" />
|
||||||
|
</button>
|
||||||
|
</DialogClose>
|
||||||
|
</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<Input
|
||||||
|
value={inputValue}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
className="mt-6 !text-[1.3rem] text-foreground"
|
||||||
|
placeholder="아이콘 이름 검색"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-5 gap-6 text-[2.4rem]">
|
||||||
|
{filteredIconNames.map((icon) => (
|
||||||
|
<IconItem
|
||||||
|
key={icon}
|
||||||
|
icon={icon}
|
||||||
|
selectedIcon={selectedIcon}
|
||||||
|
handleClick={handleIconClick}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const IconItem = ({
|
||||||
|
icon,
|
||||||
|
selectedIcon,
|
||||||
|
handleClick,
|
||||||
|
}: {
|
||||||
|
icon: string;
|
||||||
|
selectedIcon: string;
|
||||||
|
handleClick: (icon: string) => void;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"relative flex cursor-pointer flex-col items-center gap-2 rounded-md p-4",
|
||||||
|
selectedIcon === icon && "bg-accent",
|
||||||
|
)}
|
||||||
|
onClick={() => handleClick(icon)}
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className={cn(
|
||||||
|
"diveicon di-check absolute left-4 top-4 text-[1rem] text-primary",
|
||||||
|
selectedIcon !== icon && "hidden",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<i className={`diveicon di-${icon} text-foreground`} />
|
||||||
|
<span className="text-center text-[1.2rem] text-foreground">{icon}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { IconFinder };
|
||||||
@@ -7,8 +7,8 @@ export * from "./data-table";
|
|||||||
export * from "./date-picker";
|
export * from "./date-picker";
|
||||||
export * from "./dialog";
|
export * from "./dialog";
|
||||||
export * from "./dropdown-menu";
|
export * from "./dropdown-menu";
|
||||||
export * from "./input";
|
|
||||||
export * from "./file-search";
|
export * from "./file-search";
|
||||||
|
export * from "./icon-finder";
|
||||||
export * from "./input";
|
export * from "./input";
|
||||||
export * from "./label";
|
export * from "./label";
|
||||||
export * from "./layout";
|
export * from "./layout";
|
||||||
|
|||||||
@@ -3,15 +3,13 @@ import * as React from "react";
|
|||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
|
|
||||||
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
||||||
({ className, type, value, ...props }, ref) => {
|
({ className, ...props }, ref) => {
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type={type}
|
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-[3.2rem] w-full rounded-md border border-input bg-form px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
"flex h-[3.2rem] w-full rounded-md border border-input bg-form px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
value={value ?? ""}
|
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,28 +1,35 @@
|
|||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryProvider } from "../../provider/query-provider";
|
||||||
|
import { SidebarProvider } from "../sidebar";
|
||||||
import { LNB } from "./lnb";
|
import { LNB } from "../lnb";
|
||||||
import { Header } from "../header";
|
import { Header } from "../header";
|
||||||
import { Footer } from "./footer";
|
import { Footer } from "./footer";
|
||||||
|
|
||||||
import "./common.css";
|
import "./common.css";
|
||||||
|
import type { QueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
export function BaseLayout({
|
||||||
|
children,
|
||||||
export function BaseLayout({ children }: { children: React.ReactNode }) {
|
queryClient,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
queryClient?: QueryClient;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryProvider client={queryClient}>
|
||||||
<div>
|
<SidebarProvider>
|
||||||
<Header />
|
<div className="flex-1">
|
||||||
<div className="flex h-[calc(100vh-50px)]">
|
<Header />
|
||||||
<LNB />
|
<div className="flex h-[calc(100vh-50px)]">
|
||||||
<div className="flex flex-1 flex-col">
|
<LNB />
|
||||||
<div className="max-h-[calc(100%-50px)] flex-1 overflow-auto">
|
<div className="flex flex-1 flex-col">
|
||||||
{children}
|
<div className="max-h-[calc(100%-50px)] flex-1 overflow-auto">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</SidebarProvider>
|
||||||
</QueryClientProvider>
|
</QueryProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
export function LNB() {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
id="lnb"
|
|
||||||
className="!w-[22rem] overflow-auto border-r border-solid border-border bg-background"
|
|
||||||
>
|
|
||||||
<ul>
|
|
||||||
<li id="m_dashboard">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Dashboard
|
|
||||||
<i
|
|
||||||
className="diveicon di-diveicon di-chevron-down arrow"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<div className="mline">PAGES</div>
|
|
||||||
<li id="m_page_board">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
콘텐츠 관리
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_page_mem">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
로그인 & 회원관리
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_page_manage">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
페이지 관리
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_page_example">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
샘플 페이지
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_layouts">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
페이지 레이아웃
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<div className="mline">COMPONENTS</div>
|
|
||||||
<li id="m_charts">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Charts
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_tables">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Tables
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_elements">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Elements
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_tabs">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Tabs
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_popup">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Modal
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_swipe">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Swipe
|
|
||||||
<i className="diveicon di-chevron-down arrow" aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_icon">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Font Icon
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<div className="mline">OTHERS</div>
|
|
||||||
<li id="m_elements">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
Menu Label <span className="ar_label_box red">NEW</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li id="m_elements">
|
|
||||||
<a href="#none" className="!bg-background">
|
|
||||||
External Link
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,28 +1,35 @@
|
|||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryProvider } from "../../provider/query-provider";
|
||||||
|
import { SidebarProvider } from "../sidebar";
|
||||||
import { LNB } from "./lnb";
|
import { LNB } from "../lnb";
|
||||||
import { Header } from "../header";
|
import { Header } from "../header";
|
||||||
import { Footer } from "./footer";
|
import { Footer } from "./footer";
|
||||||
|
|
||||||
import "./common.css";
|
import "./common.css";
|
||||||
|
import type { QueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
export function VBaseLayout({
|
||||||
|
children,
|
||||||
export function VBaseLayout({ children }: { children: React.ReactNode }) {
|
queryClient,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
queryClient?: QueryClient;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryProvider client={queryClient}>
|
||||||
<div>
|
<SidebarProvider>
|
||||||
<Header viewOnly />
|
<div className="flex-1">
|
||||||
<div className="flex h-[calc(100vh-50px)]">
|
<Header viewOnly />
|
||||||
<LNB />
|
<div className="flex h-[calc(100vh-50px)]">
|
||||||
<div className="flex flex-1 flex-col">
|
<LNB viewOnly />
|
||||||
<div className="max-h-[calc(100%-50px)] flex-1 overflow-auto">
|
<div className="flex flex-1 flex-col">
|
||||||
{children}
|
<div className="max-h-[calc(100%-50px)] flex-1 overflow-auto">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</SidebarProvider>
|
||||||
</QueryClientProvider>
|
</QueryProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { ChevronRight } from "lucide-react";
|
||||||
|
import { cn } from "../../lib/utils";
|
||||||
|
import { ENDPOINT, SITE_ID } from "../../config";
|
||||||
|
import { getMenuList, type MenuItem } from "../../api";
|
||||||
|
import {
|
||||||
|
Sidebar,
|
||||||
|
SidebarContent,
|
||||||
|
SidebarMenu,
|
||||||
|
SidebarMenuButton,
|
||||||
|
SidebarMenuItem,
|
||||||
|
SidebarMenuSub,
|
||||||
|
} from "../sidebar";
|
||||||
|
import {
|
||||||
|
Collapsible,
|
||||||
|
CollapsibleContent,
|
||||||
|
CollapsibleTrigger,
|
||||||
|
} from "../collapsible";
|
||||||
|
import { getParentIds } from "./lib";
|
||||||
|
|
||||||
|
export function LNB({ viewOnly }: { viewOnly?: boolean }) {
|
||||||
|
const { data: menuList } = useQuery({
|
||||||
|
queryKey: [ENDPOINT.CMS_SERVICE.MENU_ROLES],
|
||||||
|
queryFn: () => getMenuList(SITE_ID),
|
||||||
|
enabled: !viewOnly,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [openMenuIds, setOpenMenuIds] = useState<number[]>([]);
|
||||||
|
|
||||||
|
function MenuItem({ item }: { item: MenuItem }) {
|
||||||
|
if (item.children) {
|
||||||
|
return <MenuGroup item={item} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SidebarMenuItem>
|
||||||
|
<SidebarMenuButton className="h-auto py-4 text-[1.4rem] text-label transition-colors hover:bg-accent">
|
||||||
|
<i className={cn("diveicon ml-2", `di-${item.iconNm}`)} />
|
||||||
|
{item.menuKornNm}
|
||||||
|
</SidebarMenuButton>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MenuGroup({ item }: { item: MenuItem }) {
|
||||||
|
const isOpen = openMenuIds.includes(item.menuCd);
|
||||||
|
|
||||||
|
const handleOpenChange = (open: boolean) => {
|
||||||
|
if (open) {
|
||||||
|
if (!openMenuIds.includes(item.menuCd)) {
|
||||||
|
const parentIds = getParentIds(item.menuCd)(menuList ?? []);
|
||||||
|
setOpenMenuIds([...parentIds, item.menuCd]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setOpenMenuIds((prev) => prev.filter((id) => id !== item.menuCd));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Collapsible open={isOpen} onOpenChange={handleOpenChange}>
|
||||||
|
<SidebarMenuItem>
|
||||||
|
<CollapsibleTrigger asChild>
|
||||||
|
<div className="group flex items-center justify-between rounded-sm py-4 pr-2 hover:bg-accent data-[state=open]:text-primary">
|
||||||
|
<SidebarMenuButton className="group/menu-button text-[1.4rem] group-data-[state=open]:bg-transparent">
|
||||||
|
<i
|
||||||
|
className={cn(
|
||||||
|
"diveicon ml-2 text-label group-data-[state=open]:text-primary",
|
||||||
|
`di-${item.iconNm}`,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<span className="text-label group-hover/menu-button:text-foreground group-data-[state=open]:text-primary">
|
||||||
|
{item.menuKornNm}
|
||||||
|
</span>
|
||||||
|
</SidebarMenuButton>
|
||||||
|
<ChevronRight className="size-6 text-label group-data-[state=open]:rotate-90" />
|
||||||
|
</div>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
<CollapsibleContent>
|
||||||
|
<SidebarMenuSub className="mr-0">
|
||||||
|
{item.children?.map((child) => (
|
||||||
|
<MenuItem key={child.menuCd} item={child} />
|
||||||
|
))}
|
||||||
|
</SidebarMenuSub>
|
||||||
|
</CollapsibleContent>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
</Collapsible>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Sidebar className="border-border bg-background px-4 py-[6rem]">
|
||||||
|
<SidebarContent className="bg-background">
|
||||||
|
<SidebarMenu className="gap-0">
|
||||||
|
{menuList?.map((item) => <MenuItem key={item.menuCd} item={item} />)}
|
||||||
|
</SidebarMenu>
|
||||||
|
</SidebarContent>
|
||||||
|
</Sidebar>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { MenuItem } from "../../api";
|
||||||
|
|
||||||
|
function getParentIds(menuCd: number): (menuList: MenuItem[]) => number[] {
|
||||||
|
return (menuList: MenuItem[]) => {
|
||||||
|
const parentIds: number[] = [];
|
||||||
|
let currentId = menuCd;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const menu = findMenuById(currentId)(menuList);
|
||||||
|
if (!menu || !menu.parentId) break;
|
||||||
|
parentIds.push(menu.parentId);
|
||||||
|
currentId = menu.parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parentIds;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function findMenuById(
|
||||||
|
menuCd: number,
|
||||||
|
): (menuList: MenuItem[]) => MenuItem | undefined {
|
||||||
|
function findInMenu(items: MenuItem[]): MenuItem | undefined {
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.menuCd === menuCd) return item;
|
||||||
|
if (item.children) {
|
||||||
|
const found = findInMenu(item.children);
|
||||||
|
if (found) return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return findInMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { getParentIds, findMenuById };
|
||||||
@@ -11,7 +11,7 @@ type Story = StoryObj<typeof LoadingWithAnimation>;
|
|||||||
|
|
||||||
export const Primary: Story = {
|
export const Primary: Story = {
|
||||||
render: () => (
|
render: () => (
|
||||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
<div className="[data-theme='black']:bg-transparent rounded-lg bg-secondary p-10">
|
||||||
<div className="relative size-[5rem]">
|
<div className="relative size-[5rem]">
|
||||||
<LoadingWithAnimation color="primary" />
|
<LoadingWithAnimation color="primary" />
|
||||||
</div>
|
</div>
|
||||||
@@ -21,7 +21,7 @@ export const Primary: Story = {
|
|||||||
|
|
||||||
export const Secondary: Story = {
|
export const Secondary: Story = {
|
||||||
render: () => (
|
render: () => (
|
||||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
<div className="[data-theme='black']:bg-transparent rounded-lg bg-secondary p-10">
|
||||||
<div className="relative size-[5rem]">
|
<div className="relative size-[5rem]">
|
||||||
<LoadingWithAnimation color="secondary" />
|
<LoadingWithAnimation color="secondary" />
|
||||||
</div>
|
</div>
|
||||||
@@ -31,7 +31,7 @@ export const Secondary: Story = {
|
|||||||
|
|
||||||
export const PrimaryWithImage: Story = {
|
export const PrimaryWithImage: Story = {
|
||||||
render: () => (
|
render: () => (
|
||||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
<div className="[data-theme='black']:bg-transparent rounded-lg bg-secondary p-10">
|
||||||
<div className="relative size-[5rem]">
|
<div className="relative size-[5rem]">
|
||||||
<LoadingWithImage color="primary" />
|
<LoadingWithImage color="primary" />
|
||||||
</div>
|
</div>
|
||||||
@@ -41,7 +41,7 @@ export const PrimaryWithImage: Story = {
|
|||||||
|
|
||||||
export const SecondaryWithImage: Story = {
|
export const SecondaryWithImage: Story = {
|
||||||
render: () => (
|
render: () => (
|
||||||
<div className="rounded-lg bg-secondary p-10 dark:bg-transparent">
|
<div className="[data-theme='black']:bg-transparent rounded-lg bg-secondary p-10">
|
||||||
<div className="relative size-[5rem]">
|
<div className="relative size-[5rem]">
|
||||||
<LoadingWithImage color="secondary" />
|
<LoadingWithImage color="secondary" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Slot } from "@radix-ui/react-slot";
|
|||||||
import { type VariantProps, cva } from "class-variance-authority";
|
import { type VariantProps, cva } from "class-variance-authority";
|
||||||
import { PanelLeft } from "lucide-react";
|
import { PanelLeft } from "lucide-react";
|
||||||
|
|
||||||
import { useIsMobile } from "../../hooks/use-mobile";
|
import { useIsMobile } from "../../lib/use-mobile";
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { Input } from "../input";
|
import { Input } from "../input";
|
||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
|
|
||||||
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
||||||
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
||||||
const SIDEBAR_WIDTH = "16rem";
|
const SIDEBAR_WIDTH = "22rem";
|
||||||
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
||||||
const SIDEBAR_WIDTH_ICON = "3rem";
|
const SIDEBAR_WIDTH_ICON = "3rem";
|
||||||
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
@apply bg-[#5987bf] px-4 py-[1.2rem] text-[1.3rem] font-medium leading-[1.2] text-[#fff];
|
@apply bg-[#5987bf] px-4 py-[1.2rem] text-[1.3rem] font-medium leading-[1.2] text-[#fff];
|
||||||
}
|
}
|
||||||
.table-ui td {
|
.table-ui td {
|
||||||
@apply border-b border-b-border px-2 py-[1.2rem] text-[1.3rem] font-normal leading-[1.2] text-[#666];
|
@apply border-b border-b-border px-2 py-[1.2rem] text-[1.3rem] font-normal leading-[1.2] text-label;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-ui.secondary th {
|
.table-ui.secondary th {
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
@apply border-b border-b-border;
|
@apply border-b border-b-border;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-mode="dark"] {
|
[data-theme="black"] {
|
||||||
.table-ui th {
|
.table-ui th {
|
||||||
@apply bg-[#5e7b9c] text-[#fff];
|
@apply bg-[#5e7b9c] text-[#fff];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import presetConfig from "../../../tailwind.config.preset";
|
|||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
export default {
|
export default {
|
||||||
presets: [presetConfig],
|
presets: [presetConfig],
|
||||||
darkMode: ["class", "[data-mode='dark']"],
|
|
||||||
content: ["./src/**/*.{ts,tsx,js,jsx}", "./.storybook/**/*.{ts,tsx,js,jsx}"],
|
content: ["./src/**/*.{ts,tsx,js,jsx}", "./.storybook/**/*.{ts,tsx,js,jsx}"],
|
||||||
plugins: [require("tailwindcss-animate")],
|
plugins: [require("tailwindcss-animate")],
|
||||||
};
|
};
|
||||||
|
|||||||
Generated
+12
@@ -51,6 +51,9 @@ importers:
|
|||||||
'@hookform/resolvers':
|
'@hookform/resolvers':
|
||||||
specifier: ^4.1.3
|
specifier: ^4.1.3
|
||||||
version: 4.1.3(react-hook-form@7.54.2)
|
version: 4.1.3(react-hook-form@7.54.2)
|
||||||
|
'@minoru/react-dnd-treeview':
|
||||||
|
specifier: ^3.5.0
|
||||||
|
version: 3.5.0(dnd-core@16.0.1)(react-dnd@16.0.1)(react-dom@18.3.1)(react@18.3.1)
|
||||||
'@radix-ui/react-label':
|
'@radix-ui/react-label':
|
||||||
specifier: ^2.1.2
|
specifier: ^2.1.2
|
||||||
version: 2.1.2(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
version: 2.1.2(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
||||||
@@ -81,6 +84,9 @@ importers:
|
|||||||
react-chartjs-2:
|
react-chartjs-2:
|
||||||
specifier: ^5.3.0
|
specifier: ^5.3.0
|
||||||
version: 5.3.0(chart.js@4.4.8)(react@18.3.1)
|
version: 5.3.0(chart.js@4.4.8)(react@18.3.1)
|
||||||
|
react-dnd:
|
||||||
|
specifier: ^16.0.1
|
||||||
|
version: 16.0.1(@types/node@22.13.5)(@types/react@18.3.18)(react@18.3.1)
|
||||||
react-hook-form:
|
react-hook-form:
|
||||||
specifier: ^7.54.2
|
specifier: ^7.54.2
|
||||||
version: 7.54.2(react@18.3.1)
|
version: 7.54.2(react@18.3.1)
|
||||||
@@ -354,6 +360,9 @@ importers:
|
|||||||
'@common/assets':
|
'@common/assets':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../assets
|
version: link:../assets
|
||||||
|
'@frontend-opensource/use-react-hooks':
|
||||||
|
specifier: ^1.1.4
|
||||||
|
version: 1.1.4
|
||||||
'@minoru/react-dnd-treeview':
|
'@minoru/react-dnd-treeview':
|
||||||
specifier: ^3.5.0
|
specifier: ^3.5.0
|
||||||
version: 3.5.0(dnd-core@16.0.1)(react-dnd@16.0.1)(react-dom@18.3.1)(react@18.3.1)
|
version: 3.5.0(dnd-core@16.0.1)(react-dnd@16.0.1)(react-dom@18.3.1)(react@18.3.1)
|
||||||
@@ -363,6 +372,9 @@ importers:
|
|||||||
'@radix-ui/react-checkbox':
|
'@radix-ui/react-checkbox':
|
||||||
specifier: ^1.1.4
|
specifier: ^1.1.4
|
||||||
version: 1.1.4(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
version: 1.1.4(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
||||||
|
'@radix-ui/react-collapsible':
|
||||||
|
specifier: ^1.1.3
|
||||||
|
version: 1.1.3(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
||||||
'@radix-ui/react-dialog':
|
'@radix-ui/react-dialog':
|
||||||
specifier: ^1.1.6
|
specifier: ^1.1.6
|
||||||
version: 1.1.6(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
version: 1.1.6(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
|
||||||
|
|||||||
Reference in New Issue
Block a user