Fixed price field and added timeout for creation toast

main
Eloi Zalczer 2024-06-19 11:00:43 +02:00
parent 5e5e7943a3
commit 822ef4510a
3 changed files with 28 additions and 8 deletions

View File

@ -0,0 +1,10 @@
/* we will explain what these classes do next! */
.toast-fade-enter-active,
.toast-fade-leave-active {
transition: opacity 0.5s ease;
}
.toast-fade-enter-from,
.toast-fade-leave-to {
opacity: 0;
}

View File

@ -35,7 +35,7 @@ const submit = handleSubmit((values) => {
try { try {
pb.collection("restaurants").create({ pb.collection("restaurants").create({
name: values.name, name: values.name,
price_range: values.price, price: values.price,
tags: tags, tags: tags,
latitude: position.value?.lat, latitude: position.value?.lat,
longitude: position.value?.lng, longitude: position.value?.lng,

View File

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import "@/assets/form.css"; import "@/assets/form.css";
import "@/assets/toast.css";
import RestaurantsMap from "../components/RestaurantsMap.vue"; import RestaurantsMap from "../components/RestaurantsMap.vue";
import { ref } from "vue"; import { ref } from "vue";
@ -15,27 +16,36 @@ function onMapClicked(latlng) {
createRestaurantModal.value?.show(); createRestaurantModal.value?.show();
} }
function resetToast() {
successMessage.value = undefined;
errorMessage.value = undefined;
}
function onRestaurantCreationSucceeded(message: string) { function onRestaurantCreationSucceeded(message: string) {
successMessage.value = message; successMessage.value = message;
errorMessage.value = undefined; errorMessage.value = undefined;
createRestaurantModal.value?.hide(); createRestaurantModal.value?.hide();
setTimeout(resetToast, 5000);
} }
function onRestaurantCreationFailed(message: string) { function onRestaurantCreationFailed(message: string) {
successMessage.value = undefined; successMessage.value = undefined;
errorMessage.value = message; errorMessage.value = message;
createRestaurantModal.value?.hide(); createRestaurantModal.value?.hide();
setTimeout(resetToast, 5000);
} }
</script> </script>
<template> <template>
<div class="toast toast-top toast-end"> <div class="toast toast-top toast-end z-[10000]">
<Transition name="toast-fade">
<div v-if="errorMessage" class="alert alert-error"> <div v-if="errorMessage" class="alert alert-error">
<span>{{ errorMessage }}</span> <span>{{ errorMessage }}</span>
</div> </div>
<div v-if="successMessage" class="alert alert-success"> <div v-else-if="successMessage" class="alert alert-success">
<span>{{ successMessage }}</span> <span>{{ successMessage }}</span>
</div> </div>
</Transition>
</div> </div>
<RestaurantsMap @clicked="onMapClicked" /> <RestaurantsMap @clicked="onMapClicked" />