diff --git a/apps/common/features/app/(with-base-layout)/banner/page.tsx b/apps/common/features/app/(with-base-layout)/banner/page.tsx deleted file mode 100644 index 23f63defe..000000000 --- a/apps/common/features/app/(with-base-layout)/banner/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { BannerPage } from "@/pages/banner"; -export default BannerPage; diff --git a/apps/common/features/app/(with-base-layout)/banner/register/[sequential]/page.tsx b/apps/common/features/app/(with-base-layout)/banner/register/[sequential]/page.tsx deleted file mode 100644 index bc19150cb..000000000 --- a/apps/common/features/app/(with-base-layout)/banner/register/[sequential]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/banner"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ sequential: string }>; -}) { - const { sequential } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/banner/register/page.tsx b/apps/common/features/app/(with-base-layout)/banner/register/page.tsx deleted file mode 100644 index 46eb12c1c..000000000 --- a/apps/common/features/app/(with-base-layout)/banner/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/banner"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/bbs/page.tsx b/apps/common/features/app/(with-base-layout)/bbs/page.tsx deleted file mode 100644 index d9aab376a..000000000 --- a/apps/common/features/app/(with-base-layout)/bbs/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { BbsPage } from "@/pages/bbs"; -export default BbsPage; diff --git a/apps/common/features/app/(with-base-layout)/bbs/register/[id]/page.tsx b/apps/common/features/app/(with-base-layout)/bbs/register/[id]/page.tsx deleted file mode 100644 index 07cc78b6f..000000000 --- a/apps/common/features/app/(with-base-layout)/bbs/register/[id]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/bbs"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ id: string }>; -}) { - const { id } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/bbs/register/page.tsx b/apps/common/features/app/(with-base-layout)/bbs/register/page.tsx deleted file mode 100644 index 3e74aef97..000000000 --- a/apps/common/features/app/(with-base-layout)/bbs/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/bbs"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/contents/page.tsx b/apps/common/features/app/(with-base-layout)/contents/page.tsx deleted file mode 100644 index ba2a6a21d..000000000 --- a/apps/common/features/app/(with-base-layout)/contents/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { ContentsPage } from "@/pages/contents"; -export default ContentsPage; diff --git a/apps/common/features/app/(with-base-layout)/contents/register/[sequential]/page.tsx b/apps/common/features/app/(with-base-layout)/contents/register/[sequential]/page.tsx deleted file mode 100644 index aa9320b8f..000000000 --- a/apps/common/features/app/(with-base-layout)/contents/register/[sequential]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/contents"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ sequential: string }>; -}) { - const { sequential } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/contents/register/page.tsx b/apps/common/features/app/(with-base-layout)/contents/register/page.tsx deleted file mode 100644 index fc33228e2..000000000 --- a/apps/common/features/app/(with-base-layout)/contents/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/contents"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/dashboard/page.tsx b/apps/common/features/app/(with-base-layout)/dashboard/page.tsx deleted file mode 100644 index 53d564ac6..000000000 --- a/apps/common/features/app/(with-base-layout)/dashboard/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { DashboardPage } from "@/pages/dashboard"; -export default DashboardPage; diff --git a/apps/common/features/app/(with-base-layout)/file/page.tsx b/apps/common/features/app/(with-base-layout)/file/page.tsx deleted file mode 100644 index 6b03fe11d..000000000 --- a/apps/common/features/app/(with-base-layout)/file/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { FilePage } from "@/pages/file"; -export default FilePage; diff --git a/apps/common/features/app/(with-base-layout)/image/page.tsx b/apps/common/features/app/(with-base-layout)/image/page.tsx deleted file mode 100644 index 89ca9eeb1..000000000 --- a/apps/common/features/app/(with-base-layout)/image/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { ImagePage } from "@/pages/image"; -export default ImagePage; diff --git a/apps/common/features/app/(with-base-layout)/image/register/[sequential]/page.tsx b/apps/common/features/app/(with-base-layout)/image/register/[sequential]/page.tsx deleted file mode 100644 index 800f0b382..000000000 --- a/apps/common/features/app/(with-base-layout)/image/register/[sequential]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/image"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ sequential: string }>; -}) { - const { sequential } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/image/register/page.tsx b/apps/common/features/app/(with-base-layout)/image/register/page.tsx deleted file mode 100644 index 3c29f2bfe..000000000 --- a/apps/common/features/app/(with-base-layout)/image/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/image"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/layout.tsx b/apps/common/features/app/(with-base-layout)/layout.tsx index c3254a935..d6250a6e9 100644 --- a/apps/common/features/app/(with-base-layout)/layout.tsx +++ b/apps/common/features/app/(with-base-layout)/layout.tsx @@ -5,7 +5,6 @@ import { useQueryClient } from "@tanstack/react-query"; import type { MenuItem } from "@common/components/api"; import { BaseLayout } from "@common/components/ui"; import { useMenuStore } from "@/shared/lib"; -import { PageLayout } from "@/shared/ui/page-layout"; export default function WithBaseLayout({ children, @@ -29,7 +28,7 @@ export default function WithBaseLayout({ currentPath={pathname ?? ""} handleMenuClick={handleMenuClick} > - {children} + {children} ); } diff --git a/apps/common/features/app/(with-base-layout)/menu/page.tsx b/apps/common/features/app/(with-base-layout)/menu/page.tsx deleted file mode 100644 index bbac0670c..000000000 --- a/apps/common/features/app/(with-base-layout)/menu/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { MenuPage } from "@/pages/menu"; -export default MenuPage; diff --git a/apps/common/features/app/(with-base-layout)/module/page.tsx b/apps/common/features/app/(with-base-layout)/module/page.tsx deleted file mode 100644 index c395e9a79..000000000 --- a/apps/common/features/app/(with-base-layout)/module/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { ModulePage } from "@/pages/module"; -export default ModulePage; diff --git a/apps/common/features/app/(with-base-layout)/module/register/[sequential]/page.tsx b/apps/common/features/app/(with-base-layout)/module/register/[sequential]/page.tsx deleted file mode 100644 index 9f1c32ff5..000000000 --- a/apps/common/features/app/(with-base-layout)/module/register/[sequential]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/module"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ sequential: string }>; -}) { - const { sequential } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/module/register/page.tsx b/apps/common/features/app/(with-base-layout)/module/register/page.tsx deleted file mode 100644 index 6354dc8ab..000000000 --- a/apps/common/features/app/(with-base-layout)/module/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/module"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/organization/page.tsx b/apps/common/features/app/(with-base-layout)/organization/page.tsx deleted file mode 100644 index 39a15cf83..000000000 --- a/apps/common/features/app/(with-base-layout)/organization/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { OrganizationPage } from "@/pages/organization"; -export default OrganizationPage; diff --git a/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/page.tsx b/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/page.tsx new file mode 100644 index 000000000..df9ae763f --- /dev/null +++ b/apps/common/features/app/(with-base-layout)/pst/bbsnotice/[bbsId]/page.tsx @@ -0,0 +1,10 @@ +import { NoticePage } from "@/pages/notice"; + +export default async function PstBbsNoticePage({ + params, +}: { + params: Promise<{ bbsId: string }>; +}) { + const { bbsId } = await params; + return ; +} diff --git a/apps/common/features/app/(with-base-layout)/site/page.tsx b/apps/common/features/app/(with-base-layout)/site/page.tsx deleted file mode 100644 index 0cf120630..000000000 --- a/apps/common/features/app/(with-base-layout)/site/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { SitePage } from "@/pages/site"; -export default SitePage; diff --git a/apps/common/features/app/(with-base-layout)/site/register/[id]/page.tsx b/apps/common/features/app/(with-base-layout)/site/register/[id]/page.tsx deleted file mode 100644 index 685d77172..000000000 --- a/apps/common/features/app/(with-base-layout)/site/register/[id]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/site"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ id: string }>; -}) { - const { id } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/site/register/page.tsx b/apps/common/features/app/(with-base-layout)/site/register/page.tsx deleted file mode 100644 index 01e25cc43..000000000 --- a/apps/common/features/app/(with-base-layout)/site/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/site"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/template/page.tsx b/apps/common/features/app/(with-base-layout)/template/page.tsx deleted file mode 100644 index f5eab5953..000000000 --- a/apps/common/features/app/(with-base-layout)/template/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { TemplatePage } from "@/pages/template"; -export default TemplatePage; diff --git a/apps/common/features/app/(with-base-layout)/template/register/[sequential]/page.tsx b/apps/common/features/app/(with-base-layout)/template/register/[sequential]/page.tsx deleted file mode 100644 index 3878a4e41..000000000 --- a/apps/common/features/app/(with-base-layout)/template/register/[sequential]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/template"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ sequential: string }>; -}) { - const { sequential } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/template/register/page.tsx b/apps/common/features/app/(with-base-layout)/template/register/page.tsx deleted file mode 100644 index 9be3f975a..000000000 --- a/apps/common/features/app/(with-base-layout)/template/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/template"; -export default CreatePage; diff --git a/apps/common/features/app/(with-base-layout)/terms/page.tsx b/apps/common/features/app/(with-base-layout)/terms/page.tsx deleted file mode 100644 index 47f4c8e02..000000000 --- a/apps/common/features/app/(with-base-layout)/terms/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { TermsPage } from "@/pages/terms"; -export default TermsPage; diff --git a/apps/common/features/app/(with-base-layout)/terms/register/[sequential]/page.tsx b/apps/common/features/app/(with-base-layout)/terms/register/[sequential]/page.tsx deleted file mode 100644 index 8ff8b2010..000000000 --- a/apps/common/features/app/(with-base-layout)/terms/register/[sequential]/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ModifyPage as VModifyPage } from "@/pages/terms"; - -export default async function ModifyPage({ - params, -}: { - params: Promise<{ sequential: string }>; -}) { - const { sequential } = await params; - return ; -} diff --git a/apps/common/features/app/(with-base-layout)/terms/register/page.tsx b/apps/common/features/app/(with-base-layout)/terms/register/page.tsx deleted file mode 100644 index 997fc119a..000000000 --- a/apps/common/features/app/(with-base-layout)/terms/register/page.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { CreatePage } from "@/pages/terms"; -export default CreatePage; diff --git a/apps/common/features/middleware.ts b/apps/common/features/middleware.ts index d56c1f8ab..018aab11a 100644 --- a/apps/common/features/middleware.ts +++ b/apps/common/features/middleware.ts @@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server"; import { CLAIM_NAME, AUTH_USER_ID } from "./src/shared/config"; const serverApiUrl = - process.env.NEXT_PUBLIC_SERVER_API_URL ?? "http://localhost:3000"; + process.env.NEXT_PUBLIC_SERVER_API_URL ?? "http://localhost:13000"; export function middleware(req: NextRequest) { const pathname = req.nextUrl.pathname; diff --git a/apps/common/features/next.config.ts b/apps/common/features/next.config.ts index 7cbf8ee2e..cb651cdc0 100644 --- a/apps/common/features/next.config.ts +++ b/apps/common/features/next.config.ts @@ -1,32 +1,5 @@ import type { NextConfig } from "next"; -const subDomain = - process.env.NEXT_PUBLIC_SUB_DOMAIN || "http://localhost:13000"; - -const nextConfig: NextConfig = { - async rewrites() { - return { - beforeFiles: [ - { - source: "/_next/static/:path*", - destination: `${subDomain}/_next/static/:path*`, - has: [ - { - type: "header", - key: "x-rewrite-me", - }, - ], - }, - ], - afterFiles: [ - { - source: "/board/:path*", - destination: `${subDomain}/board/:path*`, - }, - ], - fallback: [], - }; - }, -}; +const nextConfig: NextConfig = {}; export default nextConfig; diff --git a/apps/common/features/package.json b/apps/common/features/package.json index b2b5f2355..8960c2cdb 100644 --- a/apps/common/features/package.json +++ b/apps/common/features/package.json @@ -3,9 +3,9 @@ "version": "0.0.0", "private": true, "scripts": { - "dev": "next dev", + "dev": "next dev -p 13000", "build": "next build", - "start": "next start", + "start": "next start -p 13000", "lint": "next lint" }, "dependencies": { diff --git a/apps/common/features/src/entities/post/api/post-service.ts b/apps/common/features/src/entities/post/api/post-service.ts new file mode 100644 index 000000000..b623af4fe --- /dev/null +++ b/apps/common/features/src/entities/post/api/post-service.ts @@ -0,0 +1,18 @@ +import { client } from "@/shared/api"; +import { ENDPOINT } from "@/shared/config"; +import type { + PostList, + PostParams, + PostService, +} from "../model/post-interface"; + +export class PostApiService implements PostService { + public async getPostList(params: PostParams): Promise { + const response = await client.get(ENDPOINT.BOARD_SERVICE.POSTS, { + params, + }); + return response.data; + } +} + +export const PostApi = new PostApiService(); diff --git a/apps/common/features/src/entities/post/index.ts b/apps/common/features/src/entities/post/index.ts new file mode 100644 index 000000000..933fb0a51 --- /dev/null +++ b/apps/common/features/src/entities/post/index.ts @@ -0,0 +1,7 @@ +export { PostApi } from "./api/post-service"; +export type { + Post, + PostList, + PostParams, + PostService, +} from "./model/post-interface"; diff --git a/apps/common/features/src/entities/post/model/post-interface.ts b/apps/common/features/src/entities/post/model/post-interface.ts new file mode 100644 index 000000000..5e0f394be --- /dev/null +++ b/apps/common/features/src/entities/post/model/post-interface.ts @@ -0,0 +1,38 @@ +import { + type PageableList, + type PageableParams, +} from "@/shared/model/api-interface"; + +export interface PostParams extends PageableParams { + keywordType?: string; + keyword?: string; + bbsId?: number; + delYn?: string; + frDateYmd?: string; + toDateYmd?: string; +} + +export interface Post { + bbsId: number; + pstNo: number; + pstTtl: string; + inqNocs: number; + rfrncUrl: string; + popupYn: string; + upndFixYn: string; + prdPstgYn: string; + rootPath: string; + pstPath: string; + ansPstn: number; + wrtrNm: string; + wrtrCplc: string; + atflCd: string; + regDt: string; + rgtrNm: string; +} + +export type PostList = PageableList; + +export interface PostService { + getPostList(params: PostParams): Promise; +} diff --git a/apps/common/features/src/pages/banner/api/banner-service.ts b/apps/common/features/src/pages/banner/api/banner-service.ts deleted file mode 100644 index 93646c770..000000000 --- a/apps/common/features/src/pages/banner/api/banner-service.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { client } from "@/shared/api"; -import { ENDPOINT } from "@/shared/config"; -import type { - BannerFormData, - BannerInfo, - BannerList, - BannerParams, - BannerService, -} from "../model/banner-interface"; - -export class BannerApiService implements BannerService { - public async getBannerList(params: BannerParams): Promise { - const response = await client.get( - `${ENDPOINT.CMS_SERVICE.BANNERS}`, - { params }, - ); - return response.data; - } - - public async getBannerInfo(bnrSn: string): Promise { - const response = await client.get( - `${ENDPOINT.CMS_SERVICE.BANNERS}/${bnrSn}`, - ); - return response.data; - } - - public async createBanner(data: BannerFormData): Promise { - const response = await client.post( - ENDPOINT.CMS_SERVICE.BANNERS, - data, - ); - return response.data; - } - - public async updateBanner( - bnrSn: string, - data: BannerFormData, - ): Promise { - const response = await client.put( - `${ENDPOINT.CMS_SERVICE.BANNERS}/${bnrSn}`, - data, - ); - return response.data; - } - - public async deleteBanner(bnrSn: string): Promise { - await client.delete(`${ENDPOINT.CMS_SERVICE.BANNERS}/${bnrSn}`); - } -} - -export const BannerApi = new BannerApiService(); diff --git a/apps/common/features/src/pages/banner/index.ts b/apps/common/features/src/pages/banner/index.ts deleted file mode 100644 index b2f0c6a55..000000000 --- a/apps/common/features/src/pages/banner/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { CreatePage } from "./ui/create-page"; -export { ModifyPage } from "./ui/modify-page"; -export { BannerPage } from "./ui/banner-page"; diff --git a/apps/common/features/src/pages/banner/lib/utils.ts b/apps/common/features/src/pages/banner/lib/utils.ts deleted file mode 100644 index c6c8ca101..000000000 --- a/apps/common/features/src/pages/banner/lib/utils.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Upload, type HttpResponse } from "tus-js-client"; -import { getCookie, setCookie } from "@/shared/lib"; -import { AUTH_USER_ID, CLAIM_NAME, ENDPOINT } from "@/shared/config"; - -type UploadOptions = { - handleUploadStart?: (upload: Upload) => void; - handleProgress?: (percentage: string) => void; - handleSuccess?: (upload: Upload) => void; - handleResponse?: (res: HttpResponse) => void; -}; - -export const handleUpload = (files: FileList, options?: UploadOptions) => { - let metadata = {}; - - const file = files.item(0); - if (!file) return; - metadata = { - filename: file.name, - filetype: file.type, - }; - - const atflCd = getCookie("atfl-cd-key"); - if (atflCd) { - metadata = { - ...metadata, - atflCd, - }; - } - - const upload = new Upload(file, { - endpoint: `${ENDPOINT.ATTACH_SERVICE.TUS_UPLOAD}`, - chunkSize: 10 * 1024 * 1024, - headers: { - [CLAIM_NAME]: getCookie(CLAIM_NAME) ?? "", - [AUTH_USER_ID]: getCookie(AUTH_USER_ID) ?? "", - }, - metadata, - onError(error) { - console.error(`Failed because: ${error}`); - }, - onProgress(bytesUploaded, bytesTotal) { - const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2); - options?.handleProgress?.(percentage); - }, - onAfterResponse(req, res) { - const fileInfo = res.getHeader("X-File-Info"); - if (fileInfo === undefined || fileInfo === null) return; - - setCookie("atfl-cd-key", JSON.parse(fileInfo)?.atflCd ?? ""); - options?.handleResponse?.(res); - }, - onSuccess() { - options?.handleSuccess?.(upload); - }, - }); - - upload.start(); - options?.handleUploadStart?.(upload); - - console.log("upload start >>>>>", upload); -}; diff --git a/apps/common/features/src/pages/banner/model/banner-interface.ts b/apps/common/features/src/pages/banner/model/banner-interface.ts deleted file mode 100644 index 1226f63e6..000000000 --- a/apps/common/features/src/pages/banner/model/banner-interface.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { z } from "zod"; -import type { PageableList, PageableParams } from "@/shared/model"; - -export const BANNER_TYPE = { - BNRMAIN: "BNRMAIN", - BNRFTER: "BNRFTER", -} as const; - -export type BannerType = (typeof BANNER_TYPE)[keyof typeof BANNER_TYPE]; - -export interface BannerParams extends PageableParams { - bnrTypeCd?: BannerType; - bnrTtl?: string; - useYn?: string; -} - -export interface Banner { - bnrSn: number; - bnrTypeCd: BannerType; - bnrTypeNm: string; - bnrTtl: string; - lnkgUrlAddr: string; - useYn: string; - atflCd: string; - mdfcnDt: string; - mdfr: string; - mdfrNm: string; -} - -export interface BannerInfo extends Omit { - bnrExpln: string; - newWndwYn: string; - atflCd: string; - regDt: string; - rgTrNm: string; -} - -export const bannerFormSchema = z.object({ - bnrTypeCd: z.string(), - bnrTtl: z.string(), - bnrExpln: z.string().nullish(), - lnkgUrlAddr: z.string().nullish(), - newWndwYn: z.string(), - atflCd: z.string().nullish(), - useYn: z.string(), -}); - -export type BannerFormData = z.infer; -export type BannerList = PageableList; - -export interface BannerService { - getBannerList: (params: BannerParams) => Promise; - getBannerInfo: (bnrSn: string) => Promise; - createBanner: (data: BannerFormData) => Promise; - updateBanner: (bnrSn: string, data: BannerFormData) => Promise; - deleteBanner: (bnrSn: string) => Promise; -} diff --git a/apps/common/features/src/pages/banner/model/banner-table-columns.tsx b/apps/common/features/src/pages/banner/model/banner-table-columns.tsx deleted file mode 100644 index 74da7c31c..000000000 --- a/apps/common/features/src/pages/banner/model/banner-table-columns.tsx +++ /dev/null @@ -1,100 +0,0 @@ -"use client"; - -import dayjs from "dayjs"; -import Image from "next/image"; -import { useQuery } from "@tanstack/react-query"; -import type { ColumnDef } from "@tanstack/react-table"; -import { Checkbox, Skeleton } from "@common/components/ui"; -import { AttachmentApi } from "@/entities/attachment"; -import { ENDPOINT } from "@/shared/config"; -import type { Banner } from "./banner-interface"; - -export const createColumns = ( - imageRefs: React.MutableRefObject>, -): ColumnDef[] => [ - { - id: "select", - header: ({ table }) => ( - e.stopPropagation()} - onCheckedChange={(checked) => - table.toggleAllPageRowsSelected(!!checked) - } - className="h-4 w-4 rounded border-gray-300" - /> - ), - cell: ({ row }) => ( - e.stopPropagation()} - onCheckedChange={(checked) => row.toggleSelected(!!checked)} - className="h-4 w-4 rounded border-gray-300" - /> - ), - }, - { - header: "배너 이미지", - cell: ({ row }) => ( - - ), - }, - { - accessorKey: "bnrTtl", - header: "배너명", - }, - { - accessorKey: "bnrTypeNm", - header: "배너구분", - }, - { - accessorKey: "useYn", - header: "사용여부", - }, - { - accessorKey: "mdfrNm", - header: "최종수정자", - }, - { - accessorKey: "mdfcnDt", - header: "최종수정일", - cell: ({ row }) => { - const date = row.getValue("mdfcnDt") as string; - return date ? dayjs(date).format("YYYY-MM-DD") : ""; - }, - }, -]; - -type BannerImageProps = { - atflCd: string; - bnrSn: number; - imageRefs: React.MutableRefObject>; -}; - -const BannerImage = ({ atflCd, bnrSn, imageRefs }: BannerImageProps) => { - const prevImage = imageRefs.current.get(bnrSn); - - const { data: imageUrl, isLoading } = useQuery({ - queryKey: [ENDPOINT.ATTACH_SERVICE.IMAGES, atflCd], - queryFn: () => AttachmentApi.getImageUrlByAtflCd(atflCd), - select: (url) => { - if (url) imageRefs.current.set(bnrSn, url); - return url; - }, - enabled: !prevImage && !!atflCd, - }); - - if (isLoading) return ; - - if (!imageUrl) return null; - - return ( -
- 배너 이미지 -
- ); -}; diff --git a/apps/common/features/src/pages/banner/model/posting-table-columns.tsx b/apps/common/features/src/pages/banner/model/posting-table-columns.tsx deleted file mode 100644 index a43cf8693..000000000 --- a/apps/common/features/src/pages/banner/model/posting-table-columns.tsx +++ /dev/null @@ -1,44 +0,0 @@ -"use client"; - -import dayjs from "dayjs"; -import type { ColumnDef } from "@tanstack/react-table"; -import { Checkbox } from "@common/components/ui"; -import type { Post } from "@/entities/posting"; - -export const columns: ColumnDef[] = [ - { - id: "select", - header: ({ table }) => ( - e.stopPropagation()} - onCheckedChange={(checked) => - table.toggleAllPageRowsSelected(!!checked) - } - className="h-4 w-4 rounded border-gray-300" - /> - ), - cell: ({ row }) => ( - e.stopPropagation()} - onCheckedChange={(checked) => row.toggleSelected(!!checked)} - className="h-4 w-4 rounded border-gray-300" - /> - ), - }, - { - accessorKey: "siteNm", - header: "사이트", - }, - { - accessorKey: "pstgPrdSeNm", - header: "게시기간", - cell: ({ row }) => { - const pstgPrdSeNm = row.original.pstgPrdSeNm; - const pstgBgngDt = row.original.pstgBgngDt; - const pstgEndDt = row.original.pstgEndDt; - return `${pstgPrdSeNm} (${dayjs(pstgBgngDt).format("YYYY-MM-DD")} ~ ${dayjs(pstgEndDt).format("YYYY-MM-DD")})`; - }, - }, -]; diff --git a/apps/common/features/src/pages/banner/ui/banner-form.tsx b/apps/common/features/src/pages/banner/ui/banner-form.tsx deleted file mode 100644 index f4af75ffe..000000000 --- a/apps/common/features/src/pages/banner/ui/banner-form.tsx +++ /dev/null @@ -1,296 +0,0 @@ -"use client"; - -import Image from "next/image"; -import { useEffect, useState } from "react"; -import { useQuery } from "@tanstack/react-query"; -import type { UseFormReturn } from "react-hook-form"; -import type { HttpResponse, Upload } from "tus-js-client"; -import { - FileUploader, - Input, - Label, - Progress, - RadioGroup, - RadioGroupItem, - Table, - TableBody, - TableCell, - TableHead, - TableRow, - Textarea, -} from "@common/components"; -import { FormWrapper } from "@/widgets/form-wrapper"; -import { CodeSelect } from "@/entities/code"; -import { AttachmentApi } from "@/entities/attachment"; -import { ENDPOINT } from "@/shared/config"; -import { setCookie } from "@/shared/lib/cookie"; -import { FormControl, FormField, FormItem } from "@/shared/ui/form"; -import type { BannerFormData } from "../model/banner-interface"; -import { handleUpload } from "../lib/utils"; - -type BannerFormProps = { - form: UseFormReturn; - bnrSn?: number; - handleSave: (data: BannerFormData) => Promise; - handleDelete?: () => Promise; -}; - -function BannerForm({ form, bnrSn, ...props }: BannerFormProps) { - const atflCd = form.watch("atflCd"); - - const [imageUrl, setImageUrl] = useState(""); - const [upload, setUpload] = useState(null); - const [progress, setProgress] = useState(0); - - const { data: attachmentData } = useQuery({ - queryKey: [ENDPOINT.ATTACH_SERVICE.ATTACHMENTS, atflCd], - queryFn: () => AttachmentApi.getAttachmentsInfo(atflCd!), - select: (data) => data?.[data.length - 1], - enabled: !!atflCd, - }); - - const handleProgress = (percentage: string) => { - setProgress(Number(percentage)); - }; - - const handleUploadResponse = async (res: HttpResponse) => { - const fileInfo = res.getHeader("X-File-Info"); - if (fileInfo === undefined || fileInfo === null) return; - - const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; - if (atflCd) form.setValue("atflCd", atflCd); - if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId)); - if (attachmentData) - await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd); - }; - - useEffect(() => { - if (!attachmentData) return; - - (async () => { - setImageUrl(await AttachmentApi.getImageUrl(attachmentData.atflId)); - })(); - }, [attachmentData]); - - return ( - -
- - - - - - - - 배너명 - - ( - - - - - - )} - /> - - - - 배너구분 - - ( - - - - - - )} - /> - - - - 배너 이미지 - - ( - - - { - const files = e.target.files; - if (!files) return; - setCookie("atfl-cd-key", ""); - handleUpload(files, { - handleUploadStart: setUpload, - handleProgress, - handleSuccess: setUpload, - handleResponse: handleUploadResponse, - }); - }} - customPreview={ - <> - -
-
    -
  • - 이미지 파일(jpg, jpeg, png, gif)만 업로드 - 가능합니다. -
  • -
-
- - } - /> -
-
- )} - /> -
-
- - 링크 URL - - ( - - - - - - )} - /> - - - - 링크 열기 - - ( - - - -
- - -
-
- - -
-
-
-
- )} - /> -
-
- - 배너 설명 - - ( - - -