summaryrefslogtreecommitdiff
path: root/lib/tag-numbering/table
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tag-numbering/table')
-rw-r--r--lib/tag-numbering/table/tagNumbering-table-toolbar-actions.tsx43
-rw-r--r--lib/tag-numbering/table/tagNumbering-table.tsx11
2 files changed, 49 insertions, 5 deletions
diff --git a/lib/tag-numbering/table/tagNumbering-table-toolbar-actions.tsx b/lib/tag-numbering/table/tagNumbering-table-toolbar-actions.tsx
index 1a7af254..7a14817f 100644
--- a/lib/tag-numbering/table/tagNumbering-table-toolbar-actions.tsx
+++ b/lib/tag-numbering/table/tagNumbering-table-toolbar-actions.tsx
@@ -16,10 +16,40 @@ interface ItemsTableToolbarActionsProps {
}
export function TagNumberingTableToolbarActions({ table }: ItemsTableToolbarActionsProps) {
- // 파일 input을 숨기고, 버튼 클릭 시 참조해 클릭하는 방식
- const fileInputRef = React.useRef<HTMLInputElement>(null)
+ const [isLoading, setIsLoading] = React.useState(false)
+ const syncTags = 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 tag numberings')
+ }
+
+ const data = await response.json()
+
+ // 성공 메시지 표시
+ toast.success(
+ `tag numberings synced successfully! ${data.result.items} items processed.`
+ )
+
+ // 페이지 새로고침으로 테이블 데이터 업데이트
+ window.location.reload()
+ } catch (error) {
+ console.error('Error syncing tag numberings:', error)
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : 'An error occurred while syncing tag numberings'
+ )
+ } finally {
+ setIsLoading(false)
+ }
+ }
return (
<div className="flex items-center gap-2">
@@ -28,9 +58,14 @@ export function TagNumberingTableToolbarActions({ table }: ItemsTableToolbarActi
variant="samsung"
size="sm"
className="gap-2"
+ onClick={syncTags}
+ disabled={isLoading}
>
- <RefreshCcw className="size-4" aria-hidden="true" />
- <span className="hidden sm:inline">Get Tag Numbering</span>
+
+ <RefreshCcw className={`size-4 ${isLoading ? 'animate-spin' : ''}`} aria-hidden="true" />
+ <span className="hidden sm:inline">
+ {isLoading ? 'Syncing...' : 'Get Tag Numbering'}
+ </span>
</Button>
{/** 4) Export 버튼 */}
diff --git a/lib/tag-numbering/table/tagNumbering-table.tsx b/lib/tag-numbering/table/tagNumbering-table.tsx
index 7997aad9..6ca46e05 100644
--- a/lib/tag-numbering/table/tagNumbering-table.tsx
+++ b/lib/tag-numbering/table/tagNumbering-table.tsx
@@ -32,7 +32,6 @@ export function TagNumberingTable({ promises }: ItemsTableProps) {
const [{ data, pageCount }] =
React.use(promises)
-
const [rowAction, setRowAction] =
React.useState<DataTableRowAction<ViewTagSubfields> | null>(null)
@@ -68,6 +67,16 @@ export function TagNumberingTable({ promises }: ItemsTableProps) {
*/
const advancedFilterFields: DataTableAdvancedFilterField<ViewTagSubfields>[] = [
{
+ id: "projectCode",
+ label: "Project Code",
+ type: "text",
+ },
+ {
+ id: "projectName",
+ label: "Project Name",
+ type: "text",
+ },
+ {
id: "tagTypeCode",
label: "Tag Type Code",
type: "text",