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"
16 name="number-of-stations"
17 placeholder="number of stations"
25 .addChargingStations(state.template, state.numberOfStations)
27 $toast.success('Charging stations successfully added')
29 .catch((error: Error) => {
30 $toast.error('Error at adding charging stations')
31 console.error('Error at adding charging stations:', error)
34 $router.push({ name: 'charging-stations' })
41 <Button id="action-button" @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
44 <script setup lang="ts">
45 import { getCurrentInstance, onMounted, reactive } from 'vue'
46 import { useToast } from 'vue-toast-notification'
47 import Button from '@/components/buttons/Button.vue'
48 import type { ResponsePayload } from '@/types'
50 const state = reactive({
56 const app = getCurrentInstance()
57 const uiClient = app?.appContext.config.globalProperties.$uiClient
59 const $toast = useToast()
64 .then((response: ResponsePayload) => {
65 if (app != null && app.appContext.config.globalProperties.$templates == null) {
66 app.appContext.config.globalProperties.$templates = response.templates
69 .catch((error: Error) => {
70 $toast.error('Error at fetching charging station templates')
71 console.error('Error at fetching charging station templates:', error)