fix login spaces
This commit is contained in:
@@ -10,13 +10,17 @@ import InputText from "primevue/inputtext";
|
||||
import Textarea from "primevue/textarea";
|
||||
import Button from "primevue/button";
|
||||
import DatePicker from "primevue/datepicker";
|
||||
import {useToast} from "primevue/usetoast";
|
||||
import LoadingView from "@/components/LoadingView.vue";
|
||||
|
||||
const emits = defineEmits(['space-created', 'close-modal', 'error-space-creation'])
|
||||
const toast = useToast()
|
||||
|
||||
|
||||
const spaceName = ref('')
|
||||
const spaceDescription = ref('')
|
||||
const createCategories = ref(true)
|
||||
const loading = ref(false)
|
||||
|
||||
const cancel = () => {
|
||||
resetForm()
|
||||
@@ -28,11 +32,22 @@ const createSpace = async () => {
|
||||
space.name = spaceName.value
|
||||
space.description = spaceDescription.value
|
||||
space.createCategories = createCategories.value
|
||||
|
||||
try {
|
||||
await createSpaceRequest(space).then((res) => {
|
||||
resetForm()
|
||||
emits("space-created", res)
|
||||
})
|
||||
loading.value = true
|
||||
await createSpaceRequest(space)
|
||||
.then((res) => {
|
||||
resetForm()
|
||||
loading.value = false
|
||||
emits("space-created", res)
|
||||
}).catch((err) => {
|
||||
toast.add({
|
||||
severity: 'error',
|
||||
summary: 'Ошибка!',
|
||||
detail: err.response?.data?.message || 'Ошибка при создании пространства',
|
||||
life: 3000
|
||||
});
|
||||
})
|
||||
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
@@ -46,8 +61,8 @@ const resetForm = () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div class="flex flex-col gap-4 mt-1">
|
||||
<LoadingView v-if="loading" halfscreen/>
|
||||
<div v-else class="flex flex-col gap-4 mt-1">
|
||||
<FloatLabel variant="on" class="w-full">
|
||||
<label for="name">Название</label>
|
||||
<InputText v-model="spaceName" id="name" class="w-full"/>
|
||||
|
||||
Reference in New Issue
Block a user