Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c29017fb51 | ||
|
|
ccf20ee7eb |
+4
-7
@@ -1,12 +1,8 @@
|
||||
# turbo
|
||||
.turbo/
|
||||
.turbo
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# build
|
||||
.next/
|
||||
dist/
|
||||
node_modules
|
||||
|
||||
# build
|
||||
.next
|
||||
@@ -14,7 +10,8 @@ dist
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
apps/wr/.next/**/*
|
||||
apps/fo/.next/**/*
|
||||
|
||||
# env
|
||||
.env*
|
||||
.qodo
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
NEXT_PUBLIC_PORT=3000
|
||||
NEXT_PUBLIC_SERVER_API_URL=http://localhost:8000
|
||||
NEXT_PUBLIC_SERVER_API_URL=http://192.168.0.102:8000
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
import { ImagePage } from "@/pages/image";
|
||||
export default ImagePage;
|
||||
@@ -1,27 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import type { MenuItem } from "@common/components/api";
|
||||
import { BaseLayout } from "@common/components/ui";
|
||||
import { MenuWrapper } from "@/entities/menu";
|
||||
import { useMenuStore } from "@/shared/lib";
|
||||
|
||||
export default function WithBaseLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { setCurrentMenuInfo } = useMenuStore((state) => state);
|
||||
|
||||
const handleMenuClick = (item: MenuItem) => {
|
||||
setCurrentMenuInfo(item);
|
||||
router.push(item.urlPath);
|
||||
};
|
||||
|
||||
return (
|
||||
<BaseLayout currentPath={pathname ?? ""} handleMenuClick={handleMenuClick}>
|
||||
<MenuWrapper>{children}</MenuWrapper>
|
||||
</BaseLayout>
|
||||
);
|
||||
return <BaseLayout>{children}</BaseLayout>;
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
import { MenuPage } from "@/pages/menu";
|
||||
export default MenuPage;
|
||||
@@ -11,11 +11,6 @@ const compat = new FlatCompat({
|
||||
|
||||
const eslintConfig = [
|
||||
...compat.extends("next/core-web-vitals", "next/typescript"),
|
||||
{
|
||||
rules: {
|
||||
"react-hooks/exhaustive-deps": "off",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default eslintConfig;
|
||||
|
||||
+4
-13
@@ -5,24 +5,15 @@ const serverApiUrl =
|
||||
|
||||
export function middleware(req: NextRequest) {
|
||||
const pathname = req.nextUrl.pathname;
|
||||
const searchParams = req.nextUrl.searchParams;
|
||||
|
||||
if (pathname.startsWith("/server")) {
|
||||
const queryParams = searchParams.toString();
|
||||
const newUrl = `${serverApiUrl}${pathname.replace("/server", "")}${
|
||||
queryParams ? `?${queryParams}` : ""
|
||||
}`;
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/attach-service")) {
|
||||
const newUrl = `${serverApiUrl}${pathname}`;
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
return NextResponse.rewrite(
|
||||
`${serverApiUrl}${pathname.replace("/server", "")}`,
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/server/:path*", "/attach-service/:path*"],
|
||||
matcher: "/server/:path*",
|
||||
};
|
||||
|
||||
+33
-1
@@ -1,5 +1,37 @@
|
||||
import type { NextConfig } from "next";
|
||||
import webpack from "webpack";
|
||||
|
||||
const nextConfig: NextConfig = {};
|
||||
const nextConfig: NextConfig = {
|
||||
webpack: (config) => {
|
||||
config.plugins.push(
|
||||
new webpack.DefinePlugin({
|
||||
"import.meta.env.VITE_PORT": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_PORT,
|
||||
),
|
||||
"import.meta.env.VITE_PROXY_HOST": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_PROXY_HOST,
|
||||
),
|
||||
"import.meta.env.VITE_SERVER_API_URL": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_SERVER_API_URL,
|
||||
),
|
||||
"import.meta.env.VITE_SITE_ID": JSON.stringify(process.env.SITE_ID),
|
||||
"import.meta.env.VITE_CLAIM_NAME": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_CLAIM_NAME,
|
||||
),
|
||||
"import.meta.env.VITE_ACCESS_TOKEN": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_ACCESS_TOKEN,
|
||||
),
|
||||
"import.meta.env.VITE_REFRESH_TOKEN": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_REFRESH_TOKEN,
|
||||
),
|
||||
"import.meta.env.VITE_AUTH_USER_ID": JSON.stringify(
|
||||
process.env.NEXT_PUBLIC_AUTH_USER_ID,
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev": "NODE_OPTIONS='--inspect' next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
@@ -13,7 +13,6 @@
|
||||
"@common/components": "workspace:*",
|
||||
"@frontend-opensource/use-react-hooks": "^1.1.4",
|
||||
"@hookform/resolvers": "^4.1.3",
|
||||
"@minoru/react-dnd-treeview": "^3.5.0",
|
||||
"@radix-ui/react-label": "^2.1.2",
|
||||
"@radix-ui/react-slot": "^1.1.2",
|
||||
"@tanstack/react-query": "^5.67.1",
|
||||
@@ -24,10 +23,8 @@
|
||||
"js-cookie": "^3.0.5",
|
||||
"next": "15.1.7",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
"react-dnd": "^16.0.1",
|
||||
"react-hook-form": "^7.54.2",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"tus-js-client": "^4.3.1",
|
||||
"zod": "^3.24.2",
|
||||
"zustand": "^5.0.3"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import "./styles/base.css";
|
||||
import "./styles/components.css";
|
||||
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 (
|
||||
<html lang="ko" data-theme={theme?.value}>
|
||||
<html lang="ko">
|
||||
<body>
|
||||
<AppProvider>{children}</AppProvider>
|
||||
</body>
|
||||
|
||||
@@ -2,18 +2,16 @@
|
||||
|
||||
import { ConfirmProvider } from "@frontend-opensource/use-react-hooks";
|
||||
import { AuthWrapper } from "@/entities/auth";
|
||||
import { StoreProvider } from "@/shared/providers";
|
||||
import { AlertDialog } from "@/shared/ui/alert-dialog";
|
||||
import { QueryProvider, StoreProvider } from "@/shared/providers";
|
||||
|
||||
const AppProvider = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||
return (
|
||||
<StoreProvider>
|
||||
<ConfirmProvider>
|
||||
<AuthWrapper>
|
||||
{children}
|
||||
<AlertDialog />
|
||||
</AuthWrapper>
|
||||
</ConfirmProvider>
|
||||
<QueryProvider>
|
||||
<ConfirmProvider>
|
||||
<AuthWrapper>{children}</AuthWrapper>
|
||||
</ConfirmProvider>
|
||||
</QueryProvider>
|
||||
</StoreProvider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,129 +1,25 @@
|
||||
.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;
|
||||
}
|
||||
@tailwind components;
|
||||
|
||||
.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-top: -0.6rem;
|
||||
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"] {
|
||||
@layer components {
|
||||
.card {
|
||||
@apply relative m-[0.6rem] box-border min-h-[2rem] rounded-[0.5rem] p-[0.6rem] text-[1.3rem] text-[#666];
|
||||
}
|
||||
.card-border {
|
||||
background-color: rgba(255, 255, 255, 0.065);
|
||||
border-color: #38383a;
|
||||
@apply border border-[#dbe2e6] bg-[rgba(255,255,255,0.6)] shadow-blur;
|
||||
}
|
||||
.card-header {
|
||||
border-bottom-color: #3f4042;
|
||||
@apply -mx-[0.6rem] flex items-center justify-between border-b border-b-[#e1e7eb] p-4;
|
||||
}
|
||||
.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,2 +1,2 @@
|
||||
export { LoginApi } from "./api/login-service";
|
||||
export { AuthWrapper } from "./lib/auth-wrapper";
|
||||
export { AuthWrapper } from "./ui/auth-wrapper";
|
||||
|
||||
+20
-23
@@ -1,47 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { client } from "@/shared/api";
|
||||
import type { IUserInfo } from "@/shared/store";
|
||||
import { getCookie, useUserStore } from "@/shared/lib";
|
||||
import { ENDPOINT, AUTH_USER_ID } from "@/shared/config";
|
||||
import { getCookie, useUserStore } from "@/shared/lib";
|
||||
import type { IUserInfo } from "@/shared/store";
|
||||
import { LoginApi } from "../api/login-service";
|
||||
|
||||
const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
const router = useRouter();
|
||||
const { userInfo, setUserInfo } = useUserStore((state) => state);
|
||||
const { setUserInfo } = useUserStore((state) => state);
|
||||
|
||||
async function authCheck() {
|
||||
const userId = getCookie(AUTH_USER_ID);
|
||||
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 () => {
|
||||
useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.USERS],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
await authCheck();
|
||||
const userId = getCookie(AUTH_USER_ID);
|
||||
|
||||
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) {
|
||||
console.error(error);
|
||||
|
||||
try {
|
||||
await LoginApi.silentRefresh();
|
||||
await authCheck();
|
||||
} catch (refreshError) {
|
||||
console.error("Token refresh failed:", refreshError);
|
||||
setUserInfo(null);
|
||||
router.push("/auth/login");
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
},
|
||||
});
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
BoardPopupList,
|
||||
BoardPopupParams,
|
||||
BoardService,
|
||||
} from "../model/board-interface";
|
||||
|
||||
export class BoardApiService implements BoardService {
|
||||
public async getBoardPopupList(
|
||||
params: BoardPopupParams,
|
||||
): Promise<BoardPopupList> {
|
||||
const response = await client.get<BoardPopupList>(
|
||||
`${ENDPOINT.BOARD_SERVICE.BBS}`,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const BoardApi = new BoardApiService();
|
||||
@@ -1,2 +0,0 @@
|
||||
export { BoardApi } from "./api/board-service";
|
||||
export { type BoardPopup } from "./model/board-interface";
|
||||
@@ -1,42 +0,0 @@
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export const BOARD_TYPE = {
|
||||
BBSNORMAL: "BBSNORMAL",
|
||||
BBSFAQ: "BBSFAQ",
|
||||
BBSIMAGE: "BBSIMAGE",
|
||||
BBSMOVIE: "BBSMOVIE",
|
||||
} as const;
|
||||
|
||||
export type BoardType = (typeof BOARD_TYPE)[keyof typeof BOARD_TYPE];
|
||||
|
||||
export interface BoardPopupParams extends PageableParams {
|
||||
bbsNm?: string;
|
||||
}
|
||||
|
||||
export interface BoardPopup {
|
||||
bbsId: number;
|
||||
bbsTypeCd: BoardType;
|
||||
bbsTypeNm: string;
|
||||
bbsNm: string;
|
||||
bbsExpln: string;
|
||||
rfrncUseYn: string;
|
||||
atflUseYn: string;
|
||||
atflMaxCnt: number;
|
||||
atflMaxFileSz: number;
|
||||
ansUseYn: string;
|
||||
cmntUseYn: string;
|
||||
dgstfnEvlUseYn: string;
|
||||
smsUseYn: string;
|
||||
upndFixUseYn: string;
|
||||
pstgPrdUseYn: string;
|
||||
popupUseYn: string;
|
||||
delYn: string;
|
||||
regDt: string;
|
||||
pstCnt: number;
|
||||
}
|
||||
|
||||
export type BoardPopupList = PageableList<BoardPopup>;
|
||||
|
||||
export interface BoardService {
|
||||
getBoardPopupList: (params: BoardPopupParams) => Promise<BoardPopupList>;
|
||||
}
|
||||
@@ -11,7 +11,10 @@ import { CodeApi } from "../api/code-service";
|
||||
|
||||
type CodeSelectProps = {
|
||||
upCd: string;
|
||||
} & React.ComponentPropsWithoutRef<typeof Select>;
|
||||
value?: string;
|
||||
defaultValue?: string;
|
||||
onValueChange?: (value: string) => void;
|
||||
};
|
||||
|
||||
function CodeSelect({ upCd, defaultValue, ...props }: CodeSelectProps) {
|
||||
const { data: code } = useQuery({
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { client } from "@common/components/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { MenuItem, MenuService } from "../model/menu-interface";
|
||||
|
||||
export class MenuApiService implements MenuService {
|
||||
async getMenuRoles(siteId: string): Promise<MenuItem[]> {
|
||||
const response = await client.get<MenuItem[]>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const MenuApi = new MenuApiService();
|
||||
@@ -1 +0,0 @@
|
||||
export { MenuWrapper } from "./lib/menu-wrapper";
|
||||
@@ -1,30 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ENDPOINT, SITE_ID } from "@/shared/config";
|
||||
import { useMenuStore } from "@/shared/lib";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import { getCurrentMenu } from "./utils";
|
||||
|
||||
const MenuWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
const pathname = usePathname();
|
||||
const { data: menuRoles } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENU_ROLES],
|
||||
queryFn: () => MenuApi.getMenuRoles(SITE_ID),
|
||||
});
|
||||
const { setCurrentMenuInfo } = useMenuStore((state) => state);
|
||||
|
||||
useEffect(() => {
|
||||
if (!menuRoles) return;
|
||||
const currentMenu = getCurrentMenu(menuRoles, pathname ?? "");
|
||||
|
||||
if (!currentMenu) return;
|
||||
setCurrentMenuInfo(currentMenu);
|
||||
}, [menuRoles]);
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export { MenuWrapper };
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { MenuItem } from "../model/menu-interface";
|
||||
|
||||
export const getCurrentMenu = (
|
||||
menus: MenuItem[],
|
||||
pathname: string,
|
||||
): MenuItem | null => {
|
||||
for (const menu of menus) {
|
||||
if (menu.children) {
|
||||
return getCurrentMenu(menu.children, pathname);
|
||||
}
|
||||
if (menu.urlPath === pathname) return menu;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
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;
|
||||
menuPath: string;
|
||||
qrcd: string;
|
||||
useYn: string;
|
||||
otptYn: string;
|
||||
newWndwYn: string;
|
||||
requiredUrlPath: boolean;
|
||||
}
|
||||
|
||||
export interface MenuService {
|
||||
getMenuRoles(siteId: string): Promise<MenuItem[]>;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
export { SiteApi } from "./api/site-service";
|
||||
export {
|
||||
siteFormSchema,
|
||||
type SiteParams,
|
||||
type Site,
|
||||
type SiteFormData,
|
||||
} from "./model/site-interface";
|
||||
@@ -1,59 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableParams, PageableList } from "@/shared/model";
|
||||
|
||||
export interface SiteParams extends PageableParams {
|
||||
siteNm?: string;
|
||||
siteKndCd?: string;
|
||||
useYn?: string;
|
||||
}
|
||||
|
||||
export interface Site {
|
||||
siteId: string;
|
||||
siteNm: string;
|
||||
siteKindCode: string;
|
||||
bscSiteYn: string;
|
||||
siteAddr: string;
|
||||
useYn: string;
|
||||
regDt: string;
|
||||
rgTrNm: string;
|
||||
dmnAddr: string;
|
||||
}
|
||||
|
||||
export interface SiteDetail 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<Site>;
|
||||
|
||||
export interface SiteService {
|
||||
getSiteList(params: SiteParams): Promise<SiteList>;
|
||||
siteDetail(siteId: string): Promise<SiteDetail>;
|
||||
modifySite(siteId: string, data: SiteFormData): Promise<void>;
|
||||
createSite(data: SiteFormData): Promise<void>;
|
||||
}
|
||||
@@ -4,10 +4,8 @@ import Image from "next/image";
|
||||
import { images } from "@common/assets";
|
||||
import { LoginApi } from "@/entities/auth";
|
||||
import "./login.css";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
function LoginPage() {
|
||||
const router = useRouter();
|
||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -15,8 +13,7 @@ function LoginPage() {
|
||||
const userId = formData.get("id") as string;
|
||||
const password = formData.get("password") as string;
|
||||
|
||||
await LoginApi.login({ userId, password });
|
||||
router.push("/site");
|
||||
LoginApi.login({ userId, password });
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { ImagePage } from "./ui/image-page";
|
||||
@@ -1,80 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Upload } from "tus-js-client";
|
||||
import { FileUploader } from "@common/components/ui";
|
||||
import { PageLayout } from "@/shared/ui/page-layout";
|
||||
import { AUTH_USER_ID, CLAIM_NAME, ENDPOINT } from "@/shared/config";
|
||||
import { getCookie } from "@/shared/lib";
|
||||
|
||||
function ImagePage() {
|
||||
const handleUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.item(0);
|
||||
if (!file) return;
|
||||
|
||||
//const p_atflCd = store.getState().upload.atflCd; // Redux 스토어에서 atflCd 가져오기
|
||||
|
||||
|
||||
const upload = new Upload(file, {
|
||||
endpoint: `${ENDPOINT.ATTACH_SERVICE.TUS_UPLOAD}`,
|
||||
chunkSize: 10 * 1024 * 1024, // 5MB chunk size
|
||||
headers: {
|
||||
[CLAIM_NAME]: getCookie(CLAIM_NAME) ?? "",
|
||||
[AUTH_USER_ID]: getCookie(AUTH_USER_ID) ?? "",
|
||||
},
|
||||
retryDelays: [0, 3000, 5000, 10000, 20000],
|
||||
metadata: {
|
||||
filename: file.name,
|
||||
filetype: file.type
|
||||
// atflCd: p_atflCd,
|
||||
},
|
||||
onError: function (error) {
|
||||
console.log("Failed because: " + error);
|
||||
},
|
||||
onProgress: function (bytesUploaded, bytesTotal) {
|
||||
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
|
||||
console.log(bytesUploaded, bytesTotal, percentage + "%");
|
||||
},
|
||||
onSuccess: function () {
|
||||
console.log(
|
||||
"Download %s from %s",
|
||||
(upload.file as File).name,
|
||||
upload.url,
|
||||
);
|
||||
console.log("upload._req:", upload._req);
|
||||
|
||||
if(upload._req){
|
||||
const xhr = upload._req._xhr; // 업로드에 사용된 XMLHttpRequest 객체
|
||||
const xFileInfo = xhr.getResponseHeader('X-file-info'); // X-file-info 헤더 가져오기
|
||||
if (xFileInfo) {
|
||||
const fileInfo = JSON.parse(xFileInfo);
|
||||
console.log('fileInfo :', fileInfo);
|
||||
const downloadUrl = `${ENDPOINT.ATTACH_SERVICE.TUS_DOWNLOAD}/${fileInfo.atflId}`;
|
||||
console.log('Download URL:', downloadUrl);
|
||||
// store.dispatch(setAtflCd(fileInfo.atflCd)); // atflCd 저장
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
upload.findPreviousUploads().then(function (previousUploads) {
|
||||
if (previousUploads.length) {
|
||||
upload.resumeFromPreviousUpload(previousUploads[0]!);
|
||||
}
|
||||
upload.start();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<PageLayout>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">이미지 목록</h3>
|
||||
</div>
|
||||
<FileUploader id="image-uploader" onUpload={handleUpload} />
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
export { ImagePage };
|
||||
@@ -1,80 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Upload } from "tus-js-client";
|
||||
import { FileUploader } from "@common/components/ui";
|
||||
import { PageLayout } from "@/shared/ui/page-layout";
|
||||
import { AUTH_USER_ID, CLAIM_NAME, ENDPOINT } from "@/shared/config";
|
||||
import { getCookie } from "@/shared/lib";
|
||||
|
||||
function ImagePage() {
|
||||
const handleUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.item(0);
|
||||
if (!file) return;
|
||||
|
||||
//const p_atflCd = store.getState().upload.atflCd; // Redux 스토어에서 atflCd 가져오기
|
||||
|
||||
|
||||
const upload = new Upload(file, {
|
||||
endpoint: `${ENDPOINT.ATTACH_SERVICE.TUS_UPLOAD}`,
|
||||
chunkSize: 10 * 1024 * 1024, // 5MB chunk size
|
||||
headers: {
|
||||
[CLAIM_NAME]: getCookie(CLAIM_NAME) ?? "",
|
||||
[AUTH_USER_ID]: getCookie(AUTH_USER_ID) ?? "",
|
||||
},
|
||||
retryDelays: [0, 3000, 5000, 10000, 20000],
|
||||
metadata: {
|
||||
filename: file.name,
|
||||
filetype: file.type
|
||||
// atflCd: p_atflCd,
|
||||
},
|
||||
onError: function (error) {
|
||||
console.log("Failed because: " + error);
|
||||
},
|
||||
onProgress: function (bytesUploaded, bytesTotal) {
|
||||
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
|
||||
console.log(bytesUploaded, bytesTotal, percentage + "%");
|
||||
},
|
||||
onSuccess: function () {
|
||||
console.log(
|
||||
"Download %s from %s",
|
||||
(upload.file as File).name,
|
||||
upload.url,
|
||||
);
|
||||
console.log("upload._req:", upload._req);
|
||||
|
||||
if(upload._req){
|
||||
const xhr = upload._req._xhr; // 업로드에 사용된 XMLHttpRequest 객체
|
||||
const xFileInfo = xhr.getResponseHeader('X-file-info'); // X-file-info 헤더 가져오기
|
||||
if (xFileInfo) {
|
||||
const fileInfo = JSON.parse(xFileInfo);
|
||||
console.log('fileInfo :', fileInfo);
|
||||
const downloadUrl = `${ENDPOINT.ATTACH_SERVICE.TUS_DOWNLOAD}/${fileInfo.atflId}`;
|
||||
console.log('Download URL:', downloadUrl);
|
||||
// store.dispatch(setAtflCd(fileInfo.atflCd)); // atflCd 저장
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
upload.findPreviousUploads().then(function (previousUploads) {
|
||||
if (previousUploads.length) {
|
||||
upload.resumeFromPreviousUpload(previousUploads[0]!);
|
||||
}
|
||||
upload.start();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<PageLayout>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">이미지 목록</h3>
|
||||
</div>
|
||||
<FileUploader id="image-uploader" onUpload={handleUpload} />
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
export { ImagePage };
|
||||
@@ -1,19 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
ContentService,
|
||||
ContentParams,
|
||||
ContentList,
|
||||
} from "../model/content-interface";
|
||||
|
||||
export class ContentApiService implements ContentService {
|
||||
public async getContentList(params: ContentParams): Promise<ContentList> {
|
||||
const response = await client.get<ContentList>(
|
||||
`${ENDPOINT.CMS_SERVICE.CONTENTS}`,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const ContentApi = new ContentApiService();
|
||||
@@ -1,68 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
Menu,
|
||||
MenuFormData,
|
||||
MenuService,
|
||||
TreeMenu,
|
||||
TreeNode,
|
||||
} from "../model/menu-interface";
|
||||
|
||||
export class MenuApiService implements MenuService {
|
||||
public async getMenuInfo(menuCd: number): Promise<Menu> {
|
||||
const response = await client.get<Menu>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async createMenu(data: MenuFormData): Promise<void> {
|
||||
const response = await client.post<void>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENUS}`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async modifyMenu(
|
||||
menuCd: number,
|
||||
data: Omit<MenuFormData, "siteId">,
|
||||
): Promise<void> {
|
||||
const response = await client.put<void>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async deleteMenu(menuCd: number): Promise<void> {
|
||||
const response = await client.delete<void>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getTreeMenuList(siteId: string): Promise<TreeMenu[]> {
|
||||
const response = await client.get<TreeMenu[]>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async modifyTreeMenu(siteId: string, data: TreeNode[]): 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();
|
||||
@@ -1,17 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
Organization,
|
||||
OrganizationService,
|
||||
} from "../model/organization-interface";
|
||||
|
||||
export class OrganizationApiService implements OrganizationService {
|
||||
public async getOrganizationUserTreeList(): Promise<Organization[]> {
|
||||
const response = await client.get<Organization[]>(
|
||||
`${ENDPOINT.CMS_SERVICE.USER_OGNZ}/treeuser`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const OrganizationApi = new OrganizationApiService();
|
||||
@@ -1 +0,0 @@
|
||||
export { MenuPage } from "./ui/menu-page";
|
||||
@@ -1,165 +0,0 @@
|
||||
import type { DropOptions, NodeModel } from "@minoru/react-dnd-treeview";
|
||||
import type { TreeMenu, TreeNode } from "../model/menu-interface";
|
||||
import type { Organization, User } from "../model/organization-interface";
|
||||
|
||||
export const generateMenuTreeData = (
|
||||
data: TreeMenu[],
|
||||
): NodeModel<TreeMenu>[] => {
|
||||
return data.reduce<NodeModel<TreeMenu>[]>((acc, menu) => {
|
||||
const node: NodeModel<TreeMenu> = {
|
||||
id: menu.menuCd ?? 0,
|
||||
parent: menu.parentId ?? 0,
|
||||
text: menu.menuKornNm,
|
||||
droppable: true,
|
||||
data: menu,
|
||||
};
|
||||
|
||||
acc.push(node);
|
||||
|
||||
if (menu.children?.length) {
|
||||
acc.push(...generateMenuTreeData(menu.children));
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
};
|
||||
|
||||
export const generateNewMenuTreeData = (
|
||||
treeData: NodeModel<TreeMenu>[],
|
||||
options: DropOptions<TreeMenu>,
|
||||
): TreeNode | null => {
|
||||
const { dragSourceId, dragSource, dropTargetId, dropTarget } = options;
|
||||
|
||||
if (!dragSource?.data) return null;
|
||||
|
||||
const siblings = treeData.filter((node) => node.parent === dropTargetId);
|
||||
|
||||
const dragSourceIndex = siblings.findIndex(
|
||||
(node) => node.id === dragSourceId,
|
||||
);
|
||||
|
||||
const prevSibling = siblings[dragSourceIndex - 1];
|
||||
|
||||
const newSortSeq =
|
||||
dragSourceIndex === 0 ? 1 : (prevSibling?.data?.sortSeq ?? 0) + 1;
|
||||
|
||||
const childNodes = treeData.filter(
|
||||
(node) => node.parent === dragSourceId && node.data,
|
||||
);
|
||||
|
||||
const baseNode = (node: NodeModel<TreeMenu>): TreeNode => {
|
||||
if (!node.data) return {};
|
||||
return {
|
||||
menuCd: node.data?.menuCd,
|
||||
name: node.data?.menuKornNm,
|
||||
icon: node.data?.iconNm,
|
||||
};
|
||||
};
|
||||
|
||||
const treeNode: TreeNode = {
|
||||
...baseNode(dragSource),
|
||||
parentId: dropTargetId === 0 ? null : (dropTargetId as number),
|
||||
sortSeq: newSortSeq,
|
||||
levelNo: (dropTarget?.data?.levelNo ?? 0) + 1,
|
||||
};
|
||||
|
||||
const result: TreeNode = {
|
||||
...treeNode,
|
||||
children: childNodes.map((child) => ({
|
||||
...baseNode(child),
|
||||
parentId: child.data?.parentId === 0 ? null : (dropTargetId as number),
|
||||
sortSeq: child.data?.sortSeq,
|
||||
levelNo: (treeNode?.levelNo ?? 0) + 1,
|
||||
})),
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export const handleSelectNode =
|
||||
(callback: (node: NodeModel<TreeMenu>) => void) =>
|
||||
(node: NodeModel<TreeMenu>) => {
|
||||
callback(node);
|
||||
};
|
||||
|
||||
export const handleDropNode =
|
||||
(callback: (newTree: TreeNode) => void) =>
|
||||
(newTree: NodeModel<TreeMenu>[], options: DropOptions<TreeMenu>) => {
|
||||
const newTreeData = generateNewMenuTreeData(newTree, options);
|
||||
if (!newTreeData) return;
|
||||
callback(newTreeData);
|
||||
};
|
||||
|
||||
export const handleNodeTextChange =
|
||||
(treeData: NodeModel<TreeMenu>[]) =>
|
||||
(callback: (newTree: NodeModel<TreeMenu>[]) => void) =>
|
||||
(id: NodeModel["id"], value: string) => {
|
||||
const newTree = treeData.map((node) => {
|
||||
if (node.id === id) {
|
||||
return {
|
||||
...node,
|
||||
text: value,
|
||||
};
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
callback(newTree);
|
||||
};
|
||||
|
||||
export const generateOrganizationTreeData = (
|
||||
organizations: Organization[],
|
||||
): NodeModel<Organization | User>[] => {
|
||||
return organizations.reduce<NodeModel<Organization | User>[]>((acc, org) => {
|
||||
const orgNode: NodeModel<Organization> = {
|
||||
id: org.ognzId,
|
||||
parent: org.upOgnzId ?? 0,
|
||||
text: org.ognzNm,
|
||||
data: org,
|
||||
droppable: false,
|
||||
};
|
||||
|
||||
acc.push(orgNode);
|
||||
|
||||
if (org.children?.length) {
|
||||
acc.push(...generateOrganizationTreeData(org.children));
|
||||
}
|
||||
|
||||
if (org.users?.length) {
|
||||
acc.push(
|
||||
...org.users.map((user) => ({
|
||||
id: user.userUnqId,
|
||||
parent: org.ognzId,
|
||||
text: user.userNm,
|
||||
data: user,
|
||||
droppable: false,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
};
|
||||
|
||||
export const filterOrganizationTreeDataByKeyword = (
|
||||
treeData: NodeModel<Organization | User>[],
|
||||
keyword: string,
|
||||
): NodeModel<Organization | User>[] => {
|
||||
return Array.from(
|
||||
treeData.reduce((matchedNodes, node) => {
|
||||
if (!node.text.includes(keyword)) return matchedNodes;
|
||||
|
||||
matchedNodes.add(node);
|
||||
|
||||
let parentId = node.parent;
|
||||
while (parentId) {
|
||||
const parentNode = treeData.find((n) => n.id === parentId);
|
||||
if (!parentNode) break;
|
||||
matchedNodes.add(parentNode);
|
||||
parentId = parentNode.parent;
|
||||
}
|
||||
|
||||
return matchedNodes;
|
||||
}, new Set<NodeModel<Organization | User>>()),
|
||||
);
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
import { Checkbox } from "@common/components/ui";
|
||||
import type { BoardPopup } from "@/entities/board";
|
||||
|
||||
const columnHelper = createColumnHelper<BoardPopup>();
|
||||
|
||||
const columns = [
|
||||
columnHelper.accessor((_, index) => index + 1, {
|
||||
id: "no",
|
||||
header: "NO",
|
||||
}),
|
||||
columnHelper.accessor("bbsNm", {
|
||||
id: "bbsNm",
|
||||
header: "게시판명",
|
||||
}),
|
||||
columnHelper.accessor("bbsTypeNm", {
|
||||
id: "bbsTypeNm",
|
||||
header: "게시판유형",
|
||||
}),
|
||||
columnHelper.accessor("regDt", {
|
||||
id: "regDt",
|
||||
header: "최초생성일",
|
||||
}),
|
||||
columnHelper.accessor("pstCnt", {
|
||||
id: "pstCnt",
|
||||
header: "게시물건수",
|
||||
}),
|
||||
columnHelper.display({
|
||||
id: "select",
|
||||
header: "선택",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={row.getToggleSelectedHandler()}
|
||||
className="mx-4 flex justify-center"
|
||||
/>
|
||||
);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export { columns };
|
||||
@@ -1,22 +0,0 @@
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export interface ContentParams extends PageableParams {
|
||||
contsTtl?: string;
|
||||
aprvContsVer?: number;
|
||||
useYn?: string;
|
||||
}
|
||||
|
||||
export interface Content {
|
||||
contsSn: number;
|
||||
contsTtl: string;
|
||||
aprvContsVer: number;
|
||||
useYn: string;
|
||||
rgtr: string;
|
||||
regDt: string;
|
||||
}
|
||||
|
||||
export type ContentList = PageableList<Content>;
|
||||
|
||||
export interface ContentService {
|
||||
getContentList(params: ContentParams): Promise<ContentList>;
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
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 TreeNode {
|
||||
menuCd?: number;
|
||||
name?: string;
|
||||
sortSeq?: number;
|
||||
parentId?: number | null;
|
||||
levelNo?: number;
|
||||
icon?: string;
|
||||
children?: TreeNode[];
|
||||
}
|
||||
|
||||
export interface TreeMenu extends Omit<TreeNode, "name" | "icon" | "children"> {
|
||||
menuKornNm: string;
|
||||
menuEngNm?: string;
|
||||
iconNm?: string;
|
||||
children?: TreeMenu[];
|
||||
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.string().default("Y"),
|
||||
prntMenuCd: z.number().nullish(),
|
||||
sortSeq: z.number(),
|
||||
evlUseYn: z.string().default("Y"),
|
||||
qrcd: z.string().nullish(),
|
||||
useYn: z.string().default("Y"),
|
||||
newWndwYn: z.string().nullish(),
|
||||
menuLnkgSnNm: z.string().nullish(),
|
||||
menuPicUserUnqId: z.string().nullish(),
|
||||
menuPicUserUnqIdNm: z.string().nullish(),
|
||||
menuPicDsgnYmd: z.string().nullish(),
|
||||
});
|
||||
|
||||
export type MenuFormData = z.infer<typeof menuFormSchema>;
|
||||
export type Menu = Omit<MenuFormData, "iconNm"> & {
|
||||
menuCd: number;
|
||||
iconName?: string;
|
||||
};
|
||||
|
||||
export interface MenuService {
|
||||
getMenuInfo: (menuCd: number) => Promise<Menu>;
|
||||
createMenu: (data: MenuFormData) => Promise<void>;
|
||||
modifyMenu: (
|
||||
menuCd: number,
|
||||
data: Omit<MenuFormData, "siteId">,
|
||||
) => Promise<void>;
|
||||
deleteMenu: (menuCd: number) => Promise<void>;
|
||||
getTreeMenuList: (siteId: string) => Promise<TreeMenu[]>;
|
||||
modifyTreeMenu: (siteId: string, data: TreeNode[]) => Promise<void>;
|
||||
modifyMenuName: (menuCd: number, name: string) => Promise<void>;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
export interface User {
|
||||
userUnqId: string;
|
||||
userNm: string;
|
||||
jbpsSeCd: string;
|
||||
jbgdSeCd: string;
|
||||
}
|
||||
|
||||
export interface Organization {
|
||||
ognzId: string;
|
||||
upOgnzId: string;
|
||||
ognzNm: string;
|
||||
users: User[];
|
||||
children: Organization[];
|
||||
}
|
||||
|
||||
export interface OrganizationService {
|
||||
getOrganizationUserTreeList(): Promise<Organization[]>;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
import { Checkbox } from "@common/components/ui";
|
||||
import type { Content } from "../model/content-interface";
|
||||
|
||||
const columnHelper = createColumnHelper<Content>();
|
||||
|
||||
const columns = [
|
||||
columnHelper.accessor((_, index) => index + 1, {
|
||||
id: "no",
|
||||
header: "NO",
|
||||
}),
|
||||
columnHelper.accessor("contsTtl", {
|
||||
id: "contsTtl",
|
||||
header: "콘텐츠명",
|
||||
}),
|
||||
// TODO: 최종수정자, 최종수정일, 승인일시 추가
|
||||
columnHelper.display({
|
||||
id: "select",
|
||||
header: "선택",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={row.getToggleSelectedHandler()}
|
||||
className="mx-4 flex justify-center"
|
||||
/>
|
||||
);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export { columns };
|
||||
@@ -1,132 +0,0 @@
|
||||
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>;
|
||||
menuCd?: number;
|
||||
}
|
||||
|
||||
function BaseMenuForm({ form, menuCd }: BaseMenuFormProps) {
|
||||
return (
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="20%" />
|
||||
<col width="80%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
{menuCd && (
|
||||
<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">
|
||||
{menuCd}
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
<TableRow>
|
||||
<TableHead>메뉴명</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="menuKornNm"
|
||||
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="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={key} />
|
||||
<Label htmlFor={key}>
|
||||
{key === "EMPTY" && "빈메뉴"}
|
||||
{key === "CONTENTS" && "콘텐츠"}
|
||||
{key === "BOARD" && "게시판"}
|
||||
{key === "INSIDE" && "내부링크"}
|
||||
{key === "OUTSIDE" && "외부링크"}
|
||||
{key === "BOTTOM" && "하단메뉴"}
|
||||
</Label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
||||
export { BaseMenuForm };
|
||||
@@ -1,95 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type RowSelectionState,
|
||||
} from "@tanstack/react-table";
|
||||
import {
|
||||
Button,
|
||||
DataTable,
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Input,
|
||||
} from "@common/components/ui";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { BoardApi, type BoardPopup } from "@/entities/board";
|
||||
import { columns } from "../model/board-table-columns";
|
||||
|
||||
type BoardSearchDialogProps = {
|
||||
handleBoardSelect: (board: BoardPopup) => void;
|
||||
} & React.ComponentProps<typeof Dialog>;
|
||||
|
||||
function BoardSearchDialog({
|
||||
handleBoardSelect,
|
||||
...props
|
||||
}: BoardSearchDialogProps) {
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
const [bbsNm, setBbsNm] = useState("");
|
||||
|
||||
const { data: boardList, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.BBS],
|
||||
queryFn: () => BoardApi.getBoardPopupList({ bbsNm }),
|
||||
enabled: false,
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: boardList?.content ?? [],
|
||||
columns,
|
||||
state: {
|
||||
rowSelection,
|
||||
},
|
||||
enableMultiRowSelection: false,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const boardData = table.getSelectedRowModel().rows[0]
|
||||
?.original as BoardPopup;
|
||||
if (!boardData) return;
|
||||
handleBoardSelect(boardData);
|
||||
}, [table.getSelectedRowModel().rows]);
|
||||
|
||||
useEffect(() => {
|
||||
refetch();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="gap-3">
|
||||
<i className="diveicon di-search" />
|
||||
조회
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>게시판 조회</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="card card-border !m-0 flex w-full items-center gap-2">
|
||||
<Input
|
||||
placeholder="검색어를 입력하세요."
|
||||
className="!text-[1.3rem]"
|
||||
value={bbsNm}
|
||||
onChange={(e) => setBbsNm(e.target.value)}
|
||||
/>
|
||||
<Button onClick={() => refetch()}>
|
||||
<i className="diveicon di-search" />
|
||||
조회
|
||||
</Button>
|
||||
</div>
|
||||
<div className="h-[40rem] w-full overflow-y-auto">
|
||||
<DataTable table={table} />
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export { BoardSearchDialog };
|
||||
@@ -1,97 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
type RowSelectionState,
|
||||
} from "@tanstack/react-table";
|
||||
import {
|
||||
Button,
|
||||
DataTable,
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Input,
|
||||
} from "@common/components/ui";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { ContentApi } from "../api/content-service";
|
||||
import type { Content } from "../model/content-interface";
|
||||
import { columns } from "../model/table-colums";
|
||||
|
||||
type ContentSearchDialogProps = {
|
||||
handleContentSelect: (content: Content) => void;
|
||||
} & React.ComponentProps<typeof Dialog>;
|
||||
|
||||
function ContentSearchDialog({
|
||||
handleContentSelect,
|
||||
...props
|
||||
}: ContentSearchDialogProps) {
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
const [contsTtl, setContsTtl] = useState("");
|
||||
|
||||
const { data: contentList, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.CONTENTS],
|
||||
queryFn: () =>
|
||||
ContentApi.getContentList({ contsTtl, useYn: "Y", page: 0, size: 100 }),
|
||||
enabled: false,
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: contentList?.content ?? [],
|
||||
columns,
|
||||
state: {
|
||||
rowSelection,
|
||||
},
|
||||
enableMultiRowSelection: false,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
onRowSelectionChange: setRowSelection,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const contentData = table.getSelectedRowModel().rows[0]
|
||||
?.original as Content;
|
||||
if (!contentData) return;
|
||||
handleContentSelect(contentData);
|
||||
}, [table.getSelectedRowModel().rows]);
|
||||
|
||||
useEffect(() => {
|
||||
refetch();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="gap-3">
|
||||
<i className="diveicon di-search" />
|
||||
조회
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>콘텐츠 조회</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="card card-border !m-0 flex w-full items-center gap-2">
|
||||
<Input
|
||||
placeholder="검색어를 입력하세요."
|
||||
className="!text-[1.3rem]"
|
||||
value={contsTtl}
|
||||
onChange={(e) => setContsTtl(e.target.value)}
|
||||
/>
|
||||
<Button onClick={() => refetch()}>
|
||||
<i className="diveicon di-search" />
|
||||
조회
|
||||
</Button>
|
||||
</div>
|
||||
<div className="h-[40rem] w-full overflow-y-auto">
|
||||
<DataTable table={table} />
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export { ContentSearchDialog };
|
||||
@@ -1,44 +0,0 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
|
||||
type EditableNodeProps = {
|
||||
depth?: number;
|
||||
onSave: () => void;
|
||||
onCancel: () => void;
|
||||
} & ComponentProps<typeof Input>;
|
||||
|
||||
function EditableNode({
|
||||
depth,
|
||||
onSave,
|
||||
onCancel,
|
||||
...props
|
||||
}: EditableNodeProps) {
|
||||
return (
|
||||
<div
|
||||
className="flex items-center gap-2 rounded-sm bg-accent p-2"
|
||||
style={{ marginInlineStart: !depth ? 0 : depth * 5 + 5 }}
|
||||
>
|
||||
<Input {...props} className="h-[2.5rem] !text-[1.3rem] text-foreground" />
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-8 !bg-transparent"
|
||||
onClick={onSave}
|
||||
>
|
||||
<i className="diveicon di-check text-2xl" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-8 !bg-transparent"
|
||||
onClick={onCancel}
|
||||
>
|
||||
<i className="diveicon di-x" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { EditableNode };
|
||||
@@ -1,112 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { Button } from "@common/components";
|
||||
import { Form } from "@/shared/ui/form";
|
||||
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||
import type { MenuFormData } from "../model/menu-interface";
|
||||
import { BaseMenuForm } from "./base-menu-form";
|
||||
import { TypeMenuForm } from "./type-menu-form";
|
||||
import { PermissionsManagementDialog } from "./permissions-management-dialog";
|
||||
|
||||
interface MenuFormProps {
|
||||
form: UseFormReturn<MenuFormData>;
|
||||
menuCd?: number;
|
||||
handleCreate: (data: MenuFormData) => void;
|
||||
handleModify: ({
|
||||
menuCd,
|
||||
data,
|
||||
}: {
|
||||
menuCd: number;
|
||||
data: Omit<MenuFormData, "siteId">;
|
||||
}) => void;
|
||||
handleDelete?: (menuCd: number) => void;
|
||||
}
|
||||
|
||||
function MenuForm({
|
||||
form,
|
||||
menuCd,
|
||||
handleCreate,
|
||||
handleModify,
|
||||
handleDelete,
|
||||
}: MenuFormProps) {
|
||||
const isModifyMode = !!menuCd;
|
||||
|
||||
const { confirm } = useConfirm();
|
||||
const [onConfirm, setOnConfirm] = useState(false);
|
||||
|
||||
const handleConfirm = async (fn: () => Promise<void>) => {
|
||||
setOnConfirm(true);
|
||||
await fn();
|
||||
setOnConfirm(false);
|
||||
};
|
||||
|
||||
const onSubmit = async (data: MenuFormData) => {
|
||||
if (isModifyMode) {
|
||||
await onModify(data);
|
||||
} else {
|
||||
await onCreate(data);
|
||||
}
|
||||
};
|
||||
|
||||
const onCreate = async (data: MenuFormData) => {
|
||||
await handleConfirm(async () => {
|
||||
if (await confirm("저장하시겠습니까?")) {
|
||||
handleCreate(data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onModify = async (data: MenuFormData) => {
|
||||
await handleConfirm(async () => {
|
||||
if (await confirm("수정하시겠습니까?")) {
|
||||
handleModify({ menuCd: menuCd!, data });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onDelete = () => {
|
||||
handleConfirm(async () => {
|
||||
if (await confirm("삭제하시겠습니까?")) {
|
||||
handleDelete?.(menuCd!);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const menuType = form.watch("menuLnkgTypeCd");
|
||||
const isSubmitDisabled = !form.watch("siteId");
|
||||
|
||||
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">
|
||||
{isModifyMode ? "메뉴 수정" : "메뉴 등록"}
|
||||
</h3>
|
||||
<PermissionsManagementDialog menuCd={menuCd} />
|
||||
</div>
|
||||
<div className="card">
|
||||
<BaseMenuForm form={form} menuCd={menuCd} />
|
||||
<TypeMenuForm form={form} menuType={menuType} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-center gap-4 pb-12 pt-10">
|
||||
<Button size="lg" type="submit" disabled={isSubmitDisabled}>
|
||||
저장
|
||||
</Button>
|
||||
{isModifyMode && (
|
||||
<Button size="lg" color="red" type="button" onClick={onDelete}>
|
||||
삭제
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
<ConfirmDialog open={onConfirm} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export { MenuForm };
|
||||
@@ -1,115 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import type { NodeModel, TreeMethods } from "@minoru/react-dnd-treeview";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { cn } from "@common/components/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import type { TreeMenu } from "../model/menu-interface";
|
||||
import { EditableNode } from "./editable-node";
|
||||
|
||||
type MenuNodeProps = {
|
||||
node: NodeModel<TreeMenu>;
|
||||
depth: number;
|
||||
isOpen: boolean;
|
||||
isSelected: boolean;
|
||||
isAdditionalParent: boolean;
|
||||
treeMethods: TreeMethods | null;
|
||||
onToggle: (id: NodeModel["id"]) => void;
|
||||
onSelect: (node: NodeModel<TreeMenu>) => void;
|
||||
};
|
||||
|
||||
function MenuNode({
|
||||
node,
|
||||
depth,
|
||||
isOpen,
|
||||
isSelected,
|
||||
isAdditionalParent,
|
||||
treeMethods,
|
||||
onToggle,
|
||||
onSelect,
|
||||
}: MenuNodeProps) {
|
||||
const { id, text, data } = node;
|
||||
const indent = depth * 10 + 5;
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { mutateAsync: modifyMenuName } = useMutation({
|
||||
mutationFn: (nodeName: string) => {
|
||||
const encodedName = encodeURIComponent(nodeName);
|
||||
return MenuApi.modifyMenuName(id as number, encodedName);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
setEditMode(false);
|
||||
setNodeName(text);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isAdditionalParent) treeMethods?.open(id);
|
||||
}, [isAdditionalParent]);
|
||||
|
||||
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)]",
|
||||
)}
|
||||
>
|
||||
{editMode ? (
|
||||
<EditableNode
|
||||
value={nodeName}
|
||||
onChange={(e) => setNodeName(e.target.value)}
|
||||
onSave={handleSave}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="flex items-center" onClick={handleSelect}>
|
||||
{data?.children?.length && (
|
||||
<i
|
||||
className={cn(
|
||||
"diveicon di-arrow-forward mr-2 text-base text-label",
|
||||
isOpen && "rotate-90",
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleToggle();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<span className="text-[1.4rem] font-medium text-label">{text}</span>
|
||||
</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 };
|
||||
@@ -1,266 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import type { NodeModel } from "@minoru/react-dnd-treeview";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
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 { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import type { TreeMenu } from "../model/menu-interface";
|
||||
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 { generateMenuTreeData } from "../lib/utils";
|
||||
|
||||
function MenuPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const [siteId, setSiteId] = useState("");
|
||||
const [onConfirm, setOnConfirm] = useState(false);
|
||||
const [selectedMenu, setSelectedMenu] = useState<TreeMenu | null>(null);
|
||||
const [additionalNode, setAdditionalNode] =
|
||||
useState<NodeModel<TreeMenu> | null>(null);
|
||||
|
||||
const { data: menuInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS, selectedMenu?.menuCd],
|
||||
queryFn: () => MenuApi.getMenuInfo(selectedMenu?.menuCd ?? 0),
|
||||
enabled: !!selectedMenu?.menuCd,
|
||||
});
|
||||
|
||||
const { data: treeData } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS, siteId],
|
||||
queryFn: () => MenuApi.getTreeMenuList(siteId),
|
||||
select: (data) => {
|
||||
const treeData = generateMenuTreeData(data);
|
||||
const defaultSortSeq =
|
||||
treeData.filter((node) => node.data?.levelNo === 1).length + 1;
|
||||
form.setValue("sortSeq", defaultSortSeq);
|
||||
|
||||
return treeData;
|
||||
},
|
||||
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 { mutateAsync: createMenu } = useMutation({
|
||||
mutationFn: (data: MenuFormData) => MenuApi.createMenu(data),
|
||||
onSuccess: () => {
|
||||
alert("저장되었습니다.");
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS, siteId],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: modifyMenu } = useMutation({
|
||||
mutationFn: ({
|
||||
menuCd,
|
||||
data,
|
||||
}: {
|
||||
menuCd: number;
|
||||
data: Omit<MenuFormData, "siteId">;
|
||||
}) => MenuApi.modifyMenu(menuCd, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.");
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS, siteId],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: deleteMenu } = useMutation({
|
||||
mutationFn: (menuCd: number) => MenuApi.deleteMenu(menuCd),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.");
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS, siteId],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const form = useForm<MenuFormData>({
|
||||
resolver: zodResolver(menuFormSchema),
|
||||
defaultValues: {
|
||||
menuLnkgTypeCd: MENU_TYPE.EMPTY,
|
||||
},
|
||||
values: {
|
||||
...menuInfo,
|
||||
siteId,
|
||||
levelNo: menuInfo?.levelNo ?? 1,
|
||||
sortSeq: menuInfo?.sortSeq ?? 1,
|
||||
menuKornNm: menuInfo?.menuKornNm ?? "",
|
||||
menuLnkgTypeCd: menuInfo?.menuLnkgTypeCd ?? MENU_TYPE.EMPTY,
|
||||
iconNm: menuInfo?.iconName,
|
||||
otptYn: menuInfo?.otptYn ?? "Y",
|
||||
evlUseYn: menuInfo?.evlUseYn ?? "Y",
|
||||
useYn: menuInfo?.useYn ?? "Y",
|
||||
},
|
||||
});
|
||||
|
||||
const additionalNodeForm = useForm<MenuFormData>({
|
||||
resolver: zodResolver(menuFormSchema),
|
||||
defaultValues: {
|
||||
menuLnkgTypeCd: MENU_TYPE.EMPTY,
|
||||
levelNo: 1,
|
||||
sortSeq: 1,
|
||||
otptYn: "Y",
|
||||
evlUseYn: "Y",
|
||||
useYn: "Y",
|
||||
},
|
||||
});
|
||||
|
||||
const handleAdditionalNodeSave = async () => {
|
||||
const prntMenuCd = !additionalNode?.parent
|
||||
? null
|
||||
: (additionalNode?.parent as number);
|
||||
|
||||
await createMenu({
|
||||
...additionalNodeForm.getValues(),
|
||||
prntMenuCd,
|
||||
});
|
||||
resetAdditionalNode();
|
||||
};
|
||||
|
||||
const resetAdditionalNode = () => {
|
||||
additionalNodeForm.setValue("menuKornNm", "");
|
||||
setAdditionalNode(null);
|
||||
};
|
||||
|
||||
const handleSiteIdChange = (value: string) => {
|
||||
form.setValue("siteId", value);
|
||||
additionalNodeForm.setValue("siteId", value);
|
||||
|
||||
setSiteId(value);
|
||||
setSelectedMenu(null);
|
||||
};
|
||||
|
||||
const handleNodeSelect = (node: NodeModel<TreeMenu>) => {
|
||||
if (!node.data) return;
|
||||
if (node.data.menuCd === selectedMenu?.menuCd) {
|
||||
setSelectedMenu(null);
|
||||
additionalNodeForm.setValue("levelNo", 1);
|
||||
return;
|
||||
}
|
||||
setSelectedMenu(node.data);
|
||||
additionalNodeForm.setValue("levelNo", (node.data.levelNo ?? 0) + 1);
|
||||
};
|
||||
|
||||
const handleNodeDelete = async () => {
|
||||
setOnConfirm(true);
|
||||
if (await confirm("삭제하시겠습니까?")) {
|
||||
setOnConfirm(false);
|
||||
deleteMenu(selectedMenu!.menuCd!);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddMenu = () => {
|
||||
if (additionalNode) return;
|
||||
setAdditionalNode({
|
||||
id: -1,
|
||||
parent: selectedMenu?.menuCd ?? 0,
|
||||
text: "",
|
||||
});
|
||||
};
|
||||
|
||||
const tree = additionalNode
|
||||
? [...(additionalNode ? [additionalNode] : []), ...(treeData ?? [])]
|
||||
: (treeData ?? []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageLayout>
|
||||
<div className="card !mb-0 flex !min-h-[calc(100vh-16.8rem)] gap-2">
|
||||
<div className="card card-border w-[24rem]">
|
||||
<Select value={siteId} onValueChange={handleSiteIdChange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="선택하세요" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options?.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{siteId && (
|
||||
<>
|
||||
<div className="my-4 flex gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
color="primary"
|
||||
className="flex-1"
|
||||
onClick={handleAddMenu}
|
||||
>
|
||||
메뉴 추가
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
color="red"
|
||||
className="flex-1"
|
||||
onClick={handleNodeDelete}
|
||||
disabled={!selectedMenu}
|
||||
>
|
||||
메뉴 삭제
|
||||
</Button>
|
||||
</div>
|
||||
<div className="card card-border !mx-0">
|
||||
<MenuTree
|
||||
tree={tree}
|
||||
siteId={siteId}
|
||||
selectedMenu={selectedMenu}
|
||||
additionalNodeForm={additionalNodeForm}
|
||||
onSelectNode={handleNodeSelect}
|
||||
onAdditionalNodeSave={handleAdditionalNodeSave}
|
||||
onAdditionalNodeCancel={resetAdditionalNode}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="card card-border flex-1">
|
||||
<MenuForm
|
||||
form={form}
|
||||
menuCd={selectedMenu?.menuCd}
|
||||
handleCreate={createMenu}
|
||||
handleModify={modifyMenu}
|
||||
handleDelete={deleteMenu}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</PageLayout>
|
||||
<ConfirmDialog open={onConfirm} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export { MenuPage };
|
||||
@@ -1,151 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useRef } from "react";
|
||||
import { DndProvider } from "react-dnd";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Tree,
|
||||
MultiBackend,
|
||||
getBackendOptions,
|
||||
type NodeModel,
|
||||
type TreeMethods,
|
||||
} from "@minoru/react-dnd-treeview";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import type { MenuFormData, TreeMenu, TreeNode } from "../model/menu-interface";
|
||||
import { handleDropNode, handleSelectNode } from "../lib/utils";
|
||||
import { MenuNode } from "./menu-node";
|
||||
import { EditableNode } from "./editable-node";
|
||||
|
||||
type MenuTreeProps = {
|
||||
tree: NodeModel<TreeMenu>[];
|
||||
siteId: string;
|
||||
selectedMenu: TreeMenu | null;
|
||||
additionalNodeForm: UseFormReturn<MenuFormData>;
|
||||
onSelectNode: (node: NodeModel<TreeMenu>) => void;
|
||||
onAdditionalNodeSave: () => void;
|
||||
onAdditionalNodeCancel: () => void;
|
||||
};
|
||||
|
||||
function MenuTree({
|
||||
tree,
|
||||
siteId,
|
||||
selectedMenu,
|
||||
additionalNodeForm,
|
||||
onSelectNode,
|
||||
onAdditionalNodeSave,
|
||||
onAdditionalNodeCancel,
|
||||
}: MenuTreeProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const treeMethods = useRef<TreeMethods>(null);
|
||||
|
||||
const { mutate: modifyTreeMenu } = useMutation({
|
||||
mutationFn: (newTree: TreeNode) =>
|
||||
MenuApi.modifyTreeMenu(siteId, [newTree]),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.MENUS],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const additionalNode = tree.find((n) => n.id === -1);
|
||||
|
||||
const isAdditionalParent = (node: NodeModel<TreeMenu>): boolean => {
|
||||
if (!additionalNode) return false;
|
||||
return additionalNode?.parent === node.id;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="max-h-[calc(100vh-33.5rem)] overflow-auto">
|
||||
<DndProvider backend={MultiBackend} options={getBackendOptions()}>
|
||||
<Tree
|
||||
tree={tree}
|
||||
rootId={0}
|
||||
ref={treeMethods}
|
||||
render={(
|
||||
node: NodeModel<TreeMenu>,
|
||||
{ depth, isOpen, onToggle },
|
||||
) => {
|
||||
if (node.id === -1) {
|
||||
return (
|
||||
<EditableNode
|
||||
value={additionalNodeForm.watch("menuKornNm") ?? ""}
|
||||
onChange={(e) =>
|
||||
additionalNodeForm.setValue("menuKornNm", e.target.value)
|
||||
}
|
||||
depth={depth}
|
||||
onSave={onAdditionalNodeSave}
|
||||
onCancel={onAdditionalNodeCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<MenuNode
|
||||
node={node}
|
||||
depth={depth}
|
||||
treeMethods={treeMethods.current}
|
||||
isOpen={isOpen}
|
||||
isSelected={selectedMenu?.menuCd === node.id}
|
||||
isAdditionalParent={isAdditionalParent(node)}
|
||||
onToggle={onToggle}
|
||||
onSelect={handleSelectNode(onSelectNode)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
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>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
color="lightGray"
|
||||
className="flex-1 items-center px-0"
|
||||
onClick={() => {
|
||||
treeMethods.current?.openAll();
|
||||
}}
|
||||
>
|
||||
<i className="diveicon di-arrows-angle-expand" />
|
||||
전체펼침
|
||||
</Button>
|
||||
<Button
|
||||
color="lightGray"
|
||||
className="flex-1 items-center px-0"
|
||||
onClick={() => {
|
||||
treeMethods.current?.closeAll();
|
||||
}}
|
||||
>
|
||||
<i className="diveicon di-arrows-angle-contract" />
|
||||
전체접기
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export { MenuTree };
|
||||
@@ -1,184 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { DndProvider } from "react-dnd";
|
||||
import {
|
||||
Tree,
|
||||
MultiBackend,
|
||||
getBackendOptions,
|
||||
type NodeModel,
|
||||
} from "@minoru/react-dnd-treeview";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
Input,
|
||||
} from "@common/components/ui";
|
||||
import { cn } from "@common/components/lib";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { OrganizationApi } from "../api/organization-service";
|
||||
import type { Organization, User } from "../model/organization-interface";
|
||||
import {
|
||||
filterOrganizationTreeDataByKeyword,
|
||||
generateOrganizationTreeData,
|
||||
} from "../lib/utils";
|
||||
|
||||
type TreeModel = Organization | User;
|
||||
|
||||
interface OrganizationSearchDialogProps {
|
||||
handleUserSelect: (user: User) => void;
|
||||
}
|
||||
|
||||
function OrganizationSearchDialog({
|
||||
handleUserSelect,
|
||||
}: OrganizationSearchDialogProps) {
|
||||
const [keyword, setKeyword] = useState("");
|
||||
const [tree, setTree] = useState<NodeModel<TreeModel>[]>([]);
|
||||
const [selectedNode, setSelectedNode] = useState<NodeModel<TreeModel> | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
const { data: treeData } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.USER_OGNZ],
|
||||
queryFn: () => OrganizationApi.getOrganizationUserTreeList(),
|
||||
select: (data) => generateOrganizationTreeData(data),
|
||||
});
|
||||
|
||||
const handleSelectNode = (node: NodeModel<TreeModel>) => {
|
||||
setSelectedNode(node);
|
||||
handleUserSelect(node.data as User);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setTree(treeData ?? []);
|
||||
}, [treeData]);
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="gap-3">
|
||||
<i className="diveicon di-search" />
|
||||
조회
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[30rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>담당자 조회</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="card card-border !m-0 flex w-full items-center gap-2">
|
||||
<Input
|
||||
className="h-[2.5rem] !text-[1.3rem]"
|
||||
value={keyword}
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
setTree(filterOrganizationTreeDataByKeyword(tree, keyword))
|
||||
}
|
||||
>
|
||||
<i className="diveicon di-search text-base" />
|
||||
조회
|
||||
</Button>
|
||||
</div>
|
||||
<div className="h-[36rem] overflow-auto">
|
||||
<DndProvider backend={MultiBackend} options={getBackendOptions()}>
|
||||
<Tree
|
||||
tree={tree}
|
||||
rootId={0}
|
||||
render={(
|
||||
node: NodeModel<TreeModel>,
|
||||
{ depth, isOpen, onToggle },
|
||||
) => (
|
||||
<TreeNode
|
||||
node={node}
|
||||
depth={depth}
|
||||
isOpen={isOpen}
|
||||
selectedNode={selectedNode}
|
||||
onToggle={onToggle}
|
||||
onSelect={handleSelectNode}
|
||||
/>
|
||||
)}
|
||||
classes={{
|
||||
container: "flex flex-col",
|
||||
}}
|
||||
sort={false}
|
||||
onDrop={() => {}}
|
||||
/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
interface TreeNodeProps {
|
||||
node: NodeModel<TreeModel>;
|
||||
depth: number;
|
||||
isOpen: boolean;
|
||||
selectedNode: NodeModel<TreeModel> | null;
|
||||
onToggle: (id: NodeModel["id"]) => void;
|
||||
onSelect: (node: NodeModel<TreeModel>) => void;
|
||||
}
|
||||
|
||||
const ORGANIZATION_PREFIX = "OGNZ";
|
||||
|
||||
function TreeNode({
|
||||
node,
|
||||
depth,
|
||||
isOpen,
|
||||
selectedNode,
|
||||
onToggle,
|
||||
onSelect,
|
||||
}: TreeNodeProps) {
|
||||
const { id, text, data } = node;
|
||||
const indent = depth * 15 + 5;
|
||||
|
||||
const handleToggle = () => onToggle(id);
|
||||
const handleSelect = () => {
|
||||
if (id.toString().startsWith(ORGANIZATION_PREFIX)) return;
|
||||
onSelect(node);
|
||||
};
|
||||
|
||||
const isSelected = selectedNode?.id === id;
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{ paddingInlineStart: indent }}
|
||||
className="group flex cursor-pointer items-center justify-between gap-2 rounded-sm p-2 hover:bg-accent"
|
||||
onClick={handleSelect}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<div>
|
||||
{data && ("children" in data || "users" in data) && (
|
||||
<Button
|
||||
size="icon"
|
||||
className="h-6 w-6 !bg-transparent"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleToggle();
|
||||
}}
|
||||
>
|
||||
<i
|
||||
className={cn(
|
||||
"diveicon di-arrow-forward mr-2 text-base text-label",
|
||||
isOpen && "rotate-90",
|
||||
)}
|
||||
/>
|
||||
</Button>
|
||||
)}
|
||||
<span className="text-[1.4rem] font-medium text-label">{text}</span>
|
||||
</div>
|
||||
{isSelected && <i className="diveicon di-check text-xl text-primary" />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { OrganizationSearchDialog };
|
||||
@@ -1,22 +0,0 @@
|
||||
import { Button, Dialog, DialogTrigger } from "@common/components/ui";
|
||||
|
||||
type PermissionsManagementDialogProps = {
|
||||
menuCd?: number;
|
||||
} & React.ComponentProps<typeof Dialog>;
|
||||
|
||||
function PermissionsManagementDialog({
|
||||
...props
|
||||
}: PermissionsManagementDialogProps) {
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="gap-3">
|
||||
<i className="diveicon di-personal-information" />
|
||||
권한관리
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export { PermissionsManagementDialog };
|
||||
@@ -1,380 +0,0 @@
|
||||
import dayjs from "dayjs";
|
||||
import { type UseFormReturn } from "react-hook-form";
|
||||
import {
|
||||
DatePicker,
|
||||
IconFinder,
|
||||
Input,
|
||||
Label,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import {
|
||||
FormItem,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormMessage,
|
||||
} from "@/shared/ui/form";
|
||||
import type { BoardPopup } from "@/entities/board";
|
||||
import type { Content } from "../model/content-interface";
|
||||
import type { User } from "../model/organization-interface";
|
||||
import type { MenuFormData, MenuType } from "../model/menu-interface";
|
||||
import { OrganizationSearchDialog } from "./organization-search-dialog";
|
||||
import { ContentSearchDialog } from "./content-search-dialog";
|
||||
import { BoardSearchDialog } from "./board-search-dialog";
|
||||
|
||||
type TypeMenuFormProps = {
|
||||
form: UseFormReturn<MenuFormData>;
|
||||
menuType: MenuType;
|
||||
};
|
||||
|
||||
function TypeMenuForm({ form, menuType }: TypeMenuFormProps) {
|
||||
const handleIconClick = (icon: string) => {
|
||||
form.setValue("iconNm", icon);
|
||||
};
|
||||
|
||||
const handleContentSelect = (content: Content) => {
|
||||
form.setValue("menuLnkgSn", content.contsSn);
|
||||
form.setValue("menuLnkgSnNm", content.contsTtl);
|
||||
};
|
||||
|
||||
const handleUserSelect = (user: User) => {
|
||||
form.setValue("menuPicUserUnqId", user.userUnqId);
|
||||
form.setValue("menuPicUserUnqIdNm", user.userNm);
|
||||
};
|
||||
|
||||
const handleBoardSelect = (board: BoardPopup) => {
|
||||
form.setValue("menuLnkgSn", board.bbsId);
|
||||
form.setValue("menuLnkgSnNm", board.bbsNm);
|
||||
};
|
||||
|
||||
const handleDateSelect = (date: Date | undefined) => {
|
||||
if (!date) return;
|
||||
form.setValue("menuPicDsgnYmd", dayjs(date).format("YYYYMMDD"));
|
||||
};
|
||||
|
||||
return (
|
||||
<Table variant="secondary" className="-mt-[0.1rem]">
|
||||
<colgroup>
|
||||
<col width="20%" />
|
||||
<col width="80%" />
|
||||
</colgroup>
|
||||
<TableBody>
|
||||
{menuType === "CONTENTS" && (
|
||||
<TableRow>
|
||||
<TableHead>콘텐츠</TableHead>
|
||||
<TableCell className="border">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="h-[3.2rem] w-1/2 cursor-not-allowed overflow-hidden whitespace-nowrap break-keep rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||
{!form.watch("menuLnkgSnNm") &&
|
||||
"메뉴에 표시될 콘텐츠를 조회 후 선택하십시오."}
|
||||
{form.watch("menuLnkgSnNm")}
|
||||
</div>
|
||||
<ContentSearchDialog
|
||||
handleContentSelect={handleContentSelect}
|
||||
/>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{menuType === "BOARD" && (
|
||||
<TableRow>
|
||||
<TableHead>게시판</TableHead>
|
||||
<TableCell className="border">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="h-[3.2rem] w-1/2 cursor-not-allowed overflow-hidden whitespace-nowrap break-keep rounded-md border border-input bg-form px-3 py-2 text-[1.3rem] opacity-50">
|
||||
{!form.watch("menuLnkgSnNm") &&
|
||||
"메뉴에 표시될 게시판을 조회 후 선택하십시오."}
|
||||
{form.watch("menuLnkgSnNm")}
|
||||
</div>
|
||||
<BoardSearchDialog handleBoardSelect={handleBoardSelect} />
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{(menuType === "INSIDE" || menuType === "OUTSIDE") && (
|
||||
<TableRow>
|
||||
<TableHead>연결 URL</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="urlPath"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder={
|
||||
menuType === "INSIDE"
|
||||
? "메뉴에 연결된 페이지의 경로를 입력하십시오."
|
||||
: "'http://' 또는 'https://'를 포함하여 입력하십시오."
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{(menuType === "CONTENTS" ||
|
||||
menuType === "BOARD" ||
|
||||
menuType === "INSIDE" ||
|
||||
menuType === "OUTSIDE") && (
|
||||
<TableRow>
|
||||
<TableHead>연결 형태</TableHead>
|
||||
<TableCell className="border">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="newWndwYn"
|
||||
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="newWndwY" />
|
||||
<Label htmlFor="newWndwY">새창</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="N" id="newWndwN" />
|
||||
<Label htmlFor="newWndwN">현재창</Label>
|
||||
</div>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{(menuType === "CONTENTS" || menuType === "BOARD") && (
|
||||
<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>
|
||||
)}
|
||||
|
||||
{/* 메뉴 유형 공통 폼 S */}
|
||||
<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") && "아이콘을 조회 후 선택하십시오."}
|
||||
{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>
|
||||
{/* 메뉴 유형 공통 폼 E */}
|
||||
|
||||
{(menuType === "CONTENTS" || menuType === "BOARD") && (
|
||||
<>
|
||||
<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="flex items-center gap-6">
|
||||
<div className="flex items-center 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("menuPicUserUnqIdNm") &&
|
||||
"메뉴 담당자를 조회 후 선택하십시오."}
|
||||
{form.watch("menuPicUserUnqIdNm")}
|
||||
</div>
|
||||
<OrganizationSearchDialog
|
||||
handleUserSelect={handleUserSelect}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<b>지정일:</b>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="menuPicDsgnYmd"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<DatePicker
|
||||
mode="single"
|
||||
selected={
|
||||
field.value
|
||||
? dayjs(field.value).toDate()
|
||||
: undefined
|
||||
}
|
||||
onSelect={(date) => {
|
||||
field.onChange(date);
|
||||
handleDateSelect(date);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
||||
export { TypeMenuForm };
|
||||
@@ -1,28 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type {
|
||||
Domain,
|
||||
DomainService,
|
||||
DomainList,
|
||||
DomainParams,
|
||||
} from "../model/domain-interface";
|
||||
|
||||
export class DomainApiService implements DomainService {
|
||||
public async getDomainList(params: DomainParams): 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();
|
||||
@@ -1,22 +0,0 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { IpParams, IP, IpList, IpService } from "../model/ip-interface";
|
||||
|
||||
export class IpApiService implements IpService {
|
||||
public async getIpList(params: IpParams): 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();
|
||||
+7
-7
@@ -2,24 +2,24 @@ import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import {
|
||||
siteFormSchema,
|
||||
type ISiteInfo,
|
||||
type SiteService,
|
||||
type SiteList,
|
||||
type SiteDetail,
|
||||
type SiteParams,
|
||||
type ISiteDetail,
|
||||
type ISiteParams,
|
||||
type SiteFormData,
|
||||
} from "../model/site-interface";
|
||||
|
||||
export class SiteApiService implements SiteService {
|
||||
public async getSiteList(params: SiteParams): Promise<SiteList> {
|
||||
const response = await client.get<SiteList>(
|
||||
public async siteInfo(params: ISiteParams): Promise<ISiteInfo> {
|
||||
const response = await client.get<ISiteInfo>(
|
||||
`${ENDPOINT.CMS_SERVICE.SITES}`,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async siteDetail(siteId: string): Promise<SiteDetail> {
|
||||
const response = await client.get<SiteDetail>(
|
||||
public async siteDetail(siteId: string): Promise<ISiteDetail> {
|
||||
const response = await client.get<ISiteDetail>(
|
||||
`${ENDPOINT.CMS_SERVICE.SITES}/${siteId}`,
|
||||
);
|
||||
return response.data;
|
||||
@@ -1,31 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableParams, PageableList } from "@/shared/model";
|
||||
|
||||
export interface DomainParams extends PageableParams {
|
||||
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: DomainParams): Promise<DomainList>;
|
||||
saveDomainList(body: Domain[]): Promise<void>;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import type { PageableParams, PageableList } from "@/shared/model";
|
||||
|
||||
export interface IpParams extends PageableParams {
|
||||
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: IpParams): Promise<IpList>;
|
||||
saveIpList(body: IP[]): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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,8 +1,8 @@
|
||||
import dayjs from "dayjs";
|
||||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
import type { Site } from "@/entities/site";
|
||||
import type { ISite } from "./site-interface";
|
||||
|
||||
const columnHelper = createColumnHelper<Site>();
|
||||
const columnHelper = createColumnHelper<ISite>();
|
||||
|
||||
const columns = [
|
||||
columnHelper.accessor((_, index) => index + 1, {
|
||||
@@ -17,8 +17,8 @@ const columns = [
|
||||
id: "siteNm",
|
||||
header: "사이트명",
|
||||
}),
|
||||
columnHelper.accessor("dmnAddr", {
|
||||
id: "dmnAddr",
|
||||
columnHelper.accessor("siteAddr", {
|
||||
id: "siteAddr",
|
||||
header: "대표 URL",
|
||||
}),
|
||||
columnHelper.accessor("bscSiteYn", {
|
||||
|
||||
@@ -1,46 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { SiteApi, siteFormSchema, type SiteFormData } from "@/entities/site";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { PageLayout } from "@/shared/ui/page-layout";
|
||||
import { SiteApi } from "../api/site-service";
|
||||
import { siteFormSchema, type SiteFormData } from "../model/site-interface";
|
||||
import { SitePageLayout } from "./layout";
|
||||
import { SiteForm } from "./site-form";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
} from "@common/components/ui";
|
||||
|
||||
function CreatePage() {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const { mutateAsync: createSite } = useMutation({
|
||||
mutationFn: (data: SiteFormData) => SiteApi.createSite(data),
|
||||
onSuccess: () => {
|
||||
alert("등록되었습니다.", router.back);
|
||||
setIsCreateSuccess(true);
|
||||
},
|
||||
});
|
||||
|
||||
const [isCreateSuccess, setIsCreateSuccess] = useState(false);
|
||||
|
||||
const form = useForm<SiteFormData>({
|
||||
resolver: zodResolver(siteFormSchema),
|
||||
defaultValues: {
|
||||
siteId: "",
|
||||
siteNm: "",
|
||||
siteExpln: "",
|
||||
siteKndCd: "",
|
||||
siteAddr: "",
|
||||
faxNo: "",
|
||||
telNo: "",
|
||||
lwndCn: "",
|
||||
bscSiteYn: "",
|
||||
bkmkIcon: "",
|
||||
useYn: "",
|
||||
siteSkn: "",
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<PageLayout>
|
||||
<SitePageLayout>
|
||||
<SiteForm form={form} handleSave={createSite} />
|
||||
</PageLayout>
|
||||
<Dialog open={isCreateSuccess} onOpenChange={() => router.back()}>
|
||||
<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,8 +1,4 @@
|
||||
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 {
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
@@ -17,304 +13,197 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
Input,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Checkbox,
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
DialogFooter,
|
||||
DialogClose,
|
||||
Checkbox,
|
||||
} from "@common/components";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
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";
|
||||
|
||||
export type Domain = {
|
||||
id: number;
|
||||
domainUrl: string;
|
||||
isRepresentative: boolean;
|
||||
isActive: "true" | "false";
|
||||
};
|
||||
|
||||
type DomainManagementDialogProps = {
|
||||
siteId: string;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
handleSaveDomain?: (rows: Domain[]) => void;
|
||||
triggerDisabled?: boolean;
|
||||
handleSave: (rows: Domain[]) => void;
|
||||
};
|
||||
|
||||
function DomainManagementDialog({
|
||||
siteId,
|
||||
handleSaveDomain,
|
||||
...props
|
||||
triggerDisabled,
|
||||
handleSave,
|
||||
}: DomainManagementDialogProps) {
|
||||
const { confirm } = useConfirm();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const [rows, setRows] = useState<Domain[]>([]);
|
||||
const [rowSelection, setRowSelection] = useState<Domain["id"][]>([]);
|
||||
|
||||
const { data: domainList } = useQuery({
|
||||
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 onSave = () => {
|
||||
handleSave(rows);
|
||||
};
|
||||
|
||||
const handleAddDomain = () => {
|
||||
append({
|
||||
siteDmnNo: null,
|
||||
siteId,
|
||||
dmnAddr: "",
|
||||
useYn: "Y",
|
||||
rprsDmnYn: "N",
|
||||
mode: "C",
|
||||
});
|
||||
const newDomain: Domain = {
|
||||
id: Date.now(),
|
||||
domainUrl: "",
|
||||
isRepresentative: rows.length === 0,
|
||||
isActive: "true",
|
||||
};
|
||||
setRows([...rows, newDomain]);
|
||||
};
|
||||
|
||||
const handleSelectAll = () => {
|
||||
if (selectedRows.length === fields.length) {
|
||||
setSelectedRows([]);
|
||||
} else {
|
||||
setSelectedRows(fields.map((_, index) => index));
|
||||
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 handleSelectRow = (i: number) => {
|
||||
setSelectedRows((prev) =>
|
||||
prev.includes(i) ? prev.filter((j) => j !== i) : [...prev, i],
|
||||
const handleDomainUrlChange = (id: number, value: string) => {
|
||||
setRows(
|
||||
rows.map((row) => (row.id === id ? { ...row, domainUrl: value } : row)),
|
||||
);
|
||||
};
|
||||
|
||||
const handleDeleteDomain = async () => {
|
||||
if (selectedRows.length === 0) return;
|
||||
const handleRepresentativeChange = (id: number) => {
|
||||
setRows(
|
||||
rows.map((row) => ({
|
||||
...row,
|
||||
isRepresentative: row.id === id,
|
||||
})),
|
||||
);
|
||||
};
|
||||
|
||||
const sortedIndices = [...selectedRows].sort((a, b) => b - a);
|
||||
sortedIndices.forEach((i) => {
|
||||
const field = fields[i];
|
||||
if (field?.siteDmnNo) {
|
||||
update(i, {
|
||||
...field,
|
||||
mode: "D",
|
||||
});
|
||||
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 {
|
||||
remove(i);
|
||||
return [...prev, id];
|
||||
}
|
||||
});
|
||||
|
||||
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 (
|
||||
<>
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button>도메인 관리</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>도메인 관리</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
form.handleSubmit(onSubmit)(e);
|
||||
}}
|
||||
>
|
||||
<div className="mb-4 flex justify-end gap-2">
|
||||
<Button type="button" size="sm" onClick={handleAddDomain}>
|
||||
항목 추가
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
color="red"
|
||||
onClick={handleDeleteDomain}
|
||||
disabled={selectedRows.length === 0}
|
||||
>
|
||||
항목 삭제
|
||||
</Button>
|
||||
</div>
|
||||
<div className="card card-border max-h-[28.5rem] overflow-auto">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="10%" />
|
||||
<col width="auto" />
|
||||
<col width="15%" />
|
||||
<col width="25%" />
|
||||
</colgroup>
|
||||
<TableHeader className="sticky -top-[0.6rem]">
|
||||
<TableRow>
|
||||
<TableHead className="!px-0">
|
||||
<Checkbox
|
||||
checked={isAllSelected}
|
||||
onCheckedChange={handleSelectAll}
|
||||
/>
|
||||
</TableHead>
|
||||
<TableHead>도메인 주소</TableHead>
|
||||
<TableHead>대표 URL</TableHead>
|
||||
<TableHead>사용여부</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{fields.map((field, i) => {
|
||||
if (field.mode === "D") return null;
|
||||
return (
|
||||
<TableRow key={field.id}>
|
||||
<TableCell align="center" className="!px-0">
|
||||
<Checkbox
|
||||
checked={selectedRows.includes(i)}
|
||||
onCheckedChange={() => handleSelectRow(i)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`domains.${i}.dmnAddr`}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
className="!text-[1.3rem]"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage className="text-left" />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`domains.${i}.rprsDmnYn`}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value === "Y"}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked ? "Y" : "N");
|
||||
handleChangeRprsDmnYn(i);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
<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} />
|
||||
</>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button disabled={triggerDisabled}>도메인 관리</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-[60rem]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>도메인 관리</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="mb-4 flex justify-end gap-2">
|
||||
<Button size="sm" color="white" onClick={handleAddDomain}>
|
||||
항목 추가
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
color="red"
|
||||
onClick={handleDeleteDomain}
|
||||
disabled={rowSelection.length === 0}
|
||||
>
|
||||
항목 삭제
|
||||
</Button>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="8%" />
|
||||
<col width="12%" />
|
||||
<col width="40%" />
|
||||
<col width="20%" />
|
||||
<col width="20%" />
|
||||
</colgroup>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>NO</TableHead>
|
||||
<TableHead>선택</TableHead>
|
||||
<TableHead>도메인URL</TableHead>
|
||||
<TableHead>대표URL</TableHead>
|
||||
<TableHead>사용여부</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rows.map((row, idx) => (
|
||||
<TableRow key={row.id}>
|
||||
<TableCell align="center">{idx + 1}</TableCell>
|
||||
<TableCell align="center">
|
||||
<Checkbox
|
||||
checked={rowSelection.includes(row.id)}
|
||||
onCheckedChange={() => toggleRowSelection(row.id)}
|
||||
className="cursor-pointer"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<Input
|
||||
value={row.domainUrl}
|
||||
onChange={(e) =>
|
||||
handleDomainUrlChange(row.id, e.target.value)
|
||||
}
|
||||
className="!text-[1.3rem]"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<Checkbox
|
||||
checked={row.isRepresentative}
|
||||
onCheckedChange={() => handleRepresentativeChange(row.id)}
|
||||
className="cursor-pointer"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<Select
|
||||
value={row.isActive}
|
||||
onValueChange={(value: "true" | "false") =>
|
||||
handleActiveChange(row.id, value)
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="mx-auto w-[10rem]">
|
||||
<SelectValue placeholder="선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="true">예</SelectItem>
|
||||
<SelectItem value="false">아니오</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<DialogFooter className="!justify-center">
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" onClick={onSave}>
|
||||
저장
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" color="white">
|
||||
취소
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
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 {
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
@@ -19,266 +15,162 @@ import {
|
||||
Input,
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
Checkbox,
|
||||
DialogFooter,
|
||||
DialogClose,
|
||||
Checkbox,
|
||||
} from "@common/components";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
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 = {
|
||||
siteId: string;
|
||||
triggerDisabled?: boolean;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
type IP = {
|
||||
id: number;
|
||||
ipAddress: string;
|
||||
allowed: boolean;
|
||||
};
|
||||
|
||||
function IPManagementDialog({
|
||||
siteId,
|
||||
triggerDisabled,
|
||||
...props
|
||||
}: IPManagementDialogProps) {
|
||||
const { confirm } = useConfirm();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
type IPManagementDialogProps = {
|
||||
triggerDisabled?: boolean;
|
||||
};
|
||||
|
||||
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",
|
||||
}));
|
||||
function IPManagementDialog({ triggerDisabled }: IPManagementDialogProps) {
|
||||
const [rows, setRows] = useState<IP[]>([]);
|
||||
const [rowSelection, setRowSelection] = useState<IP["id"][]>([]);
|
||||
|
||||
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 onSave = () => {};
|
||||
|
||||
const handleAddIP = () => {
|
||||
append({
|
||||
mngNo: null,
|
||||
siteId,
|
||||
ipAddr: "",
|
||||
prmYn: "Y",
|
||||
mode: "C",
|
||||
});
|
||||
const newIP: IP = {
|
||||
id: Date.now(),
|
||||
ipAddress: "",
|
||||
allowed: true,
|
||||
};
|
||||
setRows([...rows, newIP]);
|
||||
};
|
||||
|
||||
const handleSelectAll = () => {
|
||||
if (selectedRows.length === fields.length) {
|
||||
setSelectedRows([]);
|
||||
} else {
|
||||
setSelectedRows(fields.map((_, index) => index));
|
||||
}
|
||||
const handleDeleteIP = () => {
|
||||
const filteredRows = rows.filter((row) => !rowSelection.includes(row.id));
|
||||
setRows(filteredRows);
|
||||
setRowSelection([]);
|
||||
};
|
||||
|
||||
const handleSelectRow = (i: number) => {
|
||||
setSelectedRows((prev) =>
|
||||
prev.includes(i) ? prev.filter((j) => j !== i) : [...prev, i],
|
||||
const handleIPAddressChange = (id: number, value: string) => {
|
||||
setRows(
|
||||
rows.map((row) => (row.id === id ? { ...row, ipAddress: value } : row)),
|
||||
);
|
||||
};
|
||||
|
||||
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 handleAllowedChange = (id: number, value: boolean) => {
|
||||
setRows(
|
||||
rows.map((row) => (row.id === id ? { ...row, allowed: value } : row)),
|
||||
);
|
||||
};
|
||||
|
||||
const isAllSelected =
|
||||
fields.length > 0 && selectedRows.length === fields.length;
|
||||
const toggleRowSelection = (id: number) => {
|
||||
setRowSelection((prev) => {
|
||||
if (prev.includes(id)) {
|
||||
return prev.filter((item) => item !== id);
|
||||
} else {
|
||||
return [...prev, id];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog {...props}>
|
||||
<DialogTrigger asChild>
|
||||
<Button disabled={triggerDisabled}>IP 관리</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-[60rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>IP 관리</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
form.handleSubmit(onSubmit)(e);
|
||||
}}
|
||||
>
|
||||
<div className="mb-4 flex justify-end gap-2">
|
||||
<Button type="button" size="sm" onClick={handleAddIP}>
|
||||
항목 추가
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
color="red"
|
||||
onClick={handleDeleteIP}
|
||||
disabled={selectedRows.length === 0}
|
||||
>
|
||||
항목 삭제
|
||||
</Button>
|
||||
</div>
|
||||
<div className="card card-border max-h-[28.5rem] overflow-auto">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="10%" />
|
||||
<col width="65%" />
|
||||
<col width="25%" />
|
||||
</colgroup>
|
||||
<TableHeader className="sticky -top-[0.6rem]">
|
||||
<TableRow>
|
||||
<TableHead className="!px-0">
|
||||
<Checkbox
|
||||
checked={isAllSelected}
|
||||
onCheckedChange={handleSelectAll}
|
||||
/>
|
||||
</TableHead>
|
||||
<TableHead>IP 주소</TableHead>
|
||||
<TableHead>허용여부</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{fields.map((field, i) => {
|
||||
if (field.mode === "D") return null;
|
||||
return (
|
||||
<TableRow key={field.id}>
|
||||
<TableCell align="center" className="!px-0">
|
||||
<Checkbox
|
||||
checked={selectedRows.includes(i)}
|
||||
onCheckedChange={() => handleSelectRow(i)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`ips.${i}.ipAddr`}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
className="!text-[1.3rem]"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage className="text-left" />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`ips.${i}.prmYn`}
|
||||
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={`prmY-${i}`}
|
||||
/>
|
||||
<label htmlFor={`prmY-${i}`}>예</label>
|
||||
</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} />
|
||||
</>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button disabled={triggerDisabled}>IP 관리</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-[60rem]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>IP 관리</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="mb-4 flex justify-end gap-2">
|
||||
<Button size="sm" color="green">
|
||||
엑셀 업로드
|
||||
</Button>
|
||||
<Button size="sm" color="white" onClick={handleAddIP}>
|
||||
항목 추가
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
color="red"
|
||||
onClick={handleDeleteIP}
|
||||
disabled={rowSelection.length === 0}
|
||||
>
|
||||
항목 삭제
|
||||
</Button>
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<Table variant="secondary">
|
||||
<colgroup>
|
||||
<col width="10%" />
|
||||
<col width="10%" />
|
||||
<col width="55%" />
|
||||
<col width="25%" />
|
||||
</colgroup>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>NO</TableHead>
|
||||
<TableHead>선택</TableHead>
|
||||
<TableHead>IP 주소</TableHead>
|
||||
<TableHead>허용여부</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rows.map((row, idx) => (
|
||||
<TableRow key={row.id}>
|
||||
<TableCell align="center">{idx + 1}</TableCell>
|
||||
<TableCell align="center">
|
||||
<Checkbox
|
||||
checked={rowSelection.includes(row.id)}
|
||||
onCheckedChange={() => toggleRowSelection(row.id)}
|
||||
className="cursor-pointer"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<Input
|
||||
value={row.ipAddress}
|
||||
onChange={(e) =>
|
||||
handleIPAddressChange(row.id, e.target.value)
|
||||
}
|
||||
className="!text-[1.3rem]"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<RadioGroup
|
||||
value={row.allowed ? "true" : "false"}
|
||||
onValueChange={(value) =>
|
||||
handleAllowedChange(row.id, value === "true")
|
||||
}
|
||||
className="flex justify-center"
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="true" id={`allow-${row.id}`} />
|
||||
<label htmlFor={`allow-${row.id}`}>예</label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="false" id={`deny-${row.id}`} />
|
||||
<label htmlFor={`deny-${row.id}`}>아니오</label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<DialogFooter className="!justify-center">
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" onClick={onSave}>
|
||||
저장
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<DialogClose asChild>
|
||||
<Button size="lg" color="white">
|
||||
취소
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
function SitePageLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="h-auto min-h-full bg-container">
|
||||
<h2 className="px-[1.8rem] pt-[2rem] text-[2.4rem] font-semibold text-title">
|
||||
사이트 관리
|
||||
</h2>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { SitePageLayout };
|
||||
@@ -1,76 +1,94 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
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 { PageLayout } from "@/shared/ui/page-layout";
|
||||
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
||||
import { SiteApi } from "../api/site-service";
|
||||
import {
|
||||
siteFormSchema,
|
||||
type ISiteDetail,
|
||||
type SiteFormData,
|
||||
} from "../model/site-interface";
|
||||
import { SitePageLayout } from "./layout";
|
||||
import { SiteForm } from "./site-form";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
} from "@common/components/ui";
|
||||
|
||||
function ModifyPage({ siteId }: { siteId: string }) {
|
||||
const isModifyMode = !!siteId;
|
||||
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
|
||||
const { data: siteDetail } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId],
|
||||
queryFn: () => SiteApi.siteDetail(siteId),
|
||||
select: (data) => {
|
||||
const keys = Object.keys(siteFormSchema.shape);
|
||||
const filteredData = Object.fromEntries(
|
||||
Object.entries(data).filter(([key]) => keys.includes(key)),
|
||||
);
|
||||
return {
|
||||
...filteredData,
|
||||
faxNo: data.faxNumber,
|
||||
bscSiteYn: data.basicSiteYn,
|
||||
};
|
||||
},
|
||||
select: (data) => ({
|
||||
...data,
|
||||
faxNo: data.faxNumber,
|
||||
bscSiteYn: data.basicSiteYn,
|
||||
}),
|
||||
enabled: isModifyMode,
|
||||
});
|
||||
|
||||
const { mutateAsync: modifySite } = useMutation({
|
||||
mutationFn: (data: SiteFormData) => SiteApi.modifySite(siteId, data),
|
||||
onSuccess: () => {
|
||||
alert("수정되었습니다.", () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||
});
|
||||
});
|
||||
setMessage("수정되었습니다.");
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: deleteSite } = useMutation({
|
||||
mutationFn: () => SiteApi.deleteSite(siteId),
|
||||
onSuccess: () => {
|
||||
alert("삭제되었습니다.", () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||
});
|
||||
router.back();
|
||||
});
|
||||
setMessage("삭제되었습니다.");
|
||||
},
|
||||
});
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
const form = useForm<SiteFormData>({
|
||||
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 (
|
||||
<PageLayout>
|
||||
<SitePageLayout>
|
||||
<SiteForm
|
||||
form={form}
|
||||
siteId={siteId}
|
||||
handleSave={modifySite}
|
||||
handleDelete={deleteSite}
|
||||
/>
|
||||
</PageLayout>
|
||||
<Dialog open={!!message} onOpenChange={() => router.back()}>
|
||||
<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,6 +4,10 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { type UseFormReturn } from "react-hook-form";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
Input,
|
||||
Label,
|
||||
RadioGroup,
|
||||
@@ -15,7 +19,6 @@ import {
|
||||
TableRow,
|
||||
} from "@common/components";
|
||||
import { CodeSelect } from "@/entities/code";
|
||||
import type { SiteFormData } from "@/entities/site";
|
||||
import {
|
||||
FormItem,
|
||||
FormControl,
|
||||
@@ -23,54 +26,47 @@ import {
|
||||
Form,
|
||||
FormMessage,
|
||||
} from "@/shared/ui/form";
|
||||
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
||||
import type { Domain } from "../model/domain-interface";
|
||||
import { type ISiteDetail, type SiteFormData } from "../model/site-interface";
|
||||
import { IPManagementDialog } from "./ip-management-dialog";
|
||||
import { DomainManagementDialog } from "./domain-management-dialog";
|
||||
import {
|
||||
DomainManagementDialog,
|
||||
type Domain,
|
||||
} from "./domain-management-dialog";
|
||||
|
||||
type SiteFormProps = {
|
||||
form: UseFormReturn<SiteFormData>;
|
||||
siteId?: string;
|
||||
handleSave: (data: SiteFormData) => Promise<void>;
|
||||
handleDelete?: () => Promise<void>;
|
||||
handleSave: (data: SiteFormData) => void;
|
||||
handleDelete?: () => void;
|
||||
};
|
||||
|
||||
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 router = useRouter();
|
||||
const { confirm } = useConfirm();
|
||||
const [onConfirm, setOnConfirm] = useState(false);
|
||||
const [isIpManagementOpen, setIsIpManagementOpen] = useState(false);
|
||||
const [isDomainManagementOpen, setIsDomainManagementOpen] = useState(false);
|
||||
const handleViewStateChange = (key: keyof ISiteDetail) => (value: string) => {
|
||||
setViewState({ ...viewState, [key]: value });
|
||||
};
|
||||
|
||||
const handleSaveDomain = (rows: Domain[]) => {
|
||||
form.setValue(
|
||||
"dmnAddr",
|
||||
rows.find((row) => row.rprsDmnYn === "Y")?.dmnAddr || "",
|
||||
const handleDomainSave = (rows: Domain[]) => {
|
||||
setRepresentativeDomain(
|
||||
rows.find((row) => row.isRepresentative)?.domainUrl || "",
|
||||
);
|
||||
};
|
||||
|
||||
const onSubmit = async (data: SiteFormData) => {
|
||||
const confirmMessage = isModifyMode
|
||||
? "수정하시겠습니까?"
|
||||
: "저장하시겠습니까?";
|
||||
|
||||
setOnConfirm(true);
|
||||
if (await confirm(confirmMessage)) {
|
||||
setOnConfirm(false);
|
||||
handleSave(data);
|
||||
}
|
||||
setOnConfirm(false);
|
||||
const onSubmit = (data: SiteFormData) => {
|
||||
handleSave(data);
|
||||
};
|
||||
|
||||
const onDelete = async () => {
|
||||
setOnConfirm(true);
|
||||
if (await confirm("삭제하시겠습니까?")) {
|
||||
setOnConfirm(false);
|
||||
if (await confirm("정말 삭제하시겠습니까?")) {
|
||||
handleDelete?.();
|
||||
}
|
||||
setOnConfirm(false);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -80,7 +76,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{isModifyMode ? "사이트 수정" : "사이트 등록"}
|
||||
사이트 등록/수정
|
||||
</h3>
|
||||
</div>
|
||||
<div className="card">
|
||||
@@ -101,7 +97,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="w-[12rem] !text-[1.3rem]"
|
||||
disabled={isModifyMode}
|
||||
/>
|
||||
@@ -125,7 +120,10 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<CodeSelect
|
||||
{...field}
|
||||
upCd="SITEKNDCD"
|
||||
onValueChange={field.onChange}
|
||||
onValueChange={(value) => {
|
||||
handleViewStateChange("siteKndCd")(value);
|
||||
field.onChange(value);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
@@ -134,10 +132,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
/>
|
||||
{isModifyMode && (
|
||||
<IPManagementDialog
|
||||
siteId={siteId}
|
||||
triggerDisabled={form.watch("siteKndCd") === "O"}
|
||||
open={isIpManagementOpen}
|
||||
onOpenChange={setIsIpManagementOpen}
|
||||
triggerDisabled={viewState.siteKndCd === "O"}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -154,7 +149,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<CodeSelect
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
upCd="SITESKINCD"
|
||||
onValueChange={field.onChange}
|
||||
/>
|
||||
@@ -176,7 +170,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="사이트명을 입력하십시오."
|
||||
/>
|
||||
@@ -198,7 +191,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="사이트 설명을 입력하십시오."
|
||||
/>
|
||||
@@ -215,13 +207,10 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<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("dmnAddr")}
|
||||
{representativeDomain}
|
||||
</div>
|
||||
<DomainManagementDialog
|
||||
siteId={siteId}
|
||||
open={isDomainManagementOpen}
|
||||
onOpenChange={setIsDomainManagementOpen}
|
||||
handleSaveDomain={handleSaveDomain}
|
||||
handleSave={handleDomainSave}
|
||||
/>
|
||||
</div>
|
||||
</TableCell>
|
||||
@@ -238,7 +227,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="사이트 하단 주소를 입력하십시오."
|
||||
/>
|
||||
@@ -260,7 +248,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="사이트 하단 전화번호를 입력하십시오."
|
||||
/>
|
||||
@@ -282,7 +269,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="사이트 하단 팩스번호를 입력하십시오."
|
||||
/>
|
||||
@@ -304,7 +290,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="사이트 표기 내용을 입력하십시오. (ex. COPYRIGHT c 2013 KECO. ALL RIGHTS RESERVED.)"
|
||||
/>
|
||||
@@ -326,7 +311,6 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
className="!text-[1.3rem]"
|
||||
placeholder="아이콘 파일 경로 및 파일명을 입력하여 주십시오."
|
||||
/>
|
||||
@@ -421,7 +405,25 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
<ConfirmDialog open={onConfirm} />
|
||||
<Dialog open={!!message} onOpenChange={onCancel}>
|
||||
<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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,30 +2,34 @@
|
||||
|
||||
import "@common/assets/styles/grid.css";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { type ISite, type ISiteParams } from "@/entities/site";
|
||||
import { SiteApi } from "@/entities/site/api/site-service";
|
||||
import { ENDPOINT } from "@/shared/config/api";
|
||||
import { Button, DataTable, Input } from "@common/components";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
||||
import { Button, DataTable, Input } from "@common/components";
|
||||
import { SiteApi, type Site, type SiteParams } from "@/entities/site";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { PageLayout } from "@/shared/ui/page-layout";
|
||||
import { columns } from "../model/table-columns";
|
||||
import { SitePageLayout } from "./layout";
|
||||
|
||||
function SitePage() {
|
||||
const router = useRouter();
|
||||
const { data: siteList, refetch } = useQuery({
|
||||
const { data: siteInfo, refetch } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.SITES],
|
||||
queryFn: () => SiteApi.getSiteList(siteQuery),
|
||||
queryFn: () => SiteApi.siteInfo(siteQuery),
|
||||
enabled: false,
|
||||
});
|
||||
|
||||
const [siteQuery, setSiteQuery] = useState<SiteParams>({
|
||||
const [siteQuery, setSiteQuery] = useState<ISiteParams>({
|
||||
siteNm: "",
|
||||
siteKndCd: "",
|
||||
useYn: "",
|
||||
page: 0,
|
||||
size: 0,
|
||||
sort: [],
|
||||
});
|
||||
|
||||
const table = useReactTable({
|
||||
data: siteList?.content ?? [],
|
||||
data: siteInfo?.content ?? [],
|
||||
columns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
});
|
||||
@@ -35,26 +39,29 @@ function SitePage() {
|
||||
refetch();
|
||||
};
|
||||
|
||||
const handleRowClick = (row: Site) => {
|
||||
const handleRowClick = (row: ISite) => {
|
||||
router.push(`/site/register/${row.siteId}`);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
refetch();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PageLayout>
|
||||
<SitePageLayout>
|
||||
<div className="card card-border !mt-6">
|
||||
<div className="card card-border">
|
||||
<div className="card card-border !border-[#dbe2e6] !bg-[#eef7ff]">
|
||||
<form onSubmit={handleSubmit} className="flex items-center gap-2 p-2">
|
||||
<label htmlFor="" className="mr-2 text-label">
|
||||
<label htmlFor="" className="mr-2 text-[#657481]">
|
||||
사이트명
|
||||
</label>
|
||||
<Input
|
||||
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem]"
|
||||
value={siteQuery.siteNm}
|
||||
onChange={(e) => setSiteQuery({ siteNm: e.target.value })}
|
||||
onChange={(e) =>
|
||||
setSiteQuery({ ...siteQuery, siteNm: e.target.value })
|
||||
}
|
||||
/>
|
||||
<Button className="h-[3.2rem]" type="submit">
|
||||
조회
|
||||
@@ -63,7 +70,7 @@ function SitePage() {
|
||||
</div>
|
||||
<div className="card card-border">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">사이트 목록</h3>
|
||||
<h3 className="text-2xl font-medium text-[#666]">사이트 목록</h3>
|
||||
<Button onClick={() => router.push("/site/register")}>등록</Button>
|
||||
</div>
|
||||
<div className="card !m-[1.2rem] h-[49rem] overflow-auto !p-0">
|
||||
@@ -71,7 +78,7 @@ function SitePage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PageLayout>
|
||||
</SitePageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ import { PROXY_HOST } from "./env";
|
||||
export const BASE_URL = `${PROXY_HOST}/server`;
|
||||
|
||||
export const ENDPOINT = {
|
||||
ATTACH_SERVICE: {
|
||||
TUS_UPLOAD: "/attach-service/api/v1/tus/upload",
|
||||
},
|
||||
USER_SERVICE: {
|
||||
LOGIN: "/user-service/login",
|
||||
USERS: "/user-service/api/v1/users",
|
||||
@@ -14,15 +11,6 @@ export const ENDPOINT = {
|
||||
CMS_SERVICE: {
|
||||
SITES: "/cms-service/api/v1/sites",
|
||||
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",
|
||||
MENU_ROLES: "/cms-service/api/v1/menu-roles",
|
||||
CONTENTS: "/cms-service/api/v1/contents",
|
||||
USER_OGNZ: "/cms-service/api/v1/user-ognz",
|
||||
},
|
||||
BOARD_SERVICE: {
|
||||
BBS: "/board-service/api/v1/bbs",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export { getCookie, setCookie, removeCookie } from "./cookie";
|
||||
export { useMenuStore } from "./use-menu-store";
|
||||
export { useUserStore } from "./use-user-store";
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
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,14 +0,0 @@
|
||||
import { useStore } from "zustand";
|
||||
import { useContext } from "react";
|
||||
import type { MenuStore } from "../store/menu-store";
|
||||
import { StoreContext } from "../providers/store-provider";
|
||||
|
||||
export const useMenuStore = <T>(selector: (store: MenuStore) => T): T => {
|
||||
const storeContext = useContext(StoreContext);
|
||||
|
||||
if (!storeContext) {
|
||||
throw new Error("useMenuStore must be used within StoreProvider");
|
||||
}
|
||||
|
||||
return useStore(storeContext.menuStore, selector);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useStore } from "zustand";
|
||||
import { useContext } from "react";
|
||||
import type { UserStore } from "../store/user-store";
|
||||
import { type UserStore } from "@/shared/store/user-store";
|
||||
import { StoreContext } from "../providers/store-provider";
|
||||
|
||||
export const useUserStore = <T>(selector: (store: UserStore) => T): T => {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
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 PageableParams {
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: string[];
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./api-interface";
|
||||
@@ -1 +1,2 @@
|
||||
export { QueryProvider } from "./query-provider";
|
||||
export { StoreProvider } from "./store-provider";
|
||||
|
||||
+4
-9
@@ -1,14 +1,9 @@
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
|
||||
export function QueryProvider({
|
||||
children,
|
||||
client,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
client?: QueryClient;
|
||||
}) {
|
||||
const queryClient = client ?? new QueryClient();
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export const QueryProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,11 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useRef } from "react";
|
||||
import { createAlertStore, createMenuStore, createUserStore } from "../store";
|
||||
import { createUserStore } from "@/shared/store/user-store";
|
||||
|
||||
type StoreContextType = {
|
||||
alertStore: ReturnType<typeof createAlertStore>;
|
||||
menuStore: ReturnType<typeof createMenuStore>;
|
||||
userStore: ReturnType<typeof createUserStore>;
|
||||
};
|
||||
|
||||
@@ -17,8 +15,6 @@ export const StoreProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const storeRef = useRef<StoreContextType | null>(null);
|
||||
if (storeRef.current === null) {
|
||||
storeRef.current = {
|
||||
alertStore: createAlertStore(),
|
||||
menuStore: createMenuStore(),
|
||||
userStore: createUserStore(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
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 })),
|
||||
}));
|
||||
};
|
||||
@@ -1,3 +1 @@
|
||||
export { createAlertStore } from "./alert-store";
|
||||
export { createMenuStore } from "./menu-store";
|
||||
export { createUserStore, type IUserInfo } from "./user-store";
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { createStore } from "zustand/vanilla";
|
||||
import type { MenuItem } from "@common/components/api";
|
||||
|
||||
export type MenuState = {
|
||||
currentMenuInfo: MenuItem | null;
|
||||
};
|
||||
|
||||
export type MenuActions = {
|
||||
setCurrentMenuInfo: (menu: MenuItem) => void;
|
||||
};
|
||||
|
||||
export type MenuStore = MenuState & MenuActions;
|
||||
|
||||
export const defaultInitState: MenuState = {
|
||||
currentMenuInfo: null,
|
||||
};
|
||||
|
||||
export const createMenuStore = (initState: MenuState = defaultInitState) => {
|
||||
return createStore<MenuStore>()((set) => ({
|
||||
...initState,
|
||||
setCurrentMenuInfo: (menu: MenuItem) => set({ currentMenuInfo: menu }),
|
||||
}));
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
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 };
|
||||
@@ -1,46 +0,0 @@
|
||||
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,22 +0,0 @@
|
||||
import { PageTitle } from "@common/components";
|
||||
import { useMenuStore } from "../lib/use-menu-store";
|
||||
|
||||
function PageLayout({ children }: { children: React.ReactNode }) {
|
||||
const { currentMenuInfo } = useMenuStore((state) => state);
|
||||
|
||||
const menuPaths = currentMenuInfo?.menuPath
|
||||
?.split(">")
|
||||
.map((path) => path.trim());
|
||||
|
||||
return (
|
||||
<div className="h-auto min-h-full bg-container">
|
||||
<PageTitle
|
||||
title={currentMenuInfo?.menuKornNm ?? ""}
|
||||
menuPaths={menuPaths ?? []}
|
||||
/>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { PageLayout };
|
||||
@@ -4,6 +4,7 @@ import presetConfig from "../../tailwind.config.preset";
|
||||
|
||||
export default {
|
||||
presets: [presetConfig],
|
||||
darkMode: ["class", "[data-mode='dark']"],
|
||||
content: [
|
||||
"./src/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"../../packages/common/components/src/ui/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-Oa0BRZMA0af-gZFbFik9
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"pages": {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"/favicon.ico/route":"/favicon.ico","/_not-found/page":"/_not-found","/publicReuseFaciltyInsert/page":"/publicReuseFaciltyInsert","/page":"/"}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"pages": {
|
||||
"/_app": []
|
||||
},
|
||||
"devFiles": [],
|
||||
"ampDevFiles": [],
|
||||
"polyfillFiles": [],
|
||||
"lowPriorityFiles": [
|
||||
"static/development/_ssgManifest.js",
|
||||
"static/development/_buildManifest.js"
|
||||
],
|
||||
"rootMainFiles": [],
|
||||
"ampFirstPages": []
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
+17
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
|
||||
"[project]/packages/common/components/postcss.config.js/transform.ts { CONFIG => \"[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)\" } [postcss] (ecmascript, async loader)": ((__turbopack_context__) => {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_export_value__((__turbopack_import__) => {
|
||||
return Promise.all([
|
||||
"build/chunks/08b5e__pnpm_9b08c8._.js",
|
||||
"build/chunks/[root of the server]__2c0f2d._.js"
|
||||
].map((chunk) => __turbopack_load__(chunk))).then(() => {
|
||||
return __turbopack_import__("[project]/packages/common/components/postcss.config.js/transform.ts { CONFIG => \"[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)\" } [postcss] (ecmascript)");
|
||||
});
|
||||
});
|
||||
}}),
|
||||
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sections": []
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
module.exports = {
|
||||
|
||||
"[externals]/path [external] (path, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("path", () => require("path"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[externals]/url [external] (url, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("url", () => require("url"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[externals]/fs [external] (fs, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("fs", () => require("fs"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[externals]/node:url [external] (node:url, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("node:url", () => require("node:url"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[externals]/node:path [external] (node:path, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("node:path", () => require("node:path"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, a: __turbopack_async_module__, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try {
|
||||
__turbopack_esm__({
|
||||
"default": (()=>__TURBOPACK__default__export__)
|
||||
});
|
||||
var __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$url__$5b$external$5d$__$28$node$3a$url$2c$__cjs$29$__ = __turbopack_import__("[externals]/node:url [external] (node:url, cjs)");
|
||||
var __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$path__$5b$external$5d$__$28$node$3a$path$2c$__cjs$29$__ = __turbopack_import__("[externals]/node:path [external] (node:path, cjs)");
|
||||
;
|
||||
;
|
||||
const configPath = __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$path__$5b$external$5d$__$28$node$3a$path$2c$__cjs$29$__["default"].join(process.cwd(), "../../packages/common/components/postcss.config.js");
|
||||
// Absolute paths don't work with ESM imports on Windows:
|
||||
// https://github.com/nodejs/node/issues/31710
|
||||
// convert it to a file:// URL, which works on all platforms
|
||||
const configUrl = (0, __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$url__$5b$external$5d$__$28$node$3a$url$2c$__cjs$29$__["pathToFileURL"])(configPath).toString();
|
||||
const mod = await __turbopack_external_import__(configUrl);
|
||||
const __TURBOPACK__default__export__ = mod.default ?? mod;
|
||||
__turbopack_async_result__();
|
||||
} catch(e) { __turbopack_async_result__(e); } }, true);}),
|
||||
"[project]/packages/common/components/postcss.config.js/transform.ts { CONFIG => \"[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)\" } [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, a: __turbopack_async_module__, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try {
|
||||
__turbopack_esm__({
|
||||
"default": (()=>transform),
|
||||
"init": (()=>init)
|
||||
});
|
||||
// @ts-ignore
|
||||
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$postcss$40$8$2e$5$2e$3$2f$node_modules$2f$postcss$2f$lib$2f$postcss$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[project]/node_modules/.pnpm/postcss@8.5.3/node_modules/postcss/lib/postcss.mjs [postcss] (ecmascript)");
|
||||
// @ts-ignore
|
||||
var __TURBOPACK__imported__module__$5b$project$5d2f$packages$2f$common$2f$components$2f$postcss$2e$config$2e$js_$2e$loader$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)");
|
||||
var __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__ = __turbopack_import__("[externals]/path [external] (path, cjs)");
|
||||
var __turbopack_async_dependencies__ = __turbopack_handle_async_dependencies__([
|
||||
__TURBOPACK__imported__module__$5b$project$5d2f$packages$2f$common$2f$components$2f$postcss$2e$config$2e$js_$2e$loader$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__
|
||||
]);
|
||||
([__TURBOPACK__imported__module__$5b$project$5d2f$packages$2f$common$2f$components$2f$postcss$2e$config$2e$js_$2e$loader$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__] = __turbopack_async_dependencies__.then ? (await __turbopack_async_dependencies__)() : __turbopack_async_dependencies__);
|
||||
;
|
||||
;
|
||||
;
|
||||
const contextDir = process.cwd();
|
||||
function toPath(file) {
|
||||
const relPath = (0, __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["relative"])(contextDir, file);
|
||||
if ((0, __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["isAbsolute"])(relPath)) {
|
||||
throw new Error(`Cannot depend on path (${file}) outside of root directory (${contextDir})`);
|
||||
}
|
||||
return __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["sep"] !== "/" ? relPath.replaceAll(__TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["sep"], "/") : relPath;
|
||||
}
|
||||
let processor;
|
||||
const init = async (ipc)=>{
|
||||
let config = __TURBOPACK__imported__module__$5b$project$5d2f$packages$2f$common$2f$components$2f$postcss$2e$config$2e$js_$2e$loader$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__["default"];
|
||||
if (typeof config === "function") {
|
||||
config = await config({
|
||||
env: "development"
|
||||
});
|
||||
}
|
||||
if (typeof config === "undefined") {
|
||||
throw new Error("PostCSS config is undefined (make sure to export an function or object from config file)");
|
||||
}
|
||||
let plugins;
|
||||
if (Array.isArray(config.plugins)) {
|
||||
plugins = config.plugins.map((plugin)=>{
|
||||
if (Array.isArray(plugin)) {
|
||||
return plugin;
|
||||
} else if (typeof plugin === "string") {
|
||||
return [
|
||||
plugin,
|
||||
{}
|
||||
];
|
||||
} else {
|
||||
return plugin;
|
||||
}
|
||||
});
|
||||
} else if (typeof config.plugins === "object") {
|
||||
plugins = Object.entries(config.plugins).filter(([, options])=>options);
|
||||
} else {
|
||||
plugins = [];
|
||||
}
|
||||
const loadedPlugins = plugins.map((plugin)=>{
|
||||
if (Array.isArray(plugin)) {
|
||||
const [arg, options] = plugin;
|
||||
let pluginFactory = arg;
|
||||
if (typeof pluginFactory === "string") {
|
||||
pluginFactory = require(/* turbopackIgnore: true */ pluginFactory);
|
||||
}
|
||||
if (pluginFactory.default) {
|
||||
pluginFactory = pluginFactory.default;
|
||||
}
|
||||
return pluginFactory(options);
|
||||
}
|
||||
return plugin;
|
||||
});
|
||||
processor = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$postcss$40$8$2e$5$2e$3$2f$node_modules$2f$postcss$2f$lib$2f$postcss$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__["default"])(loadedPlugins);
|
||||
};
|
||||
async function transform(ipc, cssContent, name) {
|
||||
const { css, map, messages } = await processor.process(cssContent, {
|
||||
from: name,
|
||||
to: name,
|
||||
map: {
|
||||
inline: false,
|
||||
annotation: false
|
||||
}
|
||||
});
|
||||
const assets = [];
|
||||
for (const msg of messages){
|
||||
switch(msg.type){
|
||||
case "asset":
|
||||
assets.push({
|
||||
file: msg.file,
|
||||
content: msg.content,
|
||||
sourceMap: typeof msg.sourceMap === "string" ? msg.sourceMap : JSON.stringify(msg.sourceMap)
|
||||
});
|
||||
break;
|
||||
case "dependency":
|
||||
case "missing-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "fileDependency",
|
||||
path: toPath(msg.file)
|
||||
});
|
||||
break;
|
||||
case "build-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "buildDependency",
|
||||
path: toPath(msg.file)
|
||||
});
|
||||
break;
|
||||
case "dir-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "dirDependency",
|
||||
path: toPath(msg.dir),
|
||||
glob: msg.glob
|
||||
});
|
||||
break;
|
||||
case "context-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "dirDependency",
|
||||
path: toPath(msg.file),
|
||||
glob: "**"
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
css,
|
||||
map: JSON.stringify(map),
|
||||
assets
|
||||
};
|
||||
}
|
||||
__turbopack_async_result__();
|
||||
} catch(e) { __turbopack_async_result__(e); } }, false);}),
|
||||
|
||||
};
|
||||
|
||||
//# sourceMappingURL=%5Broot%20of%20the%20server%5D__2c0f2d._.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,498 @@
|
||||
module.exports = {
|
||||
|
||||
"[externals]/node:net [external] (node:net, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("node:net", () => require("node:net"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[turbopack-node]/compiled/stacktrace-parser/index.js [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"parse": (()=>parse)
|
||||
});
|
||||
if (typeof __nccwpck_require__ !== "undefined") __nccwpck_require__.ab = __dirname + "/";
|
||||
var n = "<unknown>";
|
||||
function parse(e) {
|
||||
var r = e.split("\n");
|
||||
return r.reduce(function(e, r) {
|
||||
var n = parseChrome(r) || parseWinjs(r) || parseGecko(r) || parseNode(r) || parseJSC(r);
|
||||
if (n) {
|
||||
e.push(n);
|
||||
}
|
||||
return e;
|
||||
}, []);
|
||||
}
|
||||
var a = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
||||
var l = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
||||
function parseChrome(e) {
|
||||
var r = a.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
var u = r[2] && r[2].indexOf("native") === 0;
|
||||
var t = r[2] && r[2].indexOf("eval") === 0;
|
||||
var i = l.exec(r[2]);
|
||||
if (t && i != null) {
|
||||
r[2] = i[1];
|
||||
r[3] = i[2];
|
||||
r[4] = i[3];
|
||||
}
|
||||
return {
|
||||
file: !u ? r[2] : null,
|
||||
methodName: r[1] || n,
|
||||
arguments: u ? [
|
||||
r[2]
|
||||
] : [],
|
||||
lineNumber: r[3] ? +r[3] : null,
|
||||
column: r[4] ? +r[4] : null
|
||||
};
|
||||
}
|
||||
var u = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
||||
function parseWinjs(e) {
|
||||
var r = u.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: r[2],
|
||||
methodName: r[1] || n,
|
||||
arguments: [],
|
||||
lineNumber: +r[3],
|
||||
column: r[4] ? +r[4] : null
|
||||
};
|
||||
}
|
||||
var t = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
|
||||
var i = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
||||
function parseGecko(e) {
|
||||
var r = t.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
var a = r[3] && r[3].indexOf(" > eval") > -1;
|
||||
var l = i.exec(r[3]);
|
||||
if (a && l != null) {
|
||||
r[3] = l[1];
|
||||
r[4] = l[2];
|
||||
r[5] = null;
|
||||
}
|
||||
return {
|
||||
file: r[3],
|
||||
methodName: r[1] || n,
|
||||
arguments: r[2] ? r[2].split(",") : [],
|
||||
lineNumber: r[4] ? +r[4] : null,
|
||||
column: r[5] ? +r[5] : null
|
||||
};
|
||||
}
|
||||
var s = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
|
||||
function parseJSC(e) {
|
||||
var r = s.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: r[3],
|
||||
methodName: r[1] || n,
|
||||
arguments: [],
|
||||
lineNumber: +r[4],
|
||||
column: r[5] ? +r[5] : null
|
||||
};
|
||||
}
|
||||
var o = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
||||
function parseNode(e) {
|
||||
var r = o.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: r[2],
|
||||
methodName: r[1] || n,
|
||||
arguments: [],
|
||||
lineNumber: +r[3],
|
||||
column: r[4] ? +r[4] : null
|
||||
};
|
||||
}
|
||||
}}),
|
||||
"[turbopack-node]/ipc/error.ts [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
// merged from next.js
|
||||
// https://github.com/vercel/next.js/blob/e657741b9908cf0044aaef959c0c4defb19ed6d8/packages/next/src/lib/is-error.ts
|
||||
// https://github.com/vercel/next.js/blob/e657741b9908cf0044aaef959c0c4defb19ed6d8/packages/next/src/shared/lib/is-plain-object.ts
|
||||
__turbopack_esm__({
|
||||
"default": (()=>isError),
|
||||
"getProperError": (()=>getProperError)
|
||||
});
|
||||
function isError(err) {
|
||||
return typeof err === "object" && err !== null && "name" in err && "message" in err;
|
||||
}
|
||||
function getProperError(err) {
|
||||
if (isError(err)) {
|
||||
return err;
|
||||
}
|
||||
if ("TURBOPACK compile-time truthy", 1) {
|
||||
// Provide a better error message for cases where `throw undefined`
|
||||
// is called in development
|
||||
if (typeof err === "undefined") {
|
||||
return new Error("`undefined` was thrown instead of a real error");
|
||||
}
|
||||
if (err === null) {
|
||||
return new Error("`null` was thrown instead of a real error");
|
||||
}
|
||||
}
|
||||
return new Error(isPlainObject(err) ? JSON.stringify(err) : err + "");
|
||||
}
|
||||
function getObjectClassLabel(value) {
|
||||
return Object.prototype.toString.call(value);
|
||||
}
|
||||
function isPlainObject(value) {
|
||||
if (getObjectClassLabel(value) !== "[object Object]") {
|
||||
return false;
|
||||
}
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
/**
|
||||
* this used to be previously:
|
||||
*
|
||||
* `return prototype === null || prototype === Object.prototype`
|
||||
*
|
||||
* but Edge Runtime expose Object from vm, being that kind of type-checking wrongly fail.
|
||||
*
|
||||
* It was changed to the current implementation since it's resilient to serialization.
|
||||
*/ return prototype === null || prototype.hasOwnProperty("isPrototypeOf");
|
||||
}
|
||||
}}),
|
||||
"[turbopack-node]/ipc/index.ts [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"IPC": (()=>IPC),
|
||||
"structuredError": (()=>structuredError)
|
||||
});
|
||||
var __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$net__$5b$external$5d$__$28$node$3a$net$2c$__cjs$29$__ = __turbopack_import__("[externals]/node:net [external] (node:net, cjs)");
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$compiled$2f$stacktrace$2d$parser$2f$index$2e$js__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/compiled/stacktrace-parser/index.js [postcss] (ecmascript)");
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$error$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/ipc/error.ts [postcss] (ecmascript)");
|
||||
;
|
||||
;
|
||||
;
|
||||
function structuredError(e) {
|
||||
e = (0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$error$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["getProperError"])(e);
|
||||
return {
|
||||
name: e.name,
|
||||
message: e.message,
|
||||
stack: typeof e.stack === "string" ? (0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$compiled$2f$stacktrace$2d$parser$2f$index$2e$js__$5b$postcss$5d$__$28$ecmascript$29$__["parse"])(e.stack) : [],
|
||||
cause: e.cause ? structuredError((0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$error$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["getProperError"])(e.cause)) : undefined
|
||||
};
|
||||
}
|
||||
function createIpc(port) {
|
||||
const socket = (0, __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$net__$5b$external$5d$__$28$node$3a$net$2c$__cjs$29$__["createConnection"])(port, "127.0.0.1");
|
||||
const packetQueue = [];
|
||||
const recvPromiseResolveQueue = [];
|
||||
function pushPacket(packet) {
|
||||
const recvPromiseResolve = recvPromiseResolveQueue.shift();
|
||||
if (recvPromiseResolve != null) {
|
||||
recvPromiseResolve(JSON.parse(packet.toString("utf8")));
|
||||
} else {
|
||||
packetQueue.push(packet);
|
||||
}
|
||||
}
|
||||
let state = {
|
||||
type: "waiting"
|
||||
};
|
||||
let buffer = Buffer.alloc(0);
|
||||
socket.once("connect", ()=>{
|
||||
socket.on("data", (chunk)=>{
|
||||
buffer = Buffer.concat([
|
||||
buffer,
|
||||
chunk
|
||||
]);
|
||||
loop: while(true){
|
||||
switch(state.type){
|
||||
case "waiting":
|
||||
{
|
||||
if (buffer.length >= 4) {
|
||||
const length = buffer.readUInt32BE(0);
|
||||
buffer = buffer.subarray(4);
|
||||
state = {
|
||||
type: "packet",
|
||||
length
|
||||
};
|
||||
} else {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "packet":
|
||||
{
|
||||
if (buffer.length >= state.length) {
|
||||
const packet = buffer.subarray(0, state.length);
|
||||
buffer = buffer.subarray(state.length);
|
||||
state = {
|
||||
type: "waiting"
|
||||
};
|
||||
pushPacket(packet);
|
||||
} else {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
invariant(state, (state)=>`Unknown state type: ${state?.type}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// When the socket is closed, this process is no longer needed.
|
||||
// This might happen e. g. when parent process is killed or
|
||||
// node.js pool is garbage collected.
|
||||
socket.once("close", ()=>{
|
||||
process.exit(0);
|
||||
});
|
||||
function send(message) {
|
||||
const packet = Buffer.from(JSON.stringify(message), "utf8");
|
||||
const length = Buffer.alloc(4);
|
||||
length.writeUInt32BE(packet.length);
|
||||
socket.write(length);
|
||||
return new Promise((resolve, reject)=>{
|
||||
socket.write(packet, (err)=>{
|
||||
process.stderr.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
process.stdout.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
if (err != null) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function sendReady() {
|
||||
const length = Buffer.from([
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]);
|
||||
return new Promise((resolve, reject)=>{
|
||||
socket.write(length, (err)=>{
|
||||
process.stderr.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
process.stdout.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
if (err != null) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return {
|
||||
async recv () {
|
||||
const packet = packetQueue.shift();
|
||||
if (packet != null) {
|
||||
return JSON.parse(packet.toString("utf8"));
|
||||
}
|
||||
const result = await new Promise((resolve)=>{
|
||||
recvPromiseResolveQueue.push((result)=>{
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
return result;
|
||||
},
|
||||
send (message) {
|
||||
return send(message);
|
||||
},
|
||||
sendReady,
|
||||
async sendError (error) {
|
||||
try {
|
||||
await send({
|
||||
type: "error",
|
||||
...structuredError(error)
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("failed to send error back to rust:", err);
|
||||
// ignore and exit anyway
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
const PORT = process.argv[2];
|
||||
const IPC = createIpc(parseInt(PORT, 10));
|
||||
process.on("uncaughtException", (err)=>{
|
||||
IPC.sendError(err);
|
||||
});
|
||||
const improveConsole = (name, stream, addStack)=>{
|
||||
// @ts-ignore
|
||||
const original = console[name];
|
||||
// @ts-ignore
|
||||
const stdio = process[stream];
|
||||
// @ts-ignore
|
||||
console[name] = (...args)=>{
|
||||
stdio.write(`TURBOPACK_OUTPUT_B\n`);
|
||||
original(...args);
|
||||
if (addStack) {
|
||||
const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n";
|
||||
stdio.write("TURBOPACK_OUTPUT_S\n");
|
||||
stdio.write(stack);
|
||||
}
|
||||
stdio.write("TURBOPACK_OUTPUT_E\n");
|
||||
};
|
||||
};
|
||||
improveConsole("error", "stderr", true);
|
||||
improveConsole("warn", "stderr", true);
|
||||
improveConsole("count", "stdout", true);
|
||||
improveConsole("trace", "stderr", false);
|
||||
improveConsole("log", "stdout", true);
|
||||
improveConsole("group", "stdout", true);
|
||||
improveConsole("groupCollapsed", "stdout", true);
|
||||
improveConsole("table", "stdout", true);
|
||||
improveConsole("debug", "stdout", true);
|
||||
improveConsole("info", "stdout", true);
|
||||
improveConsole("dir", "stdout", true);
|
||||
improveConsole("dirxml", "stdout", true);
|
||||
improveConsole("timeEnd", "stdout", true);
|
||||
improveConsole("timeLog", "stdout", true);
|
||||
improveConsole("timeStamp", "stdout", true);
|
||||
improveConsole("assert", "stderr", true);
|
||||
/**
|
||||
* Utility function to ensure all variants of an enum are handled.
|
||||
*/ function invariant(never, computeMessage) {
|
||||
throw new Error(`Invariant: ${computeMessage(never)}`);
|
||||
}
|
||||
}}),
|
||||
"[turbopack-node]/ipc/evaluate.ts [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"run": (()=>run)
|
||||
});
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$index$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/ipc/index.ts [postcss] (ecmascript)");
|
||||
;
|
||||
const ipc = __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$index$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["IPC"];
|
||||
const queue = [];
|
||||
const run = async (moduleFactory)=>{
|
||||
let nextId = 1;
|
||||
const requests = new Map();
|
||||
const internalIpc = {
|
||||
sendInfo: (message)=>ipc.send({
|
||||
type: "info",
|
||||
data: message
|
||||
}),
|
||||
sendRequest: (message)=>{
|
||||
const id = nextId++;
|
||||
let resolve, reject;
|
||||
const promise = new Promise((res, rej)=>{
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
requests.set(id, {
|
||||
resolve,
|
||||
reject
|
||||
});
|
||||
return ipc.send({
|
||||
type: "request",
|
||||
id,
|
||||
data: message
|
||||
}).then(()=>promise);
|
||||
},
|
||||
sendError: (error)=>{
|
||||
return ipc.sendError(error);
|
||||
}
|
||||
};
|
||||
// Initialize module and send ready message
|
||||
let getValue;
|
||||
try {
|
||||
const module = await moduleFactory();
|
||||
if (typeof module.init === "function") {
|
||||
await module.init();
|
||||
}
|
||||
getValue = module.default;
|
||||
await ipc.sendReady();
|
||||
} catch (err) {
|
||||
await ipc.sendReady();
|
||||
await ipc.sendError(err);
|
||||
}
|
||||
// Queue handling
|
||||
let isRunning = false;
|
||||
const run = async ()=>{
|
||||
while(queue.length > 0){
|
||||
const args = queue.shift();
|
||||
try {
|
||||
const value = await getValue(internalIpc, ...args);
|
||||
await ipc.send({
|
||||
type: "end",
|
||||
data: value === undefined ? undefined : JSON.stringify(value, null, 2),
|
||||
duration: 0
|
||||
});
|
||||
} catch (e) {
|
||||
await ipc.sendError(e);
|
||||
}
|
||||
}
|
||||
isRunning = false;
|
||||
};
|
||||
// Communication handling
|
||||
while(true){
|
||||
const msg = await ipc.recv();
|
||||
switch(msg.type){
|
||||
case "evaluate":
|
||||
{
|
||||
queue.push(msg.args);
|
||||
if (!isRunning) {
|
||||
isRunning = true;
|
||||
run();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "result":
|
||||
{
|
||||
const request = requests.get(msg.id);
|
||||
if (request) {
|
||||
requests.delete(msg.id);
|
||||
if (msg.error) {
|
||||
request.reject(new Error(msg.error));
|
||||
} else {
|
||||
request.resolve(msg.data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
console.error("unexpected message type", msg.type);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}}),
|
||||
"[turbopack-node]/ipc/evaluate.ts/evaluate.js { INNER => \"[project]/apps/wr/postcss.config.mjs/transform.ts { CONFIG => \\\"[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)\\\" } [postcss] (ecmascript)\", RUNTIME => \"[turbopack-node]/ipc/evaluate.ts [postcss] (ecmascript)\" } [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({});
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$evaluate$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/ipc/evaluate.ts [postcss] (ecmascript)");
|
||||
;
|
||||
(0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$evaluate$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["run"])(()=>__turbopack_require__('[project]/apps/wr/postcss.config.mjs/transform.ts { CONFIG => "[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)" } [postcss] (ecmascript, async loader)')(__turbopack_import__));
|
||||
}}),
|
||||
"[turbopack-node]/globals.ts [postcss] (ecmascript)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
// @ts-ignore
|
||||
process.turbopack = {};
|
||||
}}),
|
||||
|
||||
};
|
||||
|
||||
//# sourceMappingURL=%5Broot%20of%20the%20server%5D__682b1a._.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,498 @@
|
||||
module.exports = {
|
||||
|
||||
"[externals]/node:net [external] (node:net, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("node:net", () => require("node:net"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[turbopack-node]/compiled/stacktrace-parser/index.js [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"parse": (()=>parse)
|
||||
});
|
||||
if (typeof __nccwpck_require__ !== "undefined") __nccwpck_require__.ab = __dirname + "/";
|
||||
var n = "<unknown>";
|
||||
function parse(e) {
|
||||
var r = e.split("\n");
|
||||
return r.reduce(function(e, r) {
|
||||
var n = parseChrome(r) || parseWinjs(r) || parseGecko(r) || parseNode(r) || parseJSC(r);
|
||||
if (n) {
|
||||
e.push(n);
|
||||
}
|
||||
return e;
|
||||
}, []);
|
||||
}
|
||||
var a = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
||||
var l = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
||||
function parseChrome(e) {
|
||||
var r = a.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
var u = r[2] && r[2].indexOf("native") === 0;
|
||||
var t = r[2] && r[2].indexOf("eval") === 0;
|
||||
var i = l.exec(r[2]);
|
||||
if (t && i != null) {
|
||||
r[2] = i[1];
|
||||
r[3] = i[2];
|
||||
r[4] = i[3];
|
||||
}
|
||||
return {
|
||||
file: !u ? r[2] : null,
|
||||
methodName: r[1] || n,
|
||||
arguments: u ? [
|
||||
r[2]
|
||||
] : [],
|
||||
lineNumber: r[3] ? +r[3] : null,
|
||||
column: r[4] ? +r[4] : null
|
||||
};
|
||||
}
|
||||
var u = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
||||
function parseWinjs(e) {
|
||||
var r = u.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: r[2],
|
||||
methodName: r[1] || n,
|
||||
arguments: [],
|
||||
lineNumber: +r[3],
|
||||
column: r[4] ? +r[4] : null
|
||||
};
|
||||
}
|
||||
var t = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
|
||||
var i = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
||||
function parseGecko(e) {
|
||||
var r = t.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
var a = r[3] && r[3].indexOf(" > eval") > -1;
|
||||
var l = i.exec(r[3]);
|
||||
if (a && l != null) {
|
||||
r[3] = l[1];
|
||||
r[4] = l[2];
|
||||
r[5] = null;
|
||||
}
|
||||
return {
|
||||
file: r[3],
|
||||
methodName: r[1] || n,
|
||||
arguments: r[2] ? r[2].split(",") : [],
|
||||
lineNumber: r[4] ? +r[4] : null,
|
||||
column: r[5] ? +r[5] : null
|
||||
};
|
||||
}
|
||||
var s = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
|
||||
function parseJSC(e) {
|
||||
var r = s.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: r[3],
|
||||
methodName: r[1] || n,
|
||||
arguments: [],
|
||||
lineNumber: +r[4],
|
||||
column: r[5] ? +r[5] : null
|
||||
};
|
||||
}
|
||||
var o = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
||||
function parseNode(e) {
|
||||
var r = o.exec(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
file: r[2],
|
||||
methodName: r[1] || n,
|
||||
arguments: [],
|
||||
lineNumber: +r[3],
|
||||
column: r[4] ? +r[4] : null
|
||||
};
|
||||
}
|
||||
}}),
|
||||
"[turbopack-node]/ipc/error.ts [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
// merged from next.js
|
||||
// https://github.com/vercel/next.js/blob/e657741b9908cf0044aaef959c0c4defb19ed6d8/packages/next/src/lib/is-error.ts
|
||||
// https://github.com/vercel/next.js/blob/e657741b9908cf0044aaef959c0c4defb19ed6d8/packages/next/src/shared/lib/is-plain-object.ts
|
||||
__turbopack_esm__({
|
||||
"default": (()=>isError),
|
||||
"getProperError": (()=>getProperError)
|
||||
});
|
||||
function isError(err) {
|
||||
return typeof err === "object" && err !== null && "name" in err && "message" in err;
|
||||
}
|
||||
function getProperError(err) {
|
||||
if (isError(err)) {
|
||||
return err;
|
||||
}
|
||||
if ("TURBOPACK compile-time truthy", 1) {
|
||||
// Provide a better error message for cases where `throw undefined`
|
||||
// is called in development
|
||||
if (typeof err === "undefined") {
|
||||
return new Error("`undefined` was thrown instead of a real error");
|
||||
}
|
||||
if (err === null) {
|
||||
return new Error("`null` was thrown instead of a real error");
|
||||
}
|
||||
}
|
||||
return new Error(isPlainObject(err) ? JSON.stringify(err) : err + "");
|
||||
}
|
||||
function getObjectClassLabel(value) {
|
||||
return Object.prototype.toString.call(value);
|
||||
}
|
||||
function isPlainObject(value) {
|
||||
if (getObjectClassLabel(value) !== "[object Object]") {
|
||||
return false;
|
||||
}
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
/**
|
||||
* this used to be previously:
|
||||
*
|
||||
* `return prototype === null || prototype === Object.prototype`
|
||||
*
|
||||
* but Edge Runtime expose Object from vm, being that kind of type-checking wrongly fail.
|
||||
*
|
||||
* It was changed to the current implementation since it's resilient to serialization.
|
||||
*/ return prototype === null || prototype.hasOwnProperty("isPrototypeOf");
|
||||
}
|
||||
}}),
|
||||
"[turbopack-node]/ipc/index.ts [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"IPC": (()=>IPC),
|
||||
"structuredError": (()=>structuredError)
|
||||
});
|
||||
var __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$net__$5b$external$5d$__$28$node$3a$net$2c$__cjs$29$__ = __turbopack_import__("[externals]/node:net [external] (node:net, cjs)");
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$compiled$2f$stacktrace$2d$parser$2f$index$2e$js__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/compiled/stacktrace-parser/index.js [postcss] (ecmascript)");
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$error$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/ipc/error.ts [postcss] (ecmascript)");
|
||||
;
|
||||
;
|
||||
;
|
||||
function structuredError(e) {
|
||||
e = (0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$error$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["getProperError"])(e);
|
||||
return {
|
||||
name: e.name,
|
||||
message: e.message,
|
||||
stack: typeof e.stack === "string" ? (0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$compiled$2f$stacktrace$2d$parser$2f$index$2e$js__$5b$postcss$5d$__$28$ecmascript$29$__["parse"])(e.stack) : [],
|
||||
cause: e.cause ? structuredError((0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$error$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["getProperError"])(e.cause)) : undefined
|
||||
};
|
||||
}
|
||||
function createIpc(port) {
|
||||
const socket = (0, __TURBOPACK__imported__module__$5b$externals$5d2f$node$3a$net__$5b$external$5d$__$28$node$3a$net$2c$__cjs$29$__["createConnection"])(port, "127.0.0.1");
|
||||
const packetQueue = [];
|
||||
const recvPromiseResolveQueue = [];
|
||||
function pushPacket(packet) {
|
||||
const recvPromiseResolve = recvPromiseResolveQueue.shift();
|
||||
if (recvPromiseResolve != null) {
|
||||
recvPromiseResolve(JSON.parse(packet.toString("utf8")));
|
||||
} else {
|
||||
packetQueue.push(packet);
|
||||
}
|
||||
}
|
||||
let state = {
|
||||
type: "waiting"
|
||||
};
|
||||
let buffer = Buffer.alloc(0);
|
||||
socket.once("connect", ()=>{
|
||||
socket.on("data", (chunk)=>{
|
||||
buffer = Buffer.concat([
|
||||
buffer,
|
||||
chunk
|
||||
]);
|
||||
loop: while(true){
|
||||
switch(state.type){
|
||||
case "waiting":
|
||||
{
|
||||
if (buffer.length >= 4) {
|
||||
const length = buffer.readUInt32BE(0);
|
||||
buffer = buffer.subarray(4);
|
||||
state = {
|
||||
type: "packet",
|
||||
length
|
||||
};
|
||||
} else {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "packet":
|
||||
{
|
||||
if (buffer.length >= state.length) {
|
||||
const packet = buffer.subarray(0, state.length);
|
||||
buffer = buffer.subarray(state.length);
|
||||
state = {
|
||||
type: "waiting"
|
||||
};
|
||||
pushPacket(packet);
|
||||
} else {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
invariant(state, (state)=>`Unknown state type: ${state?.type}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// When the socket is closed, this process is no longer needed.
|
||||
// This might happen e. g. when parent process is killed or
|
||||
// node.js pool is garbage collected.
|
||||
socket.once("close", ()=>{
|
||||
process.exit(0);
|
||||
});
|
||||
function send(message) {
|
||||
const packet = Buffer.from(JSON.stringify(message), "utf8");
|
||||
const length = Buffer.alloc(4);
|
||||
length.writeUInt32BE(packet.length);
|
||||
socket.write(length);
|
||||
return new Promise((resolve, reject)=>{
|
||||
socket.write(packet, (err)=>{
|
||||
process.stderr.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
process.stdout.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
if (err != null) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function sendReady() {
|
||||
const length = Buffer.from([
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]);
|
||||
return new Promise((resolve, reject)=>{
|
||||
socket.write(length, (err)=>{
|
||||
process.stderr.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
process.stdout.write(`TURBOPACK_OUTPUT_D\n`);
|
||||
if (err != null) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return {
|
||||
async recv () {
|
||||
const packet = packetQueue.shift();
|
||||
if (packet != null) {
|
||||
return JSON.parse(packet.toString("utf8"));
|
||||
}
|
||||
const result = await new Promise((resolve)=>{
|
||||
recvPromiseResolveQueue.push((result)=>{
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
return result;
|
||||
},
|
||||
send (message) {
|
||||
return send(message);
|
||||
},
|
||||
sendReady,
|
||||
async sendError (error) {
|
||||
try {
|
||||
await send({
|
||||
type: "error",
|
||||
...structuredError(error)
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("failed to send error back to rust:", err);
|
||||
// ignore and exit anyway
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
const PORT = process.argv[2];
|
||||
const IPC = createIpc(parseInt(PORT, 10));
|
||||
process.on("uncaughtException", (err)=>{
|
||||
IPC.sendError(err);
|
||||
});
|
||||
const improveConsole = (name, stream, addStack)=>{
|
||||
// @ts-ignore
|
||||
const original = console[name];
|
||||
// @ts-ignore
|
||||
const stdio = process[stream];
|
||||
// @ts-ignore
|
||||
console[name] = (...args)=>{
|
||||
stdio.write(`TURBOPACK_OUTPUT_B\n`);
|
||||
original(...args);
|
||||
if (addStack) {
|
||||
const stack = new Error().stack?.replace(/^.+\n.+\n/, "") + "\n";
|
||||
stdio.write("TURBOPACK_OUTPUT_S\n");
|
||||
stdio.write(stack);
|
||||
}
|
||||
stdio.write("TURBOPACK_OUTPUT_E\n");
|
||||
};
|
||||
};
|
||||
improveConsole("error", "stderr", true);
|
||||
improveConsole("warn", "stderr", true);
|
||||
improveConsole("count", "stdout", true);
|
||||
improveConsole("trace", "stderr", false);
|
||||
improveConsole("log", "stdout", true);
|
||||
improveConsole("group", "stdout", true);
|
||||
improveConsole("groupCollapsed", "stdout", true);
|
||||
improveConsole("table", "stdout", true);
|
||||
improveConsole("debug", "stdout", true);
|
||||
improveConsole("info", "stdout", true);
|
||||
improveConsole("dir", "stdout", true);
|
||||
improveConsole("dirxml", "stdout", true);
|
||||
improveConsole("timeEnd", "stdout", true);
|
||||
improveConsole("timeLog", "stdout", true);
|
||||
improveConsole("timeStamp", "stdout", true);
|
||||
improveConsole("assert", "stderr", true);
|
||||
/**
|
||||
* Utility function to ensure all variants of an enum are handled.
|
||||
*/ function invariant(never, computeMessage) {
|
||||
throw new Error(`Invariant: ${computeMessage(never)}`);
|
||||
}
|
||||
}}),
|
||||
"[turbopack-node]/ipc/evaluate.ts [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"run": (()=>run)
|
||||
});
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$index$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/ipc/index.ts [postcss] (ecmascript)");
|
||||
;
|
||||
const ipc = __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$index$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["IPC"];
|
||||
const queue = [];
|
||||
const run = async (moduleFactory)=>{
|
||||
let nextId = 1;
|
||||
const requests = new Map();
|
||||
const internalIpc = {
|
||||
sendInfo: (message)=>ipc.send({
|
||||
type: "info",
|
||||
data: message
|
||||
}),
|
||||
sendRequest: (message)=>{
|
||||
const id = nextId++;
|
||||
let resolve, reject;
|
||||
const promise = new Promise((res, rej)=>{
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
requests.set(id, {
|
||||
resolve,
|
||||
reject
|
||||
});
|
||||
return ipc.send({
|
||||
type: "request",
|
||||
id,
|
||||
data: message
|
||||
}).then(()=>promise);
|
||||
},
|
||||
sendError: (error)=>{
|
||||
return ipc.sendError(error);
|
||||
}
|
||||
};
|
||||
// Initialize module and send ready message
|
||||
let getValue;
|
||||
try {
|
||||
const module = await moduleFactory();
|
||||
if (typeof module.init === "function") {
|
||||
await module.init();
|
||||
}
|
||||
getValue = module.default;
|
||||
await ipc.sendReady();
|
||||
} catch (err) {
|
||||
await ipc.sendReady();
|
||||
await ipc.sendError(err);
|
||||
}
|
||||
// Queue handling
|
||||
let isRunning = false;
|
||||
const run = async ()=>{
|
||||
while(queue.length > 0){
|
||||
const args = queue.shift();
|
||||
try {
|
||||
const value = await getValue(internalIpc, ...args);
|
||||
await ipc.send({
|
||||
type: "end",
|
||||
data: value === undefined ? undefined : JSON.stringify(value, null, 2),
|
||||
duration: 0
|
||||
});
|
||||
} catch (e) {
|
||||
await ipc.sendError(e);
|
||||
}
|
||||
}
|
||||
isRunning = false;
|
||||
};
|
||||
// Communication handling
|
||||
while(true){
|
||||
const msg = await ipc.recv();
|
||||
switch(msg.type){
|
||||
case "evaluate":
|
||||
{
|
||||
queue.push(msg.args);
|
||||
if (!isRunning) {
|
||||
isRunning = true;
|
||||
run();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "result":
|
||||
{
|
||||
const request = requests.get(msg.id);
|
||||
if (request) {
|
||||
requests.delete(msg.id);
|
||||
if (msg.error) {
|
||||
request.reject(new Error(msg.error));
|
||||
} else {
|
||||
request.resolve(msg.data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
console.error("unexpected message type", msg.type);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}}),
|
||||
"[turbopack-node]/ipc/evaluate.ts/evaluate.js { INNER => \"[project]/packages/common/components/postcss.config.js/transform.ts { CONFIG => \\\"[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)\\\" } [postcss] (ecmascript)\", RUNTIME => \"[turbopack-node]/ipc/evaluate.ts [postcss] (ecmascript)\" } [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({});
|
||||
var __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$evaluate$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[turbopack-node]/ipc/evaluate.ts [postcss] (ecmascript)");
|
||||
;
|
||||
(0, __TURBOPACK__imported__module__$5b$turbopack$2d$node$5d2f$ipc$2f$evaluate$2e$ts__$5b$postcss$5d$__$28$ecmascript$29$__["run"])(()=>__turbopack_require__('[project]/packages/common/components/postcss.config.js/transform.ts { CONFIG => "[project]/packages/common/components/postcss.config.js_.loader.mjs [postcss] (ecmascript)" } [postcss] (ecmascript, async loader)')(__turbopack_import__));
|
||||
}}),
|
||||
"[turbopack-node]/globals.ts [postcss] (ecmascript)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
// @ts-ignore
|
||||
process.turbopack = {};
|
||||
}}),
|
||||
|
||||
};
|
||||
|
||||
//# sourceMappingURL=%5Broot%20of%20the%20server%5D__7ebbda._.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,165 @@
|
||||
module.exports = {
|
||||
|
||||
"[externals]/path [external] (path, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("path", () => require("path"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[externals]/url [external] (url, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("url", () => require("url"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[externals]/fs [external] (fs, cjs)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const mod = __turbopack_external_require__("fs", () => require("fs"));
|
||||
|
||||
module.exports = mod;
|
||||
}}),
|
||||
"[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)": (function(__turbopack_context__) {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, m: module, e: exports, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
const e = new Error("Could not parse module '[project]/apps/wr/postcss.config.mjs'");
|
||||
e.code = 'MODULE_UNPARSEABLE';
|
||||
throw e;}}),
|
||||
"[project]/apps/wr/postcss.config.mjs/transform.ts { CONFIG => \"[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)\" } [postcss] (ecmascript)": ((__turbopack_context__) => {
|
||||
"use strict";
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, z: __turbopack_require_stub__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_esm__({
|
||||
"default": (()=>transform),
|
||||
"init": (()=>init)
|
||||
});
|
||||
// @ts-ignore
|
||||
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$postcss$40$8$2e$5$2e$3$2f$node_modules$2f$postcss$2f$lib$2f$postcss$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[project]/node_modules/.pnpm/postcss@8.5.3/node_modules/postcss/lib/postcss.mjs [postcss] (ecmascript)");
|
||||
// @ts-ignore
|
||||
var __TURBOPACK__imported__module__$5b$project$5d2f$apps$2f$wr$2f$postcss$2e$config$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__ = __turbopack_import__("[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)");
|
||||
var __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__ = __turbopack_import__("[externals]/path [external] (path, cjs)");
|
||||
;
|
||||
;
|
||||
;
|
||||
const contextDir = process.cwd();
|
||||
function toPath(file) {
|
||||
const relPath = (0, __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["relative"])(contextDir, file);
|
||||
if ((0, __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["isAbsolute"])(relPath)) {
|
||||
throw new Error(`Cannot depend on path (${file}) outside of root directory (${contextDir})`);
|
||||
}
|
||||
return __TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["sep"] !== "/" ? relPath.replaceAll(__TURBOPACK__imported__module__$5b$externals$5d2f$path__$5b$external$5d$__$28$path$2c$__cjs$29$__["sep"], "/") : relPath;
|
||||
}
|
||||
let processor;
|
||||
const init = async (ipc)=>{
|
||||
let config = __TURBOPACK__imported__module__$5b$project$5d2f$apps$2f$wr$2f$postcss$2e$config$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__["default"];
|
||||
if (typeof config === "function") {
|
||||
config = await config({
|
||||
env: "development"
|
||||
});
|
||||
}
|
||||
if (typeof config === "undefined") {
|
||||
throw new Error("PostCSS config is undefined (make sure to export an function or object from config file)");
|
||||
}
|
||||
let plugins;
|
||||
if (Array.isArray(config.plugins)) {
|
||||
plugins = config.plugins.map((plugin)=>{
|
||||
if (Array.isArray(plugin)) {
|
||||
return plugin;
|
||||
} else if (typeof plugin === "string") {
|
||||
return [
|
||||
plugin,
|
||||
{}
|
||||
];
|
||||
} else {
|
||||
return plugin;
|
||||
}
|
||||
});
|
||||
} else if (typeof config.plugins === "object") {
|
||||
plugins = Object.entries(config.plugins).filter(([, options])=>options);
|
||||
} else {
|
||||
plugins = [];
|
||||
}
|
||||
const loadedPlugins = plugins.map((plugin)=>{
|
||||
if (Array.isArray(plugin)) {
|
||||
const [arg, options] = plugin;
|
||||
let pluginFactory = arg;
|
||||
if (typeof pluginFactory === "string") {
|
||||
pluginFactory = require(/* turbopackIgnore: true */ pluginFactory);
|
||||
}
|
||||
if (pluginFactory.default) {
|
||||
pluginFactory = pluginFactory.default;
|
||||
}
|
||||
return pluginFactory(options);
|
||||
}
|
||||
return plugin;
|
||||
});
|
||||
processor = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$postcss$40$8$2e$5$2e$3$2f$node_modules$2f$postcss$2f$lib$2f$postcss$2e$mjs__$5b$postcss$5d$__$28$ecmascript$29$__["default"])(loadedPlugins);
|
||||
};
|
||||
async function transform(ipc, cssContent, name) {
|
||||
const { css, map, messages } = await processor.process(cssContent, {
|
||||
from: name,
|
||||
to: name,
|
||||
map: {
|
||||
inline: false,
|
||||
annotation: false
|
||||
}
|
||||
});
|
||||
const assets = [];
|
||||
for (const msg of messages){
|
||||
switch(msg.type){
|
||||
case "asset":
|
||||
assets.push({
|
||||
file: msg.file,
|
||||
content: msg.content,
|
||||
sourceMap: typeof msg.sourceMap === "string" ? msg.sourceMap : JSON.stringify(msg.sourceMap)
|
||||
});
|
||||
break;
|
||||
case "dependency":
|
||||
case "missing-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "fileDependency",
|
||||
path: toPath(msg.file)
|
||||
});
|
||||
break;
|
||||
case "build-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "buildDependency",
|
||||
path: toPath(msg.file)
|
||||
});
|
||||
break;
|
||||
case "dir-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "dirDependency",
|
||||
path: toPath(msg.dir),
|
||||
glob: msg.glob
|
||||
});
|
||||
break;
|
||||
case "context-dependency":
|
||||
ipc.sendInfo({
|
||||
type: "dirDependency",
|
||||
path: toPath(msg.file),
|
||||
glob: "**"
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
css,
|
||||
map: JSON.stringify(map),
|
||||
assets
|
||||
};
|
||||
}
|
||||
}}),
|
||||
|
||||
};
|
||||
|
||||
//# sourceMappingURL=%5Broot%20of%20the%20server%5D__81da40._.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,674 @@
|
||||
const RUNTIME_PUBLIC_PATH = "build/chunks/[turbopack]_runtime.js";
|
||||
const OUTPUT_ROOT = ".next";
|
||||
const ASSET_PREFIX = "/";
|
||||
/**
|
||||
* This file contains runtime types and functions that are shared between all
|
||||
* TurboPack ECMAScript runtimes.
|
||||
*
|
||||
* It will be prepended to the runtime code of each runtime.
|
||||
*/ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-types.d.ts" />
|
||||
const REEXPORTED_OBJECTS = Symbol("reexported objects");
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag;
|
||||
function defineProp(obj, name, options) {
|
||||
if (!hasOwnProperty.call(obj, name)) Object.defineProperty(obj, name, options);
|
||||
}
|
||||
/**
|
||||
* Adds the getters to the exports object.
|
||||
*/ function esm(exports, getters) {
|
||||
defineProp(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
if (toStringTag) defineProp(exports, toStringTag, {
|
||||
value: "Module"
|
||||
});
|
||||
for(const key in getters){
|
||||
const item = getters[key];
|
||||
if (Array.isArray(item)) {
|
||||
defineProp(exports, key, {
|
||||
get: item[0],
|
||||
set: item[1],
|
||||
enumerable: true
|
||||
});
|
||||
} else {
|
||||
defineProp(exports, key, {
|
||||
get: item,
|
||||
enumerable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
Object.seal(exports);
|
||||
}
|
||||
/**
|
||||
* Makes the module an ESM with exports
|
||||
*/ function esmExport(module, exports, getters) {
|
||||
module.namespaceObject = module.exports;
|
||||
esm(exports, getters);
|
||||
}
|
||||
function ensureDynamicExports(module, exports) {
|
||||
let reexportedObjects = module[REEXPORTED_OBJECTS];
|
||||
if (!reexportedObjects) {
|
||||
reexportedObjects = module[REEXPORTED_OBJECTS] = [];
|
||||
module.exports = module.namespaceObject = new Proxy(exports, {
|
||||
get (target, prop) {
|
||||
if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") {
|
||||
return Reflect.get(target, prop);
|
||||
}
|
||||
for (const obj of reexportedObjects){
|
||||
const value = Reflect.get(obj, prop);
|
||||
if (value !== undefined) return value;
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
ownKeys (target) {
|
||||
const keys = Reflect.ownKeys(target);
|
||||
for (const obj of reexportedObjects){
|
||||
for (const key of Reflect.ownKeys(obj)){
|
||||
if (key !== "default" && !keys.includes(key)) keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Dynamically exports properties from an object
|
||||
*/ function dynamicExport(module, exports, object) {
|
||||
ensureDynamicExports(module, exports);
|
||||
if (typeof object === "object" && object !== null) {
|
||||
module[REEXPORTED_OBJECTS].push(object);
|
||||
}
|
||||
}
|
||||
function exportValue(module, value) {
|
||||
module.exports = value;
|
||||
}
|
||||
function exportNamespace(module, namespace) {
|
||||
module.exports = module.namespaceObject = namespace;
|
||||
}
|
||||
function createGetter(obj, key) {
|
||||
return ()=>obj[key];
|
||||
}
|
||||
/**
|
||||
* @returns prototype of the object
|
||||
*/ const getProto = Object.getPrototypeOf ? (obj)=>Object.getPrototypeOf(obj) : (obj)=>obj.__proto__;
|
||||
/** Prototypes that are not expanded for exports */ const LEAF_PROTOTYPES = [
|
||||
null,
|
||||
getProto({}),
|
||||
getProto([]),
|
||||
getProto(getProto)
|
||||
];
|
||||
/**
|
||||
* @param raw
|
||||
* @param ns
|
||||
* @param allowExportDefault
|
||||
* * `false`: will have the raw module as default export
|
||||
* * `true`: will have the default property as default export
|
||||
*/ function interopEsm(raw, ns, allowExportDefault) {
|
||||
const getters = Object.create(null);
|
||||
for(let current = raw; (typeof current === "object" || typeof current === "function") && !LEAF_PROTOTYPES.includes(current); current = getProto(current)){
|
||||
for (const key of Object.getOwnPropertyNames(current)){
|
||||
getters[key] = createGetter(raw, key);
|
||||
}
|
||||
}
|
||||
// this is not really correct
|
||||
// we should set the `default` getter if the imported module is a `.cjs file`
|
||||
if (!(allowExportDefault && "default" in getters)) {
|
||||
getters["default"] = ()=>raw;
|
||||
}
|
||||
esm(ns, getters);
|
||||
return ns;
|
||||
}
|
||||
function createNS(raw) {
|
||||
if (typeof raw === "function") {
|
||||
return function(...args) {
|
||||
return raw.apply(this, args);
|
||||
};
|
||||
} else {
|
||||
return Object.create(null);
|
||||
}
|
||||
}
|
||||
function esmImport(sourceModule, id) {
|
||||
const module = getOrInstantiateModuleFromParent(id, sourceModule);
|
||||
if (module.error) throw module.error;
|
||||
// any ES module has to have `module.namespaceObject` defined.
|
||||
if (module.namespaceObject) return module.namespaceObject;
|
||||
// only ESM can be an async module, so we don't need to worry about exports being a promise here.
|
||||
const raw = module.exports;
|
||||
return module.namespaceObject = interopEsm(raw, createNS(raw), raw && raw.__esModule);
|
||||
}
|
||||
// Add a simple runtime require so that environments without one can still pass
|
||||
// `typeof require` CommonJS checks so that exports are correctly registered.
|
||||
const runtimeRequire = // @ts-ignore
|
||||
typeof require === "function" ? require : function require1() {
|
||||
throw new Error("Unexpected use of runtime require");
|
||||
};
|
||||
function commonJsRequire(sourceModule, id) {
|
||||
const module = getOrInstantiateModuleFromParent(id, sourceModule);
|
||||
if (module.error) throw module.error;
|
||||
return module.exports;
|
||||
}
|
||||
/**
|
||||
* `require.context` and require/import expression runtime.
|
||||
*/ function moduleContext(map) {
|
||||
function moduleContext(id) {
|
||||
if (hasOwnProperty.call(map, id)) {
|
||||
return map[id].module();
|
||||
}
|
||||
const e = new Error(`Cannot find module '${id}'`);
|
||||
e.code = "MODULE_NOT_FOUND";
|
||||
throw e;
|
||||
}
|
||||
moduleContext.keys = ()=>{
|
||||
return Object.keys(map);
|
||||
};
|
||||
moduleContext.resolve = (id)=>{
|
||||
if (hasOwnProperty.call(map, id)) {
|
||||
return map[id].id();
|
||||
}
|
||||
const e = new Error(`Cannot find module '${id}'`);
|
||||
e.code = "MODULE_NOT_FOUND";
|
||||
throw e;
|
||||
};
|
||||
moduleContext.import = async (id)=>{
|
||||
return await moduleContext(id);
|
||||
};
|
||||
return moduleContext;
|
||||
}
|
||||
/**
|
||||
* Returns the path of a chunk defined by its data.
|
||||
*/ function getChunkPath(chunkData) {
|
||||
return typeof chunkData === "string" ? chunkData : chunkData.path;
|
||||
}
|
||||
function isPromise(maybePromise) {
|
||||
return maybePromise != null && typeof maybePromise === "object" && "then" in maybePromise && typeof maybePromise.then === "function";
|
||||
}
|
||||
function isAsyncModuleExt(obj) {
|
||||
return turbopackQueues in obj;
|
||||
}
|
||||
function createPromise() {
|
||||
let resolve;
|
||||
let reject;
|
||||
const promise = new Promise((res, rej)=>{
|
||||
reject = rej;
|
||||
resolve = res;
|
||||
});
|
||||
return {
|
||||
promise,
|
||||
resolve: resolve,
|
||||
reject: reject
|
||||
};
|
||||
}
|
||||
// everything below is adapted from webpack
|
||||
// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13
|
||||
const turbopackQueues = Symbol("turbopack queues");
|
||||
const turbopackExports = Symbol("turbopack exports");
|
||||
const turbopackError = Symbol("turbopack error");
|
||||
;
|
||||
function resolveQueue(queue) {
|
||||
if (queue && queue.status !== 1) {
|
||||
queue.status = 1;
|
||||
queue.forEach((fn)=>fn.queueCount--);
|
||||
queue.forEach((fn)=>fn.queueCount-- ? fn.queueCount++ : fn());
|
||||
}
|
||||
}
|
||||
function wrapDeps(deps) {
|
||||
return deps.map((dep)=>{
|
||||
if (dep !== null && typeof dep === "object") {
|
||||
if (isAsyncModuleExt(dep)) return dep;
|
||||
if (isPromise(dep)) {
|
||||
const queue = Object.assign([], {
|
||||
status: 0
|
||||
});
|
||||
const obj = {
|
||||
[turbopackExports]: {},
|
||||
[turbopackQueues]: (fn)=>fn(queue)
|
||||
};
|
||||
dep.then((res)=>{
|
||||
obj[turbopackExports] = res;
|
||||
resolveQueue(queue);
|
||||
}, (err)=>{
|
||||
obj[turbopackError] = err;
|
||||
resolveQueue(queue);
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
return {
|
||||
[turbopackExports]: dep,
|
||||
[turbopackQueues]: ()=>{}
|
||||
};
|
||||
});
|
||||
}
|
||||
function asyncModule(module, body, hasAwait) {
|
||||
const queue = hasAwait ? Object.assign([], {
|
||||
status: -1
|
||||
}) : undefined;
|
||||
const depQueues = new Set();
|
||||
const { resolve, reject, promise: rawPromise } = createPromise();
|
||||
const promise = Object.assign(rawPromise, {
|
||||
[turbopackExports]: module.exports,
|
||||
[turbopackQueues]: (fn)=>{
|
||||
queue && fn(queue);
|
||||
depQueues.forEach(fn);
|
||||
promise["catch"](()=>{});
|
||||
}
|
||||
});
|
||||
const attributes = {
|
||||
get () {
|
||||
return promise;
|
||||
},
|
||||
set (v) {
|
||||
// Calling `esmExport` leads to this.
|
||||
if (v !== promise) {
|
||||
promise[turbopackExports] = v;
|
||||
}
|
||||
}
|
||||
};
|
||||
Object.defineProperty(module, "exports", attributes);
|
||||
Object.defineProperty(module, "namespaceObject", attributes);
|
||||
function handleAsyncDependencies(deps) {
|
||||
const currentDeps = wrapDeps(deps);
|
||||
const getResult = ()=>currentDeps.map((d)=>{
|
||||
if (d[turbopackError]) throw d[turbopackError];
|
||||
return d[turbopackExports];
|
||||
});
|
||||
const { promise, resolve } = createPromise();
|
||||
const fn = Object.assign(()=>resolve(getResult), {
|
||||
queueCount: 0
|
||||
});
|
||||
function fnQueue(q) {
|
||||
if (q !== queue && !depQueues.has(q)) {
|
||||
depQueues.add(q);
|
||||
if (q && q.status === 0) {
|
||||
fn.queueCount++;
|
||||
q.push(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
currentDeps.map((dep)=>dep[turbopackQueues](fnQueue));
|
||||
return fn.queueCount ? promise : getResult();
|
||||
}
|
||||
function asyncResult(err) {
|
||||
if (err) {
|
||||
reject(promise[turbopackError] = err);
|
||||
} else {
|
||||
resolve(promise[turbopackExports]);
|
||||
}
|
||||
resolveQueue(queue);
|
||||
}
|
||||
body(handleAsyncDependencies, asyncResult);
|
||||
if (queue && queue.status === -1) {
|
||||
queue.status = 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A pseudo "fake" URL object to resolve to its relative path.
|
||||
*
|
||||
* When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this
|
||||
* runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid
|
||||
* hydration mismatch.
|
||||
*
|
||||
* This is based on webpack's existing implementation:
|
||||
* https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js
|
||||
*/ const relativeURL = function relativeURL(inputUrl) {
|
||||
const realUrl = new URL(inputUrl, "x:/");
|
||||
const values = {};
|
||||
for(const key in realUrl)values[key] = realUrl[key];
|
||||
values.href = inputUrl;
|
||||
values.pathname = inputUrl.replace(/[?#].*/, "");
|
||||
values.origin = values.protocol = "";
|
||||
values.toString = values.toJSON = (..._args)=>inputUrl;
|
||||
for(const key in values)Object.defineProperty(this, key, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: values[key]
|
||||
});
|
||||
};
|
||||
relativeURL.prototype = URL.prototype;
|
||||
/**
|
||||
* Utility function to ensure all variants of an enum are handled.
|
||||
*/ function invariant(never, computeMessage) {
|
||||
throw new Error(`Invariant: ${computeMessage(never)}`);
|
||||
}
|
||||
/**
|
||||
* A stub function to make `require` available but non-functional in ESM.
|
||||
*/ function requireStub(_moduleId) {
|
||||
throw new Error("dynamic usage of require is not supported");
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime-utils.ts" />
|
||||
/// A 'base' utilities to support runtime can have externals.
|
||||
/// Currently this is for node.js / edge runtime both.
|
||||
/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.
|
||||
async function externalImport(id) {
|
||||
let raw;
|
||||
try {
|
||||
raw = await import(id);
|
||||
} catch (err) {
|
||||
// TODO(alexkirsz) This can happen when a client-side module tries to load
|
||||
// an external module we don't provide a shim for (e.g. querystring, url).
|
||||
// For now, we fail semi-silently, but in the future this should be a
|
||||
// compilation error.
|
||||
throw new Error(`Failed to load external module ${id}: ${err}`);
|
||||
}
|
||||
if (raw && raw.__esModule && raw.default && 'default' in raw.default) {
|
||||
return interopEsm(raw.default, createNS(raw), true);
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
function externalRequire(id, thunk, esm = false) {
|
||||
let raw;
|
||||
try {
|
||||
raw = thunk();
|
||||
} catch (err) {
|
||||
// TODO(alexkirsz) This can happen when a client-side module tries to load
|
||||
// an external module we don't provide a shim for (e.g. querystring, url).
|
||||
// For now, we fail semi-silently, but in the future this should be a
|
||||
// compilation error.
|
||||
throw new Error(`Failed to load external module ${id}: ${err}`);
|
||||
}
|
||||
if (!esm || raw.__esModule) {
|
||||
return raw;
|
||||
}
|
||||
return interopEsm(raw, createNS(raw), true);
|
||||
}
|
||||
externalRequire.resolve = (id, options)=>{
|
||||
return require.resolve(id, options);
|
||||
};
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */ const path = require("path");
|
||||
const relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, ".");
|
||||
// Compute the relative path to the `distDir`.
|
||||
const relativePathToDistRoot = path.relative(path.join(OUTPUT_ROOT, RUNTIME_PUBLIC_PATH), ".");
|
||||
const RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);
|
||||
// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.
|
||||
const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);
|
||||
/**
|
||||
* Returns an absolute path to the given module path.
|
||||
* Module path should be relative, either path to a file or a directory.
|
||||
*
|
||||
* This fn allows to calculate an absolute path for some global static values, such as
|
||||
* `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.
|
||||
* See ImportMetaBinding::code_generation for the usage.
|
||||
*/ function resolveAbsolutePath(modulePath) {
|
||||
if (modulePath) {
|
||||
return path.join(ABSOLUTE_ROOT, modulePath);
|
||||
}
|
||||
return ABSOLUTE_ROOT;
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime-utils.ts" />
|
||||
function readWebAssemblyAsResponse(path) {
|
||||
const { createReadStream } = require("fs");
|
||||
const { Readable } = require("stream");
|
||||
const stream = createReadStream(path);
|
||||
// @ts-ignore unfortunately there's a slight type mismatch with the stream.
|
||||
return new Response(Readable.toWeb(stream), {
|
||||
headers: {
|
||||
"content-type": "application/wasm"
|
||||
}
|
||||
});
|
||||
}
|
||||
async function compileWebAssemblyFromPath(path) {
|
||||
const response = readWebAssemblyAsResponse(path);
|
||||
return await WebAssembly.compileStreaming(response);
|
||||
}
|
||||
async function instantiateWebAssemblyFromPath(path, importsObj) {
|
||||
const response = readWebAssemblyAsResponse(path);
|
||||
const { instance } = await WebAssembly.instantiateStreaming(response, importsObj);
|
||||
return instance.exports;
|
||||
}
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime-utils.ts" />
|
||||
/// <reference path="../shared-node/base-externals-utils.ts" />
|
||||
/// <reference path="../shared-node/node-externals-utils.ts" />
|
||||
/// <reference path="../shared-node/node-wasm-utils.ts" />
|
||||
var SourceType = /*#__PURE__*/ function(SourceType) {
|
||||
/**
|
||||
* The module was instantiated because it was included in an evaluated chunk's
|
||||
* runtime.
|
||||
*/ SourceType[SourceType["Runtime"] = 0] = "Runtime";
|
||||
/**
|
||||
* The module was instantiated because a parent module imported it.
|
||||
*/ SourceType[SourceType["Parent"] = 1] = "Parent";
|
||||
return SourceType;
|
||||
}(SourceType || {});
|
||||
function stringifySourceInfo(source) {
|
||||
switch(source.type){
|
||||
case 0:
|
||||
return `runtime for chunk ${source.chunkPath}`;
|
||||
case 1:
|
||||
return `parent module ${source.parentId}`;
|
||||
default:
|
||||
invariant(source, (source)=>`Unknown source type: ${source?.type}`);
|
||||
}
|
||||
}
|
||||
const url = require("url");
|
||||
const fs = require("fs/promises");
|
||||
const moduleFactories = Object.create(null);
|
||||
const moduleCache = Object.create(null);
|
||||
/**
|
||||
* Returns an absolute path to the given module's id.
|
||||
*/ function createResolvePathFromModule(resolver) {
|
||||
return function resolvePathFromModule(moduleId) {
|
||||
const exported = resolver(moduleId);
|
||||
const exportedPath = exported?.default ?? exported;
|
||||
if (typeof exportedPath !== "string") {
|
||||
return exported;
|
||||
}
|
||||
const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length);
|
||||
const resolved = path.resolve(ABSOLUTE_ROOT, OUTPUT_ROOT, strippedAssetPrefix);
|
||||
return url.pathToFileURL(resolved);
|
||||
};
|
||||
}
|
||||
function loadChunk(chunkData, source) {
|
||||
if (typeof chunkData === "string") {
|
||||
return loadChunkPath(chunkData, source);
|
||||
} else {
|
||||
return loadChunkPath(chunkData.path, source);
|
||||
}
|
||||
}
|
||||
function loadChunkPath(chunkPath, source) {
|
||||
if (!chunkPath.endsWith(".js")) {
|
||||
// We only support loading JS chunks in Node.js.
|
||||
// This branch can be hit when trying to load a CSS chunk.
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
|
||||
const chunkModules = require(resolved);
|
||||
for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){
|
||||
if (!moduleFactories[moduleId]) {
|
||||
moduleFactories[moduleId] = moduleFactory;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
let errorMessage = `Failed to load chunk ${chunkPath}`;
|
||||
if (source) {
|
||||
errorMessage += ` from ${stringifySourceInfo(source)}`;
|
||||
}
|
||||
throw new Error(errorMessage, {
|
||||
cause: e
|
||||
});
|
||||
}
|
||||
}
|
||||
async function loadChunkAsync(source, chunkData) {
|
||||
const chunkPath = typeof chunkData === "string" ? chunkData : chunkData.path;
|
||||
if (!chunkPath.endsWith(".js")) {
|
||||
// We only support loading JS chunks in Node.js.
|
||||
// This branch can be hit when trying to load a CSS chunk.
|
||||
return;
|
||||
}
|
||||
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
|
||||
try {
|
||||
const contents = await fs.readFile(resolved, "utf-8");
|
||||
const localRequire = (id)=>{
|
||||
let resolvedId = require.resolve(id, {
|
||||
paths: [
|
||||
path.dirname(resolved)
|
||||
]
|
||||
});
|
||||
return require(resolvedId);
|
||||
};
|
||||
const module1 = {
|
||||
exports: {}
|
||||
};
|
||||
// TODO: Use vm.runInThisContext once our minimal supported Node.js version includes https://github.com/nodejs/node/pull/52153
|
||||
// eslint-disable-next-line no-eval -- Can't use vm.runInThisContext due to https://github.com/nodejs/node/issues/52102
|
||||
(0, eval)("(function(module, exports, require, __dirname, __filename) {" + contents + "\n})" + "\n//# sourceURL=" + url.pathToFileURL(resolved))(module1, module1.exports, localRequire, path.dirname(resolved), resolved);
|
||||
const chunkModules = module1.exports;
|
||||
for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){
|
||||
if (!moduleFactories[moduleId]) {
|
||||
moduleFactories[moduleId] = moduleFactory;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
let errorMessage = `Failed to load chunk ${chunkPath}`;
|
||||
if (source) {
|
||||
errorMessage += ` from ${stringifySourceInfo(source)}`;
|
||||
}
|
||||
throw new Error(errorMessage, {
|
||||
cause: e
|
||||
});
|
||||
}
|
||||
}
|
||||
function loadWebAssembly(chunkPath, imports) {
|
||||
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
|
||||
return instantiateWebAssemblyFromPath(resolved, imports);
|
||||
}
|
||||
function loadWebAssemblyModule(chunkPath) {
|
||||
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
|
||||
return compileWebAssemblyFromPath(resolved);
|
||||
}
|
||||
function getWorkerBlobURL(_chunks) {
|
||||
throw new Error("Worker blobs are not implemented yet for Node.js");
|
||||
}
|
||||
function instantiateModule(id, source) {
|
||||
const moduleFactory = moduleFactories[id];
|
||||
if (typeof moduleFactory !== "function") {
|
||||
// This can happen if modules incorrectly handle HMR disposes/updates,
|
||||
// e.g. when they keep a `setTimeout` around which still executes old code
|
||||
// and contains e.g. a `require("something")` call.
|
||||
let instantiationReason;
|
||||
switch(source.type){
|
||||
case 0:
|
||||
instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`;
|
||||
break;
|
||||
case 1:
|
||||
instantiationReason = `because it was required from module ${source.parentId}`;
|
||||
break;
|
||||
default:
|
||||
invariant(source, (source)=>`Unknown source type: ${source?.type}`);
|
||||
}
|
||||
throw new Error(`Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`);
|
||||
}
|
||||
let parents;
|
||||
switch(source.type){
|
||||
case 0:
|
||||
parents = [];
|
||||
break;
|
||||
case 1:
|
||||
// No need to add this module as a child of the parent module here, this
|
||||
// has already been taken care of in `getOrInstantiateModuleFromParent`.
|
||||
parents = [
|
||||
source.parentId
|
||||
];
|
||||
break;
|
||||
default:
|
||||
invariant(source, (source)=>`Unknown source type: ${source?.type}`);
|
||||
}
|
||||
const module1 = {
|
||||
exports: {},
|
||||
error: undefined,
|
||||
loaded: false,
|
||||
id,
|
||||
parents,
|
||||
children: [],
|
||||
namespaceObject: undefined
|
||||
};
|
||||
moduleCache[id] = module1;
|
||||
// NOTE(alexkirsz) This can fail when the module encounters a runtime error.
|
||||
try {
|
||||
const r = commonJsRequire.bind(null, module1);
|
||||
moduleFactory.call(module1.exports, {
|
||||
a: asyncModule.bind(null, module1),
|
||||
e: module1.exports,
|
||||
r,
|
||||
t: runtimeRequire,
|
||||
x: externalRequire,
|
||||
y: externalImport,
|
||||
f: moduleContext,
|
||||
i: esmImport.bind(null, module1),
|
||||
s: esmExport.bind(null, module1, module1.exports),
|
||||
j: dynamicExport.bind(null, module1, module1.exports),
|
||||
v: exportValue.bind(null, module1),
|
||||
n: exportNamespace.bind(null, module1),
|
||||
m: module1,
|
||||
c: moduleCache,
|
||||
M: moduleFactories,
|
||||
l: loadChunkAsync.bind(null, {
|
||||
type: 1,
|
||||
parentId: id
|
||||
}),
|
||||
w: loadWebAssembly,
|
||||
u: loadWebAssemblyModule,
|
||||
g: globalThis,
|
||||
P: resolveAbsolutePath,
|
||||
U: relativeURL,
|
||||
R: createResolvePathFromModule(r),
|
||||
b: getWorkerBlobURL,
|
||||
z: requireStub,
|
||||
__dirname: typeof module1.id === "string" ? module1.id.replace(/(^|\/)\/+$/, "") : module1.id
|
||||
});
|
||||
} catch (error) {
|
||||
module1.error = error;
|
||||
throw error;
|
||||
}
|
||||
module1.loaded = true;
|
||||
if (module1.namespaceObject && module1.exports !== module1.namespaceObject) {
|
||||
// in case of a circular dependency: cjs1 -> esm2 -> cjs1
|
||||
interopEsm(module1.exports, module1.namespaceObject);
|
||||
}
|
||||
return module1;
|
||||
}
|
||||
/**
|
||||
* Retrieves a module from the cache, or instantiate it if it is not cached.
|
||||
*/ // @ts-ignore
|
||||
function getOrInstantiateModuleFromParent(id, sourceModule) {
|
||||
const module1 = moduleCache[id];
|
||||
if (sourceModule.children.indexOf(id) === -1) {
|
||||
sourceModule.children.push(id);
|
||||
}
|
||||
if (module1) {
|
||||
if (module1.parents.indexOf(sourceModule.id) === -1) {
|
||||
module1.parents.push(sourceModule.id);
|
||||
}
|
||||
return module1;
|
||||
}
|
||||
return instantiateModule(id, {
|
||||
type: 1,
|
||||
parentId: sourceModule.id
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Instantiates a runtime module.
|
||||
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
|
||||
return instantiateModule(moduleId, {
|
||||
type: 0,
|
||||
chunkPath
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.
|
||||
*/ // @ts-ignore TypeScript doesn't separate this module space from the browser runtime
|
||||
function getOrInstantiateRuntimeModule(moduleId, chunkPath) {
|
||||
const module1 = moduleCache[moduleId];
|
||||
if (module1) {
|
||||
if (module1.error) {
|
||||
throw module1.error;
|
||||
}
|
||||
return module1;
|
||||
}
|
||||
return instantiateRuntimeModule(moduleId, chunkPath);
|
||||
}
|
||||
module.exports = {
|
||||
getOrInstantiateRuntimeModule,
|
||||
loadChunk
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
|
||||
"[project]/apps/wr/postcss.config.mjs/transform.ts { CONFIG => \"[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)\" } [postcss] (ecmascript, async loader)": ((__turbopack_context__) => {
|
||||
|
||||
var { r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, b: __turbopack_worker_blob_url__, g: global, __dirname, t: __turbopack_require_real__ } = __turbopack_context__;
|
||||
{
|
||||
__turbopack_export_value__((__turbopack_import__) => {
|
||||
return Promise.all([
|
||||
"build/chunks/08b5e__pnpm_9b08c8._.js",
|
||||
"build/chunks/[root of the server]__81da40._.js"
|
||||
].map((chunk) => __turbopack_load__(chunk))).then(() => {
|
||||
return __turbopack_import__("[project]/apps/wr/postcss.config.mjs/transform.ts { CONFIG => \"[project]/apps/wr/postcss.config.mjs [postcss] (ecmascript)\" } [postcss] (ecmascript)");
|
||||
});
|
||||
});
|
||||
}}),
|
||||
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user