2 <h2>Action Add Charging Stations</h2>
4 <select v-if="state.ready" v-model="state.template">
5 <option v-for="template in app?.appContext.config.globalProperties.$templates">
9 <p>Number of stations:</p>
11 id="number-of-stations"
12 v-model="state.numberOfStations"
14 name="number-of-stations"
15 placeholder="number of stations"
22 .addChargingStations(state.template, state.numberOfStations)
24 $toast.success('Charging stations successfully added')
26 .catch((error: Error) => {
27 $toast.error('Error at adding charging stations')
28 console.error('Error at adding charging stations:', error)
31 $router.push({ name: 'charging-stations' })
35 >Add Charging Stations</Button
37 <Button @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
40 <script setup lang="ts">
41 import { getCurrentInstance, onMounted, reactive } from 'vue'
42 import { useToast } from 'vue-toast-notification'
43 import Button from '@/components/buttons/Button.vue'
44 import type { ResponsePayload } from '@/types'
46 const state = reactive({
52 const app = getCurrentInstance()
53 const uiClient = app?.appContext.config.globalProperties.$uiClient
55 const $toast = useToast()
60 .then((response: ResponsePayload) => {
61 if (app != null && app.appContext.config.globalProperties.$templates == null) {
62 app.appContext.config.globalProperties.$templates = response.templates
65 .catch((error: Error) => {
66 $toast.error('Error at fetching charging station templates')
67 console.error('Error at fetching charging station templates:', error)