import FormRecipient from "./generic/FormRecipient.js"; export default { name: 'Send', components: { FormRecipient }, data() { return { phone: '', type: window.TYPEUSER, loading: false, } }, computed: { phone_id() { return this.phone + this.type; } }, methods: { openModal() { $('#modalAudioSend').modal({ onApprove: function () { return false; } }).modal('show'); }, async handleSubmit() { try { let response = await this.submitApi() showSuccessInfo(response) $('#modalAudioSend').modal('hide'); } catch (err) { showErrorInfo(err) } }, async submitApi() { this.loading = true; try { let payload = new FormData(); payload.append("phone", this.phone_id) payload.append("audio", $("#file_audio")[0].files[0]) const response = await window.http.post(`/send/audio`, payload) this.handleReset(); return response.data.message; } catch (error) { if (error.response) { throw new Error(error.response.data.message); } throw new Error(error.message); } finally { this.loading = false; } }, handleReset() { this.phone = ''; this.type = window.TYPEUSER; $("#file_audio").val(''); }, }, template: `
Send
Send Audio
Send audio to user or group
` }