코드갱신

This commit is contained in:
2025-06-26 17:48:04 +09:00
parent ec12b35464
commit 70832bae82
3 changed files with 27 additions and 0 deletions
@@ -62,6 +62,12 @@ export class LwpoCodeApiService implements LwpoCodeService {
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${lwpoCd}/up-cd/${upCd}`,
);
}
public async codeRefreshAll(): Promise<void> {
await client.post<void>(
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/cache/refresh-all`,
);
}
}
export const LwpoCodeApi = new LwpoCodeApiService();
@@ -65,4 +65,5 @@ export interface LwpoCodeService {
lwpoCd: string,
data: LwpoCodeFormData,
): Promise<void>;
codeRefreshAll(): Promise<void>;
}
@@ -7,6 +7,7 @@ import { ENDPOINT } from "@/shared/config";
import { useDataTable } from "@/shared/lib";
import { columns } from "../model/lwpocode-table-columns";
import { LwpoCodeManagementDialog } from "./lwpocode-dialog";
import { useMutation } from '@tanstack/react-query'
type LwpoCodeSectionProps = {
upCd?: string;
@@ -58,6 +59,20 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
setPagination({ ...pagination, pageIndex: 0 });
}, [upCd]);
const { mutateAsync: codeRefreshAll } = useMutation({
mutationFn: () => LwpoCodeApi.codeRefreshAll(),
onSuccess: () => {
alert('저장되었습니다.')
},
onError: (error) => {
console.error('에러 발생:', error)
alert('에러가 발생했습니다.')
},
})
return (
<div className="flex-1">
<div className="card card-border">
@@ -83,12 +98,17 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
<div className="card card-border">
<div className="card-header">
<h3 className="text-2xl font-medium text-label">하위코드 목록</h3>
<button onClick={() => codeRefreshAll()} className="btn">
코드 리프레시
</button>
<LwpoCodeManagementDialog
open={dialogOpen}
onOpenChange={setDialogOpen}
>
<Button>등록</Button>
</LwpoCodeManagementDialog>
</div>
<div className="card !m-4 h-[calc(100vh-35rem)] overflow-auto !p-0">
{tableComponent}