import { Api } from "nocodb-sdk"; import type { ComputedRef, Ref } from "vue"; import type { PaginatedType, TableType } from "nocodb-sdk"; import { useNuxtApp } from "#app"; import useProject from "~/composables/useProject"; const formatData = (list: Array>) => list.map(row => ({ row: { ...row }, oldRow: { ...row }, rowMeta: {} })); export default (meta: Ref | ComputedRef | undefined) => { const data = ref>>(); const formattedData = ref; oldRow: Record }>>(); const paginationData = ref(); const { project } = useProject(); const { $api } = useNuxtApp(); const loadData = async (params: Parameters["dbTableRow"]["list"]>[3] = {}) => { if(!project?.value?.id || !meta?.value?.id) return const response = await $api.dbTableRow.list( "noco", project.value.id, meta.value.id, params ); data.value = response.list; formattedData.value = formatData(response.list); }; return { data, loadData, paginationData, formattedData }; };