blob: e0deb83ccc80001c88d3ad4f623370d2de448357 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<script setup lang="ts">
import { ref } from 'vue'
import axios from 'axios'
import { useToast } from 'vue-toast-notification'
const toast = useToast({
position: 'top-right'
})
const brandName = ref('')
const submit = async (e) => {
e.preventDefault()
try {
const res = await axios.post('/brand', {
name: brandName._value
})
toast.success('Successfully added a new brand.')
brandName.value = ''
// TODO: refresh items list
} catch (err) {
toast.error('An unhandled exception occoured. Please check logs')
console.error(err)
}
}
</script>
<template>
<form class="d-flex align-items-center justify-content-center m-3" v-on:submit="submit">
<div class="form-floating">
<input
id="brand-name-input"
type="text"
class="form-control"
placeholder=""
v-model="brandName"
/>
<label for="brand-name-input">New Brand Name</label>
</div>
<div class="form-floating m-3">
<input type="submit" value="Add New Brand" class="btn btn-primary" />
</div>
</form>
</template>
|