From 9ceed79cf32c896f8a998399bf1b296506b2cd4a Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 8 Apr 2025 03:08:19 +0000 Subject: 로그인 및 미들웨어 처리. 구조 변경 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/equipClass-table-toolbar-actions.tsx | 55 +++++++++++++++++----- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'lib/equip-class/table/equipClass-table-toolbar-actions.tsx') diff --git a/lib/equip-class/table/equipClass-table-toolbar-actions.tsx b/lib/equip-class/table/equipClass-table-toolbar-actions.tsx index 5e03d800..03db30a3 100644 --- a/lib/equip-class/table/equipClass-table-toolbar-actions.tsx +++ b/lib/equip-class/table/equipClass-table-toolbar-actions.tsx @@ -2,35 +2,66 @@ import * as React from "react" import { type Table } from "@tanstack/react-table" -import { Download, RefreshCcw, Upload } from "lucide-react" -import { toast } from "sonner" +import { Download, RefreshCcw } from "lucide-react" import { exportTableToExcel } from "@/lib/export" import { Button } from "@/components/ui/button" -import { TagClasses } from "@/db/schema/vendorData" - - +import { ExtendedTagClasses } from "../validation" +import { toast } from "sonner" interface ItemsTableToolbarActionsProps { - table: Table + table: Table } export function EquipClassTableToolbarActions({ table }: ItemsTableToolbarActionsProps) { - // 파일 input을 숨기고, 버튼 클릭 시 참조해 클릭하는 방식 - const fileInputRef = React.useRef(null) + const [isLoading, setIsLoading] = React.useState(false) + + const syncObjectClasses = async () => { + try { + setIsLoading(true) + // API 엔드포인트 호출 + const response = await fetch('/api/cron/object-classes') + if (!response.ok) { + const errorData = await response.json() + throw new Error(errorData.error || 'Failed to sync object classes') + } + + const data = await response.json() + + // 성공 메시지 표시 + toast.success( + `object classes synced successfully! ${data.result.items} items processed.` + ) + + // 페이지 새로고침으로 테이블 데이터 업데이트 + window.location.reload() + } catch (error) { + console.error('Error syncing object classes:', error) + toast.error( + error instanceof Error + ? error.message + : 'An error occurred while syncing object classes' + ) + } finally { + setIsLoading(false) + } + } return (
- {/** 4) Export 버튼 */} {/** 4) Export 버튼 */} @@ -39,7 +70,7 @@ export function EquipClassTableToolbarActions({ table }: ItemsTableToolbarAction size="sm" onClick={() => exportTableToExcel(table, { - filename: "tasks", + filename: "Equip Class", excludeColumns: ["select", "actions"], }) } -- cgit v1.2.3