summaryrefslogtreecommitdiff
path: root/lib/tags
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-05-28 00:32:31 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-05-28 00:32:31 +0000
commit20800b214145ee6056f94ca18fa1054f145eb977 (patch)
treeb5c8b27febe5b126e6d9ece115ea05eace33a020 /lib/tags
parente1344a5da1aeef8fbf0f33e1dfd553078c064ccc (diff)
(대표님) lib 파트 커밋
Diffstat (limited to 'lib/tags')
-rw-r--r--lib/tags/service.ts14
-rw-r--r--lib/tags/table/tag-table.tsx4
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/tags/service.ts b/lib/tags/service.ts
index e66c0438..307a4774 100644
--- a/lib/tags/service.ts
+++ b/lib/tags/service.ts
@@ -171,8 +171,8 @@ export async function createTag(
for (const formMapping of formMappings) {
// 4-1) 이미 존재하는 폼인지 확인
const existingForm = await tx
- .select({ id: forms.id })
- .from(forms)
+ .select({ id: forms.id, im: forms.im }) // im 필드 추가로 조회
+ .from(forms)
.where(
and(
eq(forms.contractItemId, selectedPackageId),
@@ -185,6 +185,16 @@ export async function createTag(
if (existingForm.length > 0) {
// 이미 존재하면 해당 ID 사용
formId = existingForm[0].id
+
+ if (existingForm[0].im !== true) {
+ await tx
+ .update(forms)
+ .set({ im: true })
+ .where(eq(forms.id, formId))
+
+ console.log(`Form ${formId} updated with im: true`)
+ }
+
createdOrExistingForms.push({
id: formId,
formCode: formMapping.formCode,
diff --git a/lib/tags/table/tag-table.tsx b/lib/tags/table/tag-table.tsx
index 62f0a7c5..1986d933 100644
--- a/lib/tags/table/tag-table.tsx
+++ b/lib/tags/table/tag-table.tsx
@@ -19,6 +19,8 @@ import { TagsTableToolbarActions } from "./tags-table-toolbar-actions"
import { TagsTableFloatingBar } from "./tags-table-floating-bar"
import { getTags } from "../service"
import { UpdateTagSheet } from "./update-tag-sheet"
+import { useAtomValue } from 'jotai'
+import { selectedModeAtom } from '@/atoms'
// 여기서 받은 `promises`로부터 태그 목록을 가져와 상태를 세팅
// 예: "selectedPackageId"는 props로 전달
@@ -30,6 +32,7 @@ interface TagsTableProps {
export function TagsTable({ promises, selectedPackageId }: TagsTableProps) {
// 1) 데이터를 가져옴 (server component -> use(...) pattern)
const [{ data, pageCount }] = React.use(promises)
+ const selectedMode = useAtomValue(selectedModeAtom)
const [rowAction, setRowAction] = React.useState<DataTableRowAction<Tag> | null>(null)
@@ -126,6 +129,7 @@ export function TagsTable({ promises, selectedPackageId }: TagsTableProps) {
table={table}
selectedPackageId={selectedPackageId}
tableData={data} // <-- pass current data
+ selectedMode={selectedMode}
/>
</DataTableAdvancedToolbar>
</DataTable>