feat(ui): add action success/failure notifications
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / actions / StartTransaction.vue
CommitLineData
c317ae3e
JB
1<template>
2 <h2>Action Start Transaction</h2>
3 <h3>Connector {{ connectorId }} on {{ chargingStationId }}</h3>
4 <p>Scan RFID tag:</p>
5 <input id="idtag" v-model="state.idTag" type="text" name="idtag" placeholder="RFID tag" />
6 <br />
7 <Button
8 @click="
9 () => {
10 uiClient
11 .startTransaction(props.hashId, parseInt(props.connectorId), state.idTag)
cea23fa0
JB
12 .then(() => {
13 $toast.success('Transaction successfully started')
14 })
c317ae3e 15 .catch((error: Error) => {
cea23fa0 16 $toast.error('Error at starting transaction')
c317ae3e
JB
17 console.error('Error at starting transaction:', error)
18 })
19 .finally(() => {
20 $router.push({ name: 'charging-stations' })
21 })
22 }
23 "
24 >Start Transaction</Button
25 >
3916b7ce 26 <Button @click="$router.push({ name: 'charging-stations' })">Cancel</Button>
c317ae3e
JB
27</template>
28
29<script setup lang="ts">
30import { getCurrentInstance, reactive } from 'vue'
31import Button from '@/components/buttons/Button.vue'
32
33const props = defineProps<{
34 hashId: string
35 chargingStationId: string
36 connectorId: string
37}>()
38
39const state = reactive({
40 idTag: ''
41})
42
43const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
44</script>
45
46<style>
47#idtag {
48 text-align: center;
49}
50</style>