Fixed hardcoded world id for calendar creation
This commit is contained in:
@@ -41,7 +41,7 @@ function handleClose() {
|
|||||||
<PhX size="20" />
|
<PhX size="20" />
|
||||||
</UiButton>
|
</UiButton>
|
||||||
|
|
||||||
<CalendarFormCreate @on-changed-name="onChangedName" @on-close="handleClose" />
|
<CalendarFormCreate v-if="world.id" :world-id="world.id" @on-changed-name="onChangedName" @on-close="handleClose" />
|
||||||
</UiAlertDialogContent>
|
</UiAlertDialogContent>
|
||||||
</UiAlertDialog>
|
</UiAlertDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
import type { Calendar } from "~/models/CalendarConfig";
|
import type { Calendar } from "~/models/CalendarConfig";
|
||||||
import { PhAlarm, PhCalendarDots, PhCircleNotch, PhWrench } from "@phosphor-icons/vue";
|
import { PhAlarm, PhCalendarDots, PhCircleNotch, PhWrench } from "@phosphor-icons/vue";
|
||||||
|
|
||||||
const defaultSkeleton: Calendar = { name: "", today: { day: 1, month: 0, year: 0 }, months: [], events: [], state: "draft", color: "white" }
|
const props = defineProps<{
|
||||||
|
worldId: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const defaultSkeleton: Calendar = { name: "", today: { day: 1, month: 0, year: 0 }, months: [], events: [], categories: [], state: "draft", color: "white" }
|
||||||
const calendarSkeleton = ref<Calendar>({ ...defaultSkeleton })
|
const calendarSkeleton = ref<Calendar>({ ...defaultSkeleton })
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -38,16 +42,18 @@ const validSkeleton = computed(() => validSkeletonGeneral.value && validSkeleton
|
|||||||
const isCreatingCalendar = ref<boolean>(false)
|
const isCreatingCalendar = ref<boolean>(false)
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
isCreatingCalendar.value = true
|
||||||
isCreatingCalendar.value = true
|
|
||||||
await $fetch("/api/calendars/create", { method: "POST", body: { ...calendarSkeleton.value, worldId: 1 } })
|
|
||||||
|
|
||||||
emit("on-close")
|
const { error } = await tryCatch($fetch("/api/calendars/create", { method: "POST", body: { ...calendarSkeleton.value, worldId: props.worldId } }))
|
||||||
} catch (err) {
|
|
||||||
console.log(err)
|
if (error) {
|
||||||
} finally {
|
console.log(error)
|
||||||
isCreatingCalendar.value = false
|
isCreatingCalendar.value = false
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit("on-close")
|
||||||
|
isCreatingCalendar.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user