From ae45ad12a5840348550078cb62042e813a3492b5 Mon Sep 17 00:00:00 2001
From: Vidhu Kant Sharma <vidhukant@vidhukant.com>
Date: Sun, 3 Dec 2023 22:32:59 +0530
Subject: updating brands table upon addition/deletion

---
 src/components/new_brand.vue | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'src/components/new_brand.vue')

diff --git a/src/components/new_brand.vue b/src/components/new_brand.vue
index 8b4893a..77d83da 100644
--- a/src/components/new_brand.vue
+++ b/src/components/new_brand.vue
@@ -1,8 +1,10 @@
 <script setup lang="js">
-import { ref } from 'vue'
+import { ref, toRaw } from 'vue'
 import axios from 'axios'
 import { useToast } from 'vue-toast-notification'
 
+const emit = defineEmits(["added"])
+
 const toast = useToast({
   position: 'top-right'
 })
@@ -12,12 +14,13 @@ const brandName = ref('')
 const submit = async (e) => {
   e.preventDefault()
   try {
-    const res = await axios.post('/brand', {
-      name: brandName._value
+    await axios.post('/brand', {
+      name: toRaw(brandName.value)
     })
+
     toast.success('Successfully added a new brand.')
+    emit("added")
     brandName.value = ''
-    // TODO: refresh items list
   } catch (err) {
     toast.error('An unhandled exception occoured. Please check logs')
     console.error(err)
-- 
cgit v1.2.3

