refactor: cleanup vue.js global properties usage
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / actions / StartTransaction.vue
CommitLineData
c317ae3e 1<template>
916f0920
JB
2 <h1 id="action">Start Transaction</h1>
3 <h2>{{ chargingStationId }}</h2>
4 <h3>Connector {{ connectorId }}</h3>
c317ae3e 5 <p>Scan RFID tag:</p>
d18fc1e3 6 <input id="idtag" v-model.trim="state.idTag" type="text" name="idtag" placeholder="RFID tag" />
c317ae3e
JB
7 <br />
8 <Button
14ee627a 9 id="action-button"
c317ae3e
JB
10 @click="
11 () => {
7e315430 12 $uiClient
4b10e4f9 13 .startTransaction(hashId, convertToInt(connectorId), state.idTag)
cea23fa0
JB
14 .then(() => {
15 $toast.success('Transaction successfully started')
16 })
c317ae3e 17 .catch((error: Error) => {
cea23fa0 18 $toast.error('Error at starting transaction')
c317ae3e
JB
19 console.error('Error at starting transaction:', error)
20 })
21 .finally(() => {
22 $router.push({ name: 'charging-stations' })
23 })
24 }
25 "
c317ae3e 26 >
1eb5f592
JB
27 Start Transaction
28 </Button>
c317ae3e
JB
29</template>
30
31<script setup lang="ts">
7e315430 32import { ref } from 'vue'
c317ae3e 33import Button from '@/components/buttons/Button.vue'
093ca832 34import { convertToInt } from '@/composables'
c317ae3e 35
4b10e4f9 36defineProps<{
c317ae3e
JB
37 hashId: string
38 chargingStationId: string
39 connectorId: string
40}>()
41
cf959670 42const state = ref<{ idTag: string }>({
c317ae3e
JB
43 idTag: ''
44})
c317ae3e
JB
45</script>
46
47<style>
48#idtag {
49 text-align: center;
50}
51</style>