2 <h1 id="action">Action</h1>
3 <h2>Add Charging Stations</h2>
5 <select v-show="state.ready" v-model="state.template">
6 <option disabled value="">Please select a template</option>
7 <option v-for="template in app?.appContext.config.globalProperties.$templates">
11 <p>Number of stations:</p>
13 id="number-of-stations"
14 v-model="state.numberOfStations"
17 name="number-of-stations"
18 placeholder="number of stations"
24 <input v-model="state.autoStart" type="checkbox" true-value="true" false-value="false" />
33 .addChargingStations(state.template, state.numberOfStations, {
34 autoStart: convertToBoolean(state.autoStart)
37 $toast.success('Charging stations successfully added')
39 .catch((error: Error) => {
40 $toast.error('Error at adding charging stations')
41 console.error('Error at adding charging stations:', error)
44 $router.push({ name: 'charging-stations' })
51 <Button id="action-button" @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
54 <script setup lang="ts">
55 import { getCurrentInstance, onMounted, reactive } from 'vue'
56 import { useToast } from 'vue-toast-notification'
57 import Button from '@/components/buttons/Button.vue'
58 import type { ResponsePayload } from '@/types'
59 import { convertToBoolean } from '@/composables'
61 const state = reactive({
68 const app = getCurrentInstance()
69 const uiClient = app?.appContext.config.globalProperties.$uiClient
71 const $toast = useToast()
76 .then((response: ResponsePayload) => {
77 if (app != null && app.appContext.config.globalProperties.$templates == null) {
78 app.appContext.config.globalProperties.$templates = response.templates
81 .catch((error: Error) => {
82 $toast.error('Error at fetching charging station templates')
83 console.error('Error at fetching charging station templates:', error)