From 1e2a1e2663bd3ed492bfa2b86a4957a1dd8d4e64 Mon Sep 17 00:00:00 2001 From: axolotle Date: Tue, 13 Aug 2024 00:32:50 +0200 Subject: [PATCH] refactor: rework async UserCreate --- app/src/views/user/UserCreate.vue | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/src/views/user/UserCreate.vue b/app/src/views/user/UserCreate.vue index 74e76fab..df34c15e 100644 --- a/app/src/views/user/UserCreate.vue +++ b/app/src/views/user/UserCreate.vue @@ -6,7 +6,6 @@ import { useRouter } from 'vue-router' import api from '@/api' import { useDomains, useUsersAndGroups } from '@/composables/data' import { useForm } from '@/composables/form' -import { useInitialQueries } from '@/composables/useInitialQueries' import { alphalownumdot_, minLength, @@ -20,13 +19,12 @@ import type { FieldProps, FormFieldDict } from '@/types/form' const { t } = useI18n() const router = useRouter() -const { loading } = useInitialQueries( - [ - { uri: 'users', cachePath: 'users' }, - { uri: 'domains', cachePath: 'domains' }, - ], - { onQueriesResponse }, -) + +await api.fetchAll([ + { uri: 'users', cachePath: 'users' }, + { uri: 'domains', cachePath: 'domains' }, +]) + const { usernames } = useUsersAndGroups() const { domainsAsChoices, mainDomain } = useDomains() @@ -105,10 +103,6 @@ const fields = { const { v, onSubmit } = useForm(form, fields) -function onQueriesResponse() { - form.value.domain = mainDomain.value -} - const onUserCreate = onSubmit(async (onError) => { const data = await formatForm(form) api @@ -126,7 +120,7 @@ const onUserCreate = onSubmit(async (onError) => { - +