2 <h2>Action Add Charging Stations</h2>
4 <select v-if="state.ready" v-model="state.template">
5 <option disabled value="">Please select a template</option>
6 <option v-for="template in app?.appContext.config.globalProperties.$templates">
10 <p>Number of stations:</p>
12 id="number-of-stations"
13 v-model="state.numberOfStations"
15 name="number-of-stations"
16 placeholder="number of stations"
23 .addChargingStations(state.template, state.numberOfStations)
25 $toast.success('Charging stations successfully added')
27 .catch((error: Error) => {
28 $toast.error('Error at adding charging stations')
29 console.error('Error at adding charging stations:', error)
32 $router.push({ name: 'charging-stations' })
36 >Add Charging Stations</Button
38 <Button @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
41 <script setup lang="ts">
42 import { getCurrentInstance, onMounted, reactive } from 'vue'
43 import { useToast } from 'vue-toast-notification'
44 import Button from '@/components/buttons/Button.vue'
45 import type { ResponsePayload } from '@/types'
47 const state = reactive({
53 const app = getCurrentInstance()
54 const uiClient = app?.appContext.config.globalProperties.$uiClient
56 const $toast = useToast()
61 .then((response: ResponsePayload) => {
62 if (app != null && app.appContext.config.globalProperties.$templates == null) {
63 app.appContext.config.globalProperties.$templates = response.templates
66 .catch((error: Error) => {
67 $toast.error('Error at fetching charging station templates')
68 console.error('Error at fetching charging station templates:', error)