From 757deae40ef1de05622d45fb8e6406aa71d40333 Mon Sep 17 00:00:00 2001 From: changwng Date: Thu, 10 Jul 2025 14:51:25 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[groups]=20=EA=B7=B8=EB=A3=B9=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=EC=83=81=EB=8B=A8=EC=97=90=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=B6=95=EA=B0=80=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group-user/model/group-user-interface.ts | 1 + apps/cs/src/entities/group/index.ts | 1 + .../pages/groups/ui/group-users-section.tsx | 45 ++++++++++- .../cs/src/pages/groups/ui/groups-section.tsx | 76 ++++++++++++++++++- apps/cs/src/types/tanstack-table.d.ts | 11 +++ 5 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 apps/cs/src/types/tanstack-table.d.ts diff --git a/apps/cs/src/entities/group-user/model/group-user-interface.ts b/apps/cs/src/entities/group-user/model/group-user-interface.ts index 8935bfacc..52fa97fce 100644 --- a/apps/cs/src/entities/group-user/model/group-user-interface.ts +++ b/apps/cs/src/entities/group-user/model/group-user-interface.ts @@ -3,6 +3,7 @@ import type { PageableList, PageableParams } from "@/shared/model"; // 그룹 사용자 검색 파라미터 인터페이스 export interface GroupUserSearchParams extends PageableParams { keyword?: string; + userNm?: string; } // 그룹 사용자 목록 응답 인터페이스 diff --git a/apps/cs/src/entities/group/index.ts b/apps/cs/src/entities/group/index.ts index da1d72a41..30dc07714 100644 --- a/apps/cs/src/entities/group/index.ts +++ b/apps/cs/src/entities/group/index.ts @@ -3,4 +3,5 @@ export { groupFormSchema, type GroupFormData, type GroupListResponseDto, + type GroupSearchParams, } from "./model/group-interface"; diff --git a/apps/cs/src/pages/groups/ui/group-users-section.tsx b/apps/cs/src/pages/groups/ui/group-users-section.tsx index dc16fda60..4b7170e3a 100644 --- a/apps/cs/src/pages/groups/ui/group-users-section.tsx +++ b/apps/cs/src/pages/groups/ui/group-users-section.tsx @@ -12,7 +12,7 @@ import { type RowSelectionState, } from "@tanstack/react-table"; import { useConfirm } from "@frontend-opensource/use-react-hooks"; -import { Button } from "@common/components"; +import { Button,Input, Label } from "@common/components"; import { GroupUsersApi } from "@/entities/group-user"; import { ENDPOINT } from "@/shared/config"; import { useAlertStore, useDataTable } from "@/shared/lib"; @@ -32,13 +32,17 @@ function GroupUsersSection({ groupId }: GroupUsersSectionProps) { pageIndex: 0, pageSize: 10, }); + + const [userNm, setUserNm] = useState(""); + const [rowSelection, setRowSelection] = useState({}); const query = useQuery({ - queryKey: [ENDPOINT.CMS_SERVICE.GROUP_USERS, groupId, pagination], + queryKey: [ENDPOINT.CMS_SERVICE.GROUP_USERS, groupId, pagination, userNm], queryFn: () => GroupUsersApi.findPageGroupUser({ keyword: groupId, + userNm: userNm, page: pagination.pageIndex, size: pagination.pageSize, }), @@ -46,6 +50,20 @@ function GroupUsersSection({ groupId }: GroupUsersSectionProps) { placeholderData: keepPreviousData, }); + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + setPagination({ + ...pagination, + pageIndex: 0, + }); + // userNm이 이미 state에 반영되어 있으므로 별도 처리 불필요 + // 쿼리키에 userNm이 포함되어 있어 자동 refetch됨 + }; + + const handleReset = () => { + setUserNm(""); + }; + const { tableComponent, tableInstance: table } = useDataTable({ query, tableOptions: { @@ -97,6 +115,29 @@ function GroupUsersSection({ groupId }: GroupUsersSectionProps) { return (
+
+
+ + setUserNm(e.target.value)} + /> + + +
+

그룹 사용자 목록

diff --git a/apps/cs/src/pages/groups/ui/groups-section.tsx b/apps/cs/src/pages/groups/ui/groups-section.tsx index 2130a94c0..c316283b7 100644 --- a/apps/cs/src/pages/groups/ui/groups-section.tsx +++ b/apps/cs/src/pages/groups/ui/groups-section.tsx @@ -3,14 +3,14 @@ import { useState } from "react"; import { keepPreviousData, useQuery, useQueryClient } from "@tanstack/react-query"; import { getCoreRowModel, type PaginationState } from "@tanstack/react-table"; -import { Button } from "@common/components"; -import { GroupApi } from "@/entities/group"; +import { Button, Input, Label } from "@common/components"; +import { GroupApi , type GroupSearchParams} from "@/entities/group"; import { ENDPOINT } from "@/shared/config"; import { useDataTable } from "@/shared/lib"; import { columns } from "../model/groups-table-columns"; import { GroupsDialog } from "./groups-dialog"; import { useConfirm } from "@frontend-opensource/use-react-hooks"; -import { useAlertStore, useMutationWrapper } from "@/shared/lib"; +import { useAlertStore, useMutationWrapper } from "@/shared/lib"; type GroupsSectionProps = { handleSelectedGroup: (groupId: string) => void; @@ -22,10 +22,20 @@ function GroupsSection({ handleSelectedGroup }: GroupsSectionProps) { pageSize: 10, }); + const [groupNm, setGroupNm] = useState(""); + const [searchParams, setSearchParams] = useState({ + groupNm: "", + delYn :"N", + sort : "groupId,desc", + }); + + + const query = useQuery({ - queryKey: [ENDPOINT.CMS_SERVICE.GROUPS, pagination], + queryKey: [ENDPOINT.CMS_SERVICE.GROUPS,searchParams, pagination], queryFn: () => GroupApi.findPageGroup({ + ...searchParams, page: pagination.pageIndex, size: pagination.pageSize, }), @@ -49,6 +59,27 @@ function GroupsSection({ handleSelectedGroup }: GroupsSectionProps) { await deleteGroup(groupId); } }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + setPagination({ + ...pagination, + pageIndex: 0, + }); + setSearchParams({ + ...searchParams, + groupNm, + }); + }; + + const handleReset = () => { + setGroupNm(""); + setSearchParams({ + ...searchParams, + groupNm: "", + delYn:"N" + }); + }; const handleRowClick = (row: { groupId: string }) => { table.setRowSelection({ [row.groupId]: true }); handleSelectedGroup(row.groupId); // 1. 리스트에서 선택된 groupId 저장 @@ -76,6 +107,43 @@ function GroupsSection({ handleSelectedGroup }: GroupsSectionProps) { return (
+
+
+ + setGroupNm(e.target.value)} + /> + + + + + setSearchParams({ + ...searchParams, + delYn: e.target.checked ? "Y" : "N", + }) + } + /> +
+

그룹 목록

diff --git a/apps/cs/src/types/tanstack-table.d.ts b/apps/cs/src/types/tanstack-table.d.ts new file mode 100644 index 000000000..9cd9838a2 --- /dev/null +++ b/apps/cs/src/types/tanstack-table.d.ts @@ -0,0 +1,11 @@ +import '@tanstack/react-table'; + +// 오류가 표시되는 이유는 TypeScript가 meta 객체 안에 onDelete라는 속성이 존재한다는 것을 모르기 때문입니다 +declare module '@tanstack/react-table' { + // TData는 테이블의 row 데이터 타입을 의미합니다. + // interface TableMeta에 우리 프로젝트에서 사용할 커스텀 속성의 타입을 정의합니다. + interface TableMeta { + // handleDelete 함수가 string 타입의 인자를 받으므로, 타입을 명시해줍니다. + onDelete: (groupId: string) => void; + } +} \ No newline at end of file From ffacf689f92a4fd42a3811297ff80696fb0d1403 Mon Sep 17 00:00:00 2001 From: changwng Date: Thu, 10 Jul 2025 15:10:41 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[groups]=20tableData=20build=EC=8B=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EB=A1=9C=20=EB=8B=A4=EC=8B=9C=20=EC=98=AC?= =?UTF-8?q?=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/groups/model/groups-table-columns.tsx | 8 ++++++++ apps/cs/src/types/tanstack-table.d.ts | 11 ----------- 2 files changed, 8 insertions(+), 11 deletions(-) delete mode 100644 apps/cs/src/types/tanstack-table.d.ts diff --git a/apps/cs/src/pages/groups/model/groups-table-columns.tsx b/apps/cs/src/pages/groups/model/groups-table-columns.tsx index 0f417a304..0cb6a1f84 100644 --- a/apps/cs/src/pages/groups/model/groups-table-columns.tsx +++ b/apps/cs/src/pages/groups/model/groups-table-columns.tsx @@ -4,6 +4,14 @@ import { type GroupListResponseDto } from "@/entities/group"; import { MenuAuthorityDialog } from "../ui/menu-authority-dialog"; import { GroupsDialog } from "../ui/groups-dialog"; + +declare module "@tanstack/react-table" { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + interface TableMeta { + onDelete: (groupId: string) => void; + } +} + export const columns: ColumnDef[] = [ { accessorKey: "groupId", diff --git a/apps/cs/src/types/tanstack-table.d.ts b/apps/cs/src/types/tanstack-table.d.ts deleted file mode 100644 index 9cd9838a2..000000000 --- a/apps/cs/src/types/tanstack-table.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import '@tanstack/react-table'; - -// 오류가 표시되는 이유는 TypeScript가 meta 객체 안에 onDelete라는 속성이 존재한다는 것을 모르기 때문입니다 -declare module '@tanstack/react-table' { - // TData는 테이블의 row 데이터 타입을 의미합니다. - // interface TableMeta에 우리 프로젝트에서 사용할 커스텀 속성의 타입을 정의합니다. - interface TableMeta { - // handleDelete 함수가 string 타입의 인자를 받으므로, 타입을 명시해줍니다. - onDelete: (groupId: string) => void; - } -} \ No newline at end of file From 12d03e9dd1eceb2f4061a4046d1b297caa344e75 Mon Sep 17 00:00:00 2001 From: changwng Date: Thu, 10 Jul 2025 15:45:32 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[groups]=20tableData=20build=EC=8B=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EB=A1=9C=20-=20onDelete=20=EC=98=B5=EC=85=94?= =?UTF-8?q?=EB=84=90=EB=A1=9C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cs/src/pages/groups/model/groups-table-columns.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cs/src/pages/groups/model/groups-table-columns.tsx b/apps/cs/src/pages/groups/model/groups-table-columns.tsx index 0cb6a1f84..864bfafd2 100644 --- a/apps/cs/src/pages/groups/model/groups-table-columns.tsx +++ b/apps/cs/src/pages/groups/model/groups-table-columns.tsx @@ -8,7 +8,7 @@ import { GroupsDialog } from "../ui/groups-dialog"; declare module "@tanstack/react-table" { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface TableMeta { - onDelete: (groupId: string) => void; + onDelete?: (groupId: string , row?: TData) => void; } } From 67023952aed67aed6e0a4f8b47220398d17dd6d9 Mon Sep 17 00:00:00 2001 From: changwng Date: Thu, 10 Jul 2025 15:49:22 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[all]=20cs=20=EC=8B=A4=ED=96=89=EC=8B=9C=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EB=82=A8=EA=B8=B0=EA=B8=B0=EB=B0=8F=20?= =?UTF-8?q?=ED=84=B0=EB=AF=B8=EB=84=90=20=EC=97=86=EC=9D=B4=20=EB=9B=B0?= =?UTF-8?q?=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cs/start_cs.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/cs/start_cs.sh diff --git a/apps/cs/start_cs.sh b/apps/cs/start_cs.sh new file mode 100644 index 000000000..1cd43e699 --- /dev/null +++ b/apps/cs/start_cs.sh @@ -0,0 +1 @@ +nohup pnpm start > start.log 2>&1 & \ No newline at end of file From ec91aa461ac4bace98cfba5fabd0b96c25fdd334 Mon Sep 17 00:00:00 2001 From: changwng Date: Thu, 10 Jul 2025 16:26:44 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[all]=20cs=20=EB=B0=8F=20features=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/features/start_13000.sh | 25 +++++++++++++++++++++++++ apps/cs/start_cs.sh | 26 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 apps/common/features/start_13000.sh mode change 100644 => 100755 apps/cs/start_cs.sh diff --git a/apps/common/features/start_13000.sh b/apps/common/features/start_13000.sh new file mode 100755 index 000000000..e1ba84bbf --- /dev/null +++ b/apps/common/features/start_13000.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +PORT=13000 +LOG_FILE="start_13000.log" + +# 1. 기존 포트 사용 프로세스 종료 +PID=$(lsof -t -i :$PORT) +if [ -n "$PID" ]; then + echo "Killing process on port $PORT (PID: $PID)" + kill -9 $PID +fi + +# 2. 백그라운드로 앱 시작 (로그 파일로 리디렉션) +echo "Starting app on port $PORT..." +nohup pnpm start > $LOG_FILE 2>&1 & + +# 3. PID 확인 +sleep 1 +NEW_PID=$(lsof -t -i :$PORT) +if [ -n "$NEW_PID" ]; then + echo "App started successfully (PID: $NEW_PID)" + echo "Logs: tail -f $LOG_FILE" +else + echo "Failed to start app. Check logs: $LOG_FILE" +fi \ No newline at end of file diff --git a/apps/cs/start_cs.sh b/apps/cs/start_cs.sh old mode 100644 new mode 100755 index 1cd43e699..7fa2c18a7 --- a/apps/cs/start_cs.sh +++ b/apps/cs/start_cs.sh @@ -1 +1,25 @@ -nohup pnpm start > start.log 2>&1 & \ No newline at end of file +#!/bin/bash + +PORT=3000 +LOG_FILE="start_cs.log" + +# 1. 기존 포트 사용 프로세스 종료 +PID=$(lsof -t -i :$PORT) +if [ -n "$PID" ]; then + echo "Killing process on port $PORT (PID: $PID)" + kill -9 $PID +fi + +# 2. 백그라운드로 앱 시작 (로그 파일로 리디렉션) +echo "Starting app on port $PORT..." +nohup pnpm start > $LOG_FILE 2>&1 & + +# 3. PID 확인 +sleep 1 +NEW_PID=$(lsof -t -i :$PORT) +if [ -n "$NEW_PID" ]; then + echo "App started successfully (PID: $NEW_PID)" + echo "Logs: tail -f $LOG_FILE" +else + echo "Failed to start app. Check logs: $LOG_FILE" +fi \ No newline at end of file From 20db7002154bc8387dddc423aa415fc972b821d5 Mon Sep 17 00:00:00 2001 From: changwng Date: Thu, 10 Jul 2025 19:02:26 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[code]=20=ED=95=98=EC=9C=84=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=93=B1=EB=A1=9D=ED=9B=84=20=EC=9E=AC=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20handleAft?= =?UTF-8?q?erSave=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++ .../code/model/lwpocode-table-columns.tsx | 89 ++++++++++--------- apps/cs/src/pages/code/ui/lwpocode-dialog.tsx | 86 +++++++++++++----- .../cs/src/pages/code/ui/lwpocode-section.tsx | 19 ++-- 4 files changed, 134 insertions(+), 68 deletions(-) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..c3f502a19 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/apps/cs/src/pages/code/model/lwpocode-table-columns.tsx b/apps/cs/src/pages/code/model/lwpocode-table-columns.tsx index 1bea87275..a119d88d9 100644 --- a/apps/cs/src/pages/code/model/lwpocode-table-columns.tsx +++ b/apps/cs/src/pages/code/model/lwpocode-table-columns.tsx @@ -5,56 +5,62 @@ import type { LwpoCode } from "@/entities/code"; import { LwpoCodeManagementDialog } from "../ui/lwpocode-dialog"; import { useState } from "react"; -export const columns: ColumnDef[] = [ - { - id: "no", - header: "NO", - cell: ({ row, table }) => { - const totalRows = table.getRowCount(); - const { pageIndex, pageSize } = table.getState().pagination; - return totalRows - (pageIndex * pageSize + row.index); +// columns를 함수로 변경하여 onAfterSave를 주입받음 +export function getColumns(onAfterSave: () => void) : ColumnDef[] { + return [ + { + id: "no", + header: "NO", + cell: ({ row, table }) => { + const totalRows = table.getRowCount(); + const { pageIndex, pageSize } = table.getState().pagination; + return totalRows - (pageIndex * pageSize + row.index); + }, }, - }, - { - accessorKey: "lwpoCd", - header: "하위코드", - }, - { - accessorKey: "lwpoCdNm", - header: "하위코드명", - }, - { - accessorKey: "useYn", - header: "사용 여부", - }, - { - accessorKey: "regDt", - header: "등록일", - cell: ({ row }) => { - const date = dayjs(row.original.regDt); - return date.format("YYYY-MM-DD"); + { + accessorKey: "lwpoCd", + header: "하위코드", }, - }, - { - id: "actions", - header: "관리", - cell: ({ row }) => ( -
e.stopPropagation()}> - -
- ), - }, -]; + { + accessorKey: "lwpoCdNm", + header: "하위코드명", + }, + { + accessorKey: "useYn", + header: "사용 여부", + }, + { + accessorKey: "regDt", + header: "등록일", + cell: ({ row }) => { + const date = dayjs(row.original.regDt); + return date.format("YYYY-MM-DD"); + }, + }, + { + id: "actions", + header: "관리", + cell: ({ row }) => ( +
e.stopPropagation()}> + +
+ ), + }, + ]; +} const LwpoCodeManageButton = ({ lwpoCd, upCd, + onAfterSave, }: { lwpoCd: string; upCd: string; + onAfterSave: () => void; }) => { const [dialogOpen, setDialogOpen] = useState(false); return ( @@ -63,6 +69,7 @@ const LwpoCodeManageButton = ({ upCd={upCd} open={dialogOpen} onOpenChange={setDialogOpen} + onAfterSave={onAfterSave} > diff --git a/apps/cs/src/pages/code/ui/lwpocode-dialog.tsx b/apps/cs/src/pages/code/ui/lwpocode-dialog.tsx index c11c57332..1eb9562ec 100644 --- a/apps/cs/src/pages/code/ui/lwpocode-dialog.tsx +++ b/apps/cs/src/pages/code/ui/lwpocode-dialog.tsx @@ -37,7 +37,8 @@ type ManagementLwpoCodeDialogProps = { upCd?: string; children?: React.ReactNode; open?: boolean; - onOpenChange?: (open: boolean) => void; + onOpenChange?: (open: boolean) => void; + onAfterSave?: () => void; // 콜백 추가 }; const LwpoCodeManagementDialog = memo( @@ -46,19 +47,21 @@ const LwpoCodeManagementDialog = memo( upCd, children, open, - onOpenChange, + onOpenChange, + onAfterSave, // 콜백 사용 ...props }: ManagementLwpoCodeDialogProps) => { const isRegistration = !lwpoCd; const { confirm } = useConfirm(); - const alert = useAlertStore((state) => state.setMessage); - + const alert = useAlertStore((state) => state.setMessage); + // 상세 데이터 const { data: detailData } = useQuery({ queryKey: [ENDPOINT.CMS_SERVICE.LWPO_CODE, upCd, lwpoCd], queryFn: () => LwpoCodeApi.lwpoCodeDetail(upCd!, lwpoCd!), - enabled: !!upCd && !isRegistration, + enabled: !!upCd && !isRegistration && open, }); + const { data: upCodeData } = useQuery({ queryKey: [ENDPOINT.CMS_SERVICE.UP_CODE, upCd], @@ -68,16 +71,22 @@ const LwpoCodeManagementDialog = memo( const { mutateAsync: createLwpoCode } = useMutationWrapper({ mutationFn: (data: LwpoCodeFormData) => LwpoCodeApi.createLwpoCode(data), - onSuccess: () => { - alert("등록되었습니다.", () => onOpenChange?.(false)); + onSuccess: async () => { + alert("등록되었습니다.", () => { + onOpenChange?.(false); + if (onAfterSave) onAfterSave(); + }); }, }); const { mutateAsync: updateLwpoCode } = useMutationWrapper({ mutationFn: (data: LwpoCodeFormData) => LwpoCodeApi.updateLwpoCode(upCd!, lwpoCd!, data), - onSuccess: () => { - alert("수정되었습니다.", () => onOpenChange?.(false)); + onSuccess: async () => { + alert("수정되었습니다.", () => { + onOpenChange?.(false); + if (onAfterSave) onAfterSave(); + }); }, }); @@ -95,16 +104,40 @@ const LwpoCodeManagementDialog = memo( delYn: "N", }, }); + - const onSubmit = - (callback: (data: LwpoCodeFormData) => void) => - async (data: LwpoCodeFormData) => { - const confirmMessage = isRegistration - ? "등록하시겠습니까?" - : "수정하시겠습니까?"; - - if (await confirm(confirmMessage)) callback(data); - }; + const handleRegister = async () => { + if (!upCd) { + alert("상위코드가 없습니다."); + return; + } + const confirmMessage = "등록하시겠습니까?"; + if (await confirm(confirmMessage)) { + const rawValues = form.getValues(); + const values = { + ...rawValues, + upCd: upCd, + sortSeq: Number(rawValues.sortSeq) || 0, + }; + await createLwpoCode(values); + } + }; + const handleSave = async () => { + if (!upCd) { + alert("상위코드가 없습니다."); + return; + } + const confirmMessage = "수정하시겠습니까?"; + if (await confirm(confirmMessage)) { + const rawValues = form.getValues(); + const values = { + ...rawValues, + upCd: upCd, + sortSeq: Number(rawValues.sortSeq) || 0, + }; + await updateLwpoCode(values); + } + }; return ( @@ -117,9 +150,14 @@ const LwpoCodeManagementDialog = memo(
{ + e.preventDefault(); + if (isRegistration) { + handleRegister(); + } else { + handleSave(); + } + }} className="space-y-4" > @@ -292,7 +330,11 @@ const LwpoCodeManagementDialog = memo(
- diff --git a/apps/cs/src/pages/code/ui/lwpocode-section.tsx b/apps/cs/src/pages/code/ui/lwpocode-section.tsx index c6025b338..3e6aaf1ca 100644 --- a/apps/cs/src/pages/code/ui/lwpocode-section.tsx +++ b/apps/cs/src/pages/code/ui/lwpocode-section.tsx @@ -5,7 +5,7 @@ import { Button, Input, Label } from "@common/components"; import { LwpoCodeApi, type LwpoCodeParams } from "@/entities/code"; import { ENDPOINT } from "@/shared/config"; import { useAlertStore, useDataTable } from "@/shared/lib"; -import { columns } from "../model/lwpocode-table-columns"; +import { getColumns } from "../model/lwpocode-table-columns"; import { LwpoCodeManagementDialog } from "./lwpocode-dialog"; type LwpoCodeSectionProps = { @@ -24,7 +24,7 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) { pageIndex: 0, pageSize: 10, }); - + const query = useQuery({ queryKey: [ENDPOINT.CMS_SERVICE.LWPO_CODE, upCd, searchParams, pagination], queryFn: () => @@ -34,10 +34,17 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) { page: pagination.pageIndex, size: pagination.pageSize, }), - enabled: !!upCd, + enabled: !!upCd , placeholderData: keepPreviousData, - }); + }); + // 등록/수정 후 목록 재조회 콜백 + const handleAfterSave = () => { + query.refetch(); + }; + const columns = getColumns(handleAfterSave); + + const { mutateAsync: codeRefreshAll } = useMutation({ mutationFn: LwpoCodeApi.codeRefreshAll, onSuccess: () => { @@ -117,7 +124,9 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {