diff --git a/packages/nc-gui/components/shared-view/Grid.vue b/packages/nc-gui/components/shared-view/Grid.vue index 0a6b84409a..b35c1fbbbb 100644 --- a/packages/nc-gui/components/shared-view/Grid.vue +++ b/packages/nc-gui/components/shared-view/Grid.vue @@ -6,7 +6,7 @@ import { ActiveViewInj, FieldsInj, IsPublicInj, MetaInj, ReadonlyInj, ReloadView const { sharedView, meta, sorts, nestedFilters } = useSharedView() const { signedIn } = useGlobal() -const { loadProject } = useProject(meta?.value.project_id) +const { loadProject } = useProject((meta.value as any)?.project_id) const reloadEventHook = createEventHook() diff --git a/packages/nc-gui/composables/useSharedView.ts b/packages/nc-gui/composables/useSharedView.ts index 1b7a7da01d..0fd6f9191b 100644 --- a/packages/nc-gui/composables/useSharedView.ts +++ b/packages/nc-gui/composables/useSharedView.ts @@ -1,4 +1,4 @@ -import type { ExportTypes, FilterType, PaginatedType, SortType, TableType, ViewType } from 'nocodb-sdk' +import type { ExportTypes, FilterType, PaginatedType, RequestParams, SortType, TableType, ViewType } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk' import { useNuxtApp } from '#app' @@ -8,15 +8,15 @@ export function useSharedView() { () => [], ) const paginationData = useState('paginationData', () => ({ page: 1, pageSize: 25 })) - const sharedView = useState('sharedView') + const sharedView = useState('sharedView', () => undefined) const sorts = useState('sorts', () => []) - const password = useState('password') + const password = useState('password', () => undefined) const allowCSVDownload = useState('allowCSVDownload', () => false) + const meta = useState('meta', () => undefined) - const meta = useState('meta') const formColumns = computed( () => - meta.value.columns + meta.value?.columns ?.filter( (f: Record) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup && f.uidt !== UITypes.Formula, @@ -29,7 +29,9 @@ export function useSharedView() { const { setMeta } = useMetas() const loadSharedView = async (viewId: string, localPassword: string | undefined = undefined) => { - const viewMeta = await $api.public.sharedViewMetaGet(viewId, { + if (!meta.value) return + + const viewMeta: Record = await $api.public.sharedViewMetaGet(viewId, { headers: { 'xc-password': localPassword ?? password.value, }, @@ -42,7 +44,7 @@ export function useSharedView() { meta.value = { ...viewMeta.model } let order = 1 - meta.value.columns = [...viewMeta.model.columns] + meta.value!.columns = [...viewMeta.model.columns] .filter((c) => c.show) .map((c) => ({ ...c, order: order++ })) .sort((a, b) => a.order - b.order) @@ -58,7 +60,7 @@ export function useSharedView() { const pageSize = paginationData.value.pageSize || 25 const { data } = await $api.public.dataList( - sharedView?.value?.uuid, + (sharedView.value as any)?.uuid, { offset: (page - 1) * pageSize, filterArrJson: JSON.stringify(nestedFilters.value), @@ -80,7 +82,7 @@ export function useSharedView() { type: ExportTypes.EXCEL | ExportTypes.CSV, responseType: 'base64' | 'blob', ) => { - return await $api.public.csvExport(sharedView.value?.uuid, type, { + return await $api.public.csvExport((sharedView.value as any)?.uuid, type, { format: responseType as any, query: { fields: fields.map((field) => field.title), @@ -92,7 +94,7 @@ export function useSharedView() { headers: { 'xc-password': password.value, }, - }) + } as RequestParams) } return {