mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-11 21:29:50 +02:00
Use nuxtopenfetch
This commit is contained in:
@@ -15,20 +15,22 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ApiModel } from '#nuxt-api-party';
|
||||
import type { components } from '#open-fetch-schemas/api';
|
||||
type CreateLibraryRecord = components['schemas']['CreateLibraryRecord'];
|
||||
|
||||
const name = ref('');
|
||||
const path = ref('');
|
||||
|
||||
const model = computed((): ApiModel<'CreateLibraryRecord'> => {
|
||||
const model: ComputedRef = computed((): CreateLibraryRecord => {
|
||||
return { basePath: path.value, libraryName: name.value };
|
||||
});
|
||||
|
||||
const busy = ref(false);
|
||||
const onAddClick = async () => {
|
||||
if (!model.value) return;
|
||||
busy.value = true;
|
||||
await $api('/v2/FileLibrary', { method: 'PUT', body: model.value })
|
||||
.then(() => refreshNuxtData(Keys.FileLibraries))
|
||||
await useApi('/v2/FileLibrary', { method: 'PUT', body: model.value })
|
||||
.then(() => refreshNuxtData(FetchKeys.FileLibraries))
|
||||
.finally(() => (busy.value = false));
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user