Commit e9fccad2 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

remove ;

parent 5b7e2bf2
...@@ -12,17 +12,23 @@ ...@@ -12,17 +12,23 @@
<b-modal id="modal-create" title="create Product" class="modal fade" > <b-modal id="modal-create" title="create Product" class="modal fade" >
<div class="w-full mt-4 p-10"> <div class="w-full mt-4 p-10">
<form > <form >
<label>Name :</label> <label for="input-live">Name :</label>
<input <b-form-input
id="input-live"
type="text" type="text"
class="form-control mb-2" class="form-control mb-2"
placeholder="name" placeholder="name"
aria-describedby="input-live-help input-live-feedback"
v-model="name" v-model="name"
max="255" max="255"
min="1" min="1"
size="sm" :state="nameState"
required trim
/> >
</b-form-input>
<b-form-invalid-feedback id="input-live-feedback">
Enter at least 3 letters
</b-form-invalid-feedback>
<label>Category ID :</label> <label>Category ID :</label>
<b-form-select v-model="category_id"> <b-form-select v-model="category_id">
<option v-for="item in categories" :value="item.id"> <option v-for="item in categories" :value="item.id">
...@@ -389,7 +395,6 @@ export default { ...@@ -389,7 +395,6 @@ export default {
color: "", color: "",
size: "", size: "",
quantity: "", quantity: "",
}, },
], ],
message: [], message: [],
...@@ -416,6 +421,9 @@ export default { ...@@ -416,6 +421,9 @@ export default {
formTitle() { formTitle() {
return this.editedIndex === -1 ? "New Item" : "Edit Item"; return this.editedIndex === -1 ? "New Item" : "Edit Item";
}, },
nameState() {
return this.name.length > 2 ? true : false
}
}, },
watch: { watch: {
dialog(val) { dialog(val) {
...@@ -491,7 +499,7 @@ export default { ...@@ -491,7 +499,7 @@ export default {
.get("http://127.0.0.1:8000/api/categories/") .get("http://127.0.0.1:8000/api/categories/")
.then((response) => (this.categories = response.data.data)) .then((response) => (this.categories = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error)
}); });
}, },
getProducts() { getProducts() {
...@@ -499,7 +507,7 @@ export default { ...@@ -499,7 +507,7 @@ export default {
.get("http://127.0.0.1:8000/api/products/") .get("http://127.0.0.1:8000/api/products/")
.then((response) => (this.products = response.data.data)) .then((response) => (this.products = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error)
}); });
}, },
createProduct() { createProduct() {
...@@ -522,13 +530,13 @@ export default { ...@@ -522,13 +530,13 @@ export default {
}) })
.then(response => { .then(response => {
this.$bvModal.hide('modal-create') this.$bvModal.hide('modal-create')
self.$toast.success('Category created successfully!', { self.$toast.success('Product created successfully!', {
duration: 3000 duration: 3000
}) })
}) })
.catch(errors => { .catch(errors => {
this.$bvModal.hide('modal-create') this.$bvModal.hide('modal-create')
console.log(errors.response.data.message); console.log(errors.response.data.message)
this.message = errors.response.data.message; this.message = errors.response.data.message;
self.$toast.error('something went wrong while trying create!',{ self.$toast.error('something went wrong while trying create!',{
duration: 3000 duration: 3000
...@@ -563,31 +571,31 @@ export default { ...@@ -563,31 +571,31 @@ export default {
"Authorization": this.$auth.$storage.getUniversal("token") "Authorization": this.$auth.$storage.getUniversal("token")
} }
}).then((response) => { }).then((response) => {
return response.json(); return response.json()
}); });
this.sName = resp.data.name; this.sName = resp.data.name
this.sPrice = resp.data.price; this.sPrice = resp.data.price
this.sCategoryId = resp.data.category_id; this.sCategoryId = resp.data.category_id
this.sDescription = resp.data.description; this.sDescription = resp.data.description
this.sStock = resp.data.stock; this.sStock = resp.data.stock
this.sVariants = resp.data.variants; this.sVariants = resp.data.variants
this.sImages = resp.data.images; this.sImages = resp.data.images
console.log(this.sVariants); console.log(this.sVariants)
console.log(this.sImages); console.log(this.sImages)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
this.$bvModal.show('modal-show') this.$bvModal.show('modal-show')
}, },
editProduct(item) { editProduct(item) {
this.$bvModal.show('modal-edit'); this.$bvModal.show('modal-edit')
this.eId = item.id; this.eId = item.id
this.eName = item.name; this.eName = item.name
this.eCategoryId = item.category_id; this.eCategoryId = item.category_id
this.ePrice = item.price; this.ePrice = item.price
this.eStock = item.stock; this.eStock = item.stock
this.eDescription = item.description; this.eDescription = item.description
this.eVariants = item.variants; this.eVariants = item.variants
}, },
updateProduct(ID) { updateProduct(ID) {
const self = this; const self = this;
...@@ -610,7 +618,7 @@ export default { ...@@ -610,7 +618,7 @@ export default {
self.$toast.success('User updated successfully!',{ self.$toast.success('User updated successfully!',{
duration: 3000 duration: 3000
}); });
console.log(response); console.log(response)
}) })
} catch(error){ } catch(error){
console.log(error) console.log(error)
...@@ -642,7 +650,6 @@ export default { ...@@ -642,7 +650,6 @@ export default {
console.log(this.category_id) console.log(this.category_id)
console.log(this.stock) console.log(this.stock)
console.log(this.images) console.log(this.images)
console.log(this.variants) console.log(this.variants)
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment