mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-16 02:12:54 -05:00
Merge branch 'logo-upload' into 'master'
fix cropper Logo upload See merge request mohit.panjvani/crater-web!43
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
:upload-handler="cropperHandler"
|
||||
trigger="#pick-avatar"
|
||||
@changed="setFileObject"
|
||||
@error="hadleUploadError"
|
||||
/>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -177,14 +178,14 @@ export default {
|
||||
},
|
||||
isFetchingData: false,
|
||||
formData: {
|
||||
name: '',
|
||||
logo: null,
|
||||
name: null,
|
||||
logo: '',
|
||||
email: '',
|
||||
phone: null,
|
||||
zip: null,
|
||||
address_street_1: null,
|
||||
address_street_2: null,
|
||||
website: null,
|
||||
phone: '',
|
||||
zip: '',
|
||||
address_street_1: '',
|
||||
address_street_2: '',
|
||||
website: '',
|
||||
country_id: null,
|
||||
state_id: '',
|
||||
city_id: ''
|
||||
@@ -286,6 +287,9 @@ export default {
|
||||
setFileObject (file) {
|
||||
this.fileObject = file
|
||||
},
|
||||
hadleUploadError (message, type, xhr) {
|
||||
window.toastr['error']('Oops! Something went wrong...')
|
||||
},
|
||||
async setInitialData () {
|
||||
let response = await this.loadData()
|
||||
this.isFetchingData = true
|
||||
@@ -314,15 +318,23 @@ export default {
|
||||
data.append('country_id', this.formData.country_id)
|
||||
data.append('zip', this.formData.zip)
|
||||
data.append('phone', this.formData.phone)
|
||||
if (this.fileObject) {
|
||||
data.append('logo', this.fileObject)
|
||||
}
|
||||
|
||||
let response = await this.editCompany(data)
|
||||
if (response.data.success) {
|
||||
this.isLoading = false
|
||||
if (this.fileObject && this.previewLogo) {
|
||||
let logoData = new FormData()
|
||||
logoData.append('company_logo', JSON.stringify({
|
||||
name: this.fileObject.name,
|
||||
data: this.previewLogo
|
||||
}))
|
||||
await axios.post('/api/settings/company/upload-logo', logoData)
|
||||
}
|
||||
this.isLoading = false
|
||||
window.toastr['success'](this.$t('settings.company_info.updated_message'))
|
||||
return true
|
||||
}
|
||||
this.isLoading = false
|
||||
window.toastr['error'](response.data.error)
|
||||
return true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user