chore: 코드관리 코드갱신 기능 추가 및 W3 에러 해결
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
import { keepPreviousData, useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { getCoreRowModel, type PaginationState } from "@tanstack/react-table";
|
import { getCoreRowModel, type PaginationState } from "@tanstack/react-table";
|
||||||
import { Button, Input, Label } from "@common/components";
|
import { Button, Input, Label } from "@common/components";
|
||||||
import { LwpoCodeApi, type LwpoCodeParams } from "@/entities/code";
|
import { LwpoCodeApi, type LwpoCodeParams } from "@/entities/code";
|
||||||
import { ENDPOINT } from "@/shared/config";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import { useDataTable } from "@/shared/lib";
|
import { useAlertStore, useDataTable } from "@/shared/lib";
|
||||||
import { columns } from "../model/lwpocode-table-columns";
|
import { columns } from "../model/lwpocode-table-columns";
|
||||||
import { LwpoCodeManagementDialog } from "./lwpocode-dialog";
|
import { LwpoCodeManagementDialog } from "./lwpocode-dialog";
|
||||||
import { useMutation } from '@tanstack/react-query'
|
|
||||||
|
|
||||||
type LwpoCodeSectionProps = {
|
type LwpoCodeSectionProps = {
|
||||||
upCd?: string;
|
upCd?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
|
function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
|
||||||
|
const alert = useAlertStore((state) => state.setMessage);
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [lwpoCodeQuery, setLwpoCodeQuery] = useState<LwpoCodeParams>({
|
const [lwpoCodeQuery, setLwpoCodeQuery] = useState<LwpoCodeParams>({
|
||||||
lwpoCdNm: "",
|
lwpoCdNm: "",
|
||||||
@@ -36,6 +36,13 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
|
|||||||
placeholderData: keepPreviousData,
|
placeholderData: keepPreviousData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { mutateAsync: codeRefreshAll } = useMutation({
|
||||||
|
mutationFn: LwpoCodeApi.codeRefreshAll,
|
||||||
|
onSuccess: () => {
|
||||||
|
alert("코드 갱신이 완료되었습니다.");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const { tableComponent } = useDataTable({
|
const { tableComponent } = useDataTable({
|
||||||
query,
|
query,
|
||||||
tableOptions: {
|
tableOptions: {
|
||||||
@@ -59,20 +66,6 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
|
|||||||
setPagination({ ...pagination, pageIndex: 0 });
|
setPagination({ ...pagination, pageIndex: 0 });
|
||||||
}, [upCd]);
|
}, [upCd]);
|
||||||
|
|
||||||
const { mutateAsync: codeRefreshAll } = useMutation({
|
|
||||||
mutationFn: () => LwpoCodeApi.codeRefreshAll(),
|
|
||||||
onSuccess: () => {
|
|
||||||
alert('저장되었습니다.')
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.error('에러 발생:', error)
|
|
||||||
alert('에러가 발생했습니다.')
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="card card-border">
|
<div className="card card-border">
|
||||||
@@ -98,17 +91,17 @@ function LwpoCodeSection({ upCd }: LwpoCodeSectionProps) {
|
|||||||
<div className="card card-border">
|
<div className="card card-border">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<h3 className="text-2xl font-medium text-label">하위코드 목록</h3>
|
<h3 className="text-2xl font-medium text-label">하위코드 목록</h3>
|
||||||
<button onClick={() => codeRefreshAll()} className="btn">
|
<div className="flex items-center gap-2">
|
||||||
코드 리프레시
|
<Button color="emerald" onClick={() => codeRefreshAll()}>
|
||||||
</button>
|
코드갱신
|
||||||
|
</Button>
|
||||||
<LwpoCodeManagementDialog
|
<LwpoCodeManagementDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
onOpenChange={setDialogOpen}
|
onOpenChange={setDialogOpen}
|
||||||
>
|
>
|
||||||
<Button>등록</Button>
|
<Button>등록</Button>
|
||||||
</LwpoCodeManagementDialog>
|
</LwpoCodeManagementDialog>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="card !m-4 h-[calc(100vh-35rem)] overflow-auto !p-0">
|
<div className="card !m-4 h-[calc(100vh-35rem)] overflow-auto !p-0">
|
||||||
{tableComponent}
|
{tableComponent}
|
||||||
|
|||||||
@@ -94,9 +94,6 @@ export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
|||||||
<header className="sticky top-0 z-30 box-border flex h-[5rem] w-full items-center justify-between border-b border-solid border-border bg-background">
|
<header className="sticky top-0 z-30 box-border flex h-[5rem] w-full items-center justify-between border-b border-solid border-border bg-background">
|
||||||
<div className="flex items-center px-6">
|
<div className="flex items-center px-6">
|
||||||
<SidebarTrigger className="size-12 !bg-transparent p-2 hover:!bg-accent [&>svg]:!size-full [&>svg]:text-foreground" />
|
<SidebarTrigger className="size-12 !bg-transparent p-2 hover:!bg-accent [&>svg]:!size-full [&>svg]:text-foreground" />
|
||||||
<div className="MobMenuBtn">
|
|
||||||
<img src={images.menuBtn} />
|
|
||||||
</div>
|
|
||||||
<h1 className="flex items-center gap-4">
|
<h1 className="flex items-center gap-4">
|
||||||
<img src={images.logo} className="h-[3rem]" alt="logo" />
|
<img src={images.logo} className="h-[3rem]" alt="logo" />
|
||||||
<span className="text-[1.8rem] font-semibold text-foreground">
|
<span className="text-[1.8rem] font-semibold text-foreground">
|
||||||
|
|||||||
Reference in New Issue
Block a user