export default { name: 'Update Message', data() { return { update_type: 'user', update_phone: '', update_message_id: '', update_new_message: '', update_loading: false, } }, computed: { update_phone_id() { return this.update_type === 'user' ? `${this.update_phone}@${window.TYPEUSER}` : `${this.update_phone}@${window.TYPEGROUP}` } }, methods: { messageEditModal() { $('#modalMessageEdit').modal({ onApprove: function () { return false; } }).modal('show'); }, async messageEditProcess() { try { let response = await this.messageEditApi() showSuccessInfo(response) $('#modalMessageEdit').modal('hide'); } catch (err) { showErrorInfo(err) } }, messageEditApi() { return new Promise(async (resolve, reject) => { try { this.update_loading = true; const payload = { phone: this.update_phone_id, message: this.update_new_message } let response = await http.post(`/message/${this.update_message_id}/update`, payload) this.messageEditReset(); resolve(response.data.message) } catch (error) { if (error.response) { reject(error.response.data.message) } else { reject(error.message) } } finally { this.update_loading = false; } }) }, messageEditReset() { this.update_type = 'user'; this.update_phone = ''; this.update_message_id = ''; this.update_new_message = ''; this.update_loading = false; }, }, template: `
Message
Edit Message
Update your sent message
` }