refactor(ui): refine action forms
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / actions / AddChargingStations.vue
index 387d8a1a7110860e55a954878bc6b874403e21ed..667edb6cbfa465f923f308621004aac351d9e3fb 100644 (file)
@@ -2,6 +2,7 @@
   <h2>Action Add Charging Stations</h2>
   <p>Template:</p>
   <select v-if="state.ready" v-model="state.template">
+    <option disabled value="">Please select a template</option>
     <option v-for="template in app?.appContext.config.globalProperties.$templates">
       {{ template }}
     </option>
       () => {
         uiClient
           .addChargingStations(state.template, state.numberOfStations)
+          .then(() => {
+            $toast.success('Charging stations successfully added')
+          })
           .catch((error: Error) => {
-            // TODO: add code for UI notifications or other error handling logic
+            $toast.error('Error at adding charging stations')
             console.error('Error at adding charging stations:', error)
           })
           .finally(() => {
@@ -36,6 +40,7 @@
 
 <script setup lang="ts">
 import { getCurrentInstance, onMounted, reactive } from 'vue'
+import { useToast } from 'vue-toast-notification'
 import Button from '@/components/buttons/Button.vue'
 import type { ResponsePayload } from '@/types'
 
@@ -48,6 +53,8 @@ const state = reactive({
 const app = getCurrentInstance()
 const uiClient = app?.appContext.config.globalProperties.$uiClient
 
+const $toast = useToast()
+
 onMounted(() => {
   uiClient
     .listTemplates()
@@ -57,7 +64,7 @@ onMounted(() => {
       }
     })
     .catch((error: Error) => {
-      // TODO: add code for UI notifications or other error handling logic
+      $toast.error('Error at fetching charging station templates')
       console.error('Error at fetching charging station templates:', error)
     })
     .finally(() => {