feat: preloading, error handing

This commit is contained in:
opbnq-q
2025-03-09 04:25:25 -07:00
parent 9e49d16a43
commit f648b4b171
10 changed files with 112 additions and 76 deletions

View File

@@ -1,18 +1,27 @@
<script setup lang="ts">
import Table from "../table/Table.vue";
import { onMounted, reactive } from "vue";
import { onMounted, reactive, ref } from "vue";
import { getDefaultValues } from "../utils/structs/defaults.util";
import Service from "./author.service.ts";
import type { Scheme } from "../types/scheme.type";
import { Author } from "../../bindings/app/internal/services";
import PostService from "../post/post.service.ts";
import type { Validate } from "../types/validate.type.ts";
const postService = new PostService();
const service = new Service();
onMounted(async () => {
const items = ref<Author[]>([])
async function load() {
(scheme as any).Posts.type!.nested!.values = await postService.readAll();
items.value = await service.readAll();
return items.value;
}
onMounted(async () => {
load()
});
const scheme: Scheme<Author> = reactive({
@@ -44,10 +53,16 @@ const scheme: Scheme<Author> = reactive({
});
const getDefaults = () => getDefaultValues(scheme);
const validate: Validate<Author> = (data, mode): ReturnType<Validate<Author>> => {
return {
status: 'success',
}
}
</script>
<template>
<main class="w-screen h-screen">
<Table :scheme :service :getDefaults></Table>
<Table :scheme :service :get-defaults :validate :items :load></Table>
</main>
</template>