diff --git a/packages/nc-gui/components/template/Editor.vue b/packages/nc-gui/components/template/Editor.vue index 770109fd9a..a6be949176 100644 --- a/packages/nc-gui/components/template/Editor.vue +++ b/packages/nc-gui/components/template/Editor.vue @@ -501,12 +501,16 @@ async function importTemplate() { } } } - const createdTable = await $api.base.tableCreate(project?.value?.id as string, baseId as string, { - table_name: table.table_name, - // leave title empty to get a generated one based on table_name - title: '', - columns: table.columns || [], - }) + const createdTable = await $api.base.tableCreate( + project.value?.id as string, + (baseId || project.value?.bases?.[0].id)!, + { + table_name: table.table_name, + // leave title empty to get a generated one based on table_name + title: '', + columns: table.columns || [], + }, + ) table.id = createdTable.id table.title = createdTable.title diff --git a/packages/nc-gui/composables/useTable.ts b/packages/nc-gui/composables/useTable.ts index c6638a3b8a..1b90832e07 100644 --- a/packages/nc-gui/composables/useTable.ts +++ b/packages/nc-gui/composables/useTable.ts @@ -49,7 +49,7 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void, baseId? }) try { - const tableMeta = await $api.base.tableCreate(project?.value?.id as string, baseId as string, { + const tableMeta = await $api.base.tableCreate(project?.value?.id as string, (baseId || project?.value?.bases?.[0].id)!, { ...table, columns, })