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"
24 .addChargingStations(state.template, state.numberOfStations)
26 $toast.success('Charging stations successfully added')
28 .catch((error: Error) => {
29 $toast.error('Error at adding charging stations')
30 console.error('Error at adding charging stations:', error)
33 $router.push({ name: 'charging-stations' })
40 <Button @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
43 <script setup lang="ts">
44 import { getCurrentInstance, onMounted, reactive } from 'vue'
45 import { useToast } from 'vue-toast-notification'
46 import Button from '@/components/buttons/Button.vue'
47 import type { ResponsePayload } from '@/types'
49 const state = reactive({
55 const app = getCurrentInstance()
56 const uiClient = app?.appContext.config.globalProperties.$uiClient
58 const $toast = useToast()
63 .then((response: ResponsePayload) => {
64 if (app != null && app.appContext.config.globalProperties.$templates == null) {
65 app.appContext.config.globalProperties.$templates = response.templates
68 .catch((error: Error) => {
69 $toast.error('Error at fetching charging station templates')
70 console.error('Error at fetching charging station templates:', error)