mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
938 B
36 lines
938 B
import {useNuxtApp} from "#app"; |
|
import {Api, TableType} from "nocodb-sdk"; |
|
import {useUser} from "~/composables/user"; |
|
|
|
export const useProject = () => { |
|
const {$api}: { $api: Api<any> } = useNuxtApp() as any |
|
const {user} = useUser() |
|
|
|
const project = useState<{ id?: string, title?: string }>('project', null) |
|
const tables = useState<Array<TableType>>('tables', null) |
|
|
|
const loadTables = async () => { |
|
const tablesResponse = await $api.dbTable.list(project?.value?.id, {}, { |
|
headers: { |
|
'xc-auth': user.token |
|
} |
|
}) |
|
|
|
console.log(tablesResponse) |
|
tables.value = tablesResponse.list |
|
} |
|
|
|
const loadProject = async (projectId:string) => { |
|
const projectResponse = await $api.project.read(projectId, { |
|
headers: { |
|
'xc-auth': user.token |
|
} |
|
}) |
|
|
|
console.log(projectResponse) |
|
project.value = projectResponse |
|
} |
|
|
|
|
|
return {project, tables, loadProject, loadTables} |
|
}
|
|
|