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.
24 lines
647 B
24 lines
647 B
2 years ago
|
import type { ProjectType, TableType } from "nocodb-sdk";
|
||
|
import { useNuxtApp } from "#app";
|
||
3 years ago
|
|
||
2 years ago
|
export default () => {
|
||
2 years ago
|
const { $api } = useNuxtApp();
|
||
3 years ago
|
|
||
2 years ago
|
const project = useState<ProjectType>("project");
|
||
|
const tables = useState<Array<TableType>>("tables");
|
||
3 years ago
|
|
||
|
const loadTables = async () => {
|
||
2 years ago
|
if (project.value.id) {
|
||
2 years ago
|
const tablesResponse = await $api.dbTable.list(project.value.id);
|
||
3 years ago
|
|
||
2 years ago
|
if (tablesResponse.list) tables.value = tablesResponse.list;
|
||
2 years ago
|
}
|
||
2 years ago
|
};
|
||
3 years ago
|
|
||
3 years ago
|
const loadProject = async (projectId: string) => {
|
||
2 years ago
|
project.value = await $api.project.read(projectId);
|
||
|
};
|
||
3 years ago
|
|
||
2 years ago
|
return { project, tables, loadProject, loadTables };
|
||
|
};
|