refactor(ui): use bootstrap theme for toast notifications
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / actions / AddChargingStations.vue
index 164518b1f70e7fd8590d1b9b6dc1ab63998f4da9..7a2f8a59ef86cc8c727a5f587c7cbd5e55558557 100644 (file)
@@ -11,7 +11,7 @@
     id="number-of-stations"
     v-model="state.numberOfStations"
     type="text"
-    name="number-of-station"
+    name="number-of-stations"
     placeholder="number of stations"
   />
   <br />
       () => {
         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,7 +39,9 @@
 
 <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'
 
 const state = reactive({
   ready: false,
@@ -47,6 +52,8 @@ const state = reactive({
 const app = getCurrentInstance()
 const uiClient = app?.appContext.config.globalProperties.$uiClient
 
+const $toast = useToast()
+
 onMounted(() => {
   uiClient
     .listTemplates()
@@ -56,7 +63,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(() => {