-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
ShoppingCart/Frondend/ecommerce-ui/src/views/Category/EditCategory.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12 text-center"> | ||
<h3 class="pt-3">Edit Category</h3> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-3"></div> | ||
<div class="col-md-6 px-5 px-md-0"> | ||
<form> | ||
<div class="form-group"> | ||
<label>Category Name</label> | ||
<input type="text" class="form-control" v-model="categoryName" required> | ||
</div> | ||
<div class="form-group"> | ||
<label>Description</label> | ||
<input type="text" class="form-control" v-model="description" required> | ||
</div> | ||
<div class="form-group"> | ||
<label>ImageURL</label> | ||
<input type="url" class="form-control" v-model="imageUrl" required> | ||
</div> | ||
<button type="button" class="btn btn-primary" @click="editCategory">Submit</button> | ||
</form> | ||
</div> | ||
<div class="col-3"></div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
var axios = require('axios') | ||
import swal from 'sweetalert'; | ||
export default { | ||
data(){ | ||
return { | ||
id : null, | ||
categoryName : null, | ||
description : null, | ||
imageUrl : null, | ||
categoryIndex : null | ||
} | ||
}, | ||
props : ["baseURL", "category"], | ||
methods : { | ||
async editCategory() { | ||
const updatedCategory = { | ||
id : this.id, | ||
categoryName : this.categoryName, | ||
description : this.description, | ||
imageUrl : this.imageUrl, | ||
} | ||
await axios({ | ||
method: 'post', | ||
url: this.baseURL+"category/update/"+this.id, | ||
data : JSON.stringify(updatedCategory), | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}) | ||
.then(() => { | ||
swal({ | ||
text: "Category Updated Successfully!", | ||
icon: "success", | ||
closeOnClickOutside: false, | ||
}); | ||
}) | ||
.catch(err => console.log(err)); | ||
} | ||
}, | ||
mounted() { | ||
this.id = this.$route.params.id; | ||
this.categoryName = this.category.categoryName; | ||
this.description = this.category.description; | ||
this.imageUrl = this.category.imageUrl; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
h4 { | ||
font-family: 'Roboto', sans-serif; | ||
color: #484848; | ||
font-weight: 700; | ||
} | ||
</style> |