+
Update
diff --git a/src/views/components/SendAudio.js b/src/views/components/SendAudio.js
new file mode 100644
index 0000000..714a85d
--- /dev/null
+++ b/src/views/components/SendAudio.js
@@ -0,0 +1,111 @@
+export default {
+ name: 'Send',
+ data() {
+ return {
+ phone: '',
+ type: 'user',
+ loading: false,
+ }
+ },
+ computed: {
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
+ }
+ },
+ methods: {
+ sendModal() {
+ $('#modalAudioSend').modal({
+ onApprove: function () {
+ return false;
+ }
+ }).modal('show');
+ },
+ async sendProcess() {
+ try {
+ let response = await this.sendApi()
+ showSuccessInfo(response)
+ $('#modalAudioSend').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ }
+ },
+ sendApi() {
+ return new Promise(async (resolve, reject) => {
+ try {
+ this.loading = true;
+ let payload = new FormData();
+ payload.append("phone", this.phone_id)
+ payload.append("audio", $("#file")[0].files[0])
+ let response = await http.post(`/send/audio`, payload)
+ this.sendReset();
+ resolve(response.data.message)
+ } catch (error) {
+ if (error.response) {
+ reject(error.response.data.message)
+ } else {
+ reject(error.message)
+ }
+ } finally {
+ this.loading = false;
+ }
+ })
+ },
+ sendReset() {
+ this.phone = '';
+ this.type = 'user';
+ $("#file").val('');
+ },
+ },
+ template:`
+
+
+
Send
+
+
+ Send audio to user or group
+
+
+
+
+
+
+ `
+}
\ No newline at end of file
diff --git a/src/views/components/SendPoll.js b/src/views/components/SendPoll.js
index d3fd683..b3551bc 100644
--- a/src/views/components/SendPoll.js
+++ b/src/views/components/SendPoll.js
@@ -3,48 +3,48 @@ export default {
name: 'SendPoll',
data() {
return {
- poll_phone: '',
- poll_type: 'user',
- poll_loading: false,
- poll_question: '',
- poll_options: ['', ''],
- poll_max_vote: 1,
+ phone: '',
+ type: 'user',
+ loading: false,
+ question: '',
+ options: ['', ''],
+ max_vote: 1,
}
},
computed: {
- poll_phone_id() {
- return this.poll_type === 'user' ? `${this.poll_phone}@${window.TYPEUSER}` : `${this.poll_phone}@${window.TYPEGROUP}`
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
}
},
methods: {
- sendPollModal() {
+ showModal() {
$('#modalSendPoll').modal({
onApprove: function () {
return false;
}
}).modal('show');
},
- async sendPollProcess() {
+ async sendProcess() {
try {
- let response = await this.sendPollApi()
+ let response = await this.sendApi()
window.showSuccessInfo(response)
$('#modalSendPoll').modal('hide');
} catch (err) {
window.showErrorInfo(err)
}
},
- sendPollApi() {
+ sendApi() {
return new Promise(async (resolve, reject) => {
try {
- this.poll_loading = true;
+ this.loading = true;
const payload = {
- phone: this.poll_phone_id,
- question: this.poll_question,
- max_answer: this.poll_max_vote,
- options: this.poll_options
+ phone: this.phone_id,
+ question: this.question,
+ max_answer: this.max_vote,
+ options: this.options
}
let response = await window.http.post(`/send/poll`, payload)
- this.sendPollReset();
+ this.sendReset();
resolve(response.data.message)
} catch (error) {
if (error.response) {
@@ -53,26 +53,26 @@ export default {
reject(error.message)
}
} finally {
- this.poll_loading = false;
+ this.loading = false;
}
})
},
- sendPollReset() {
- this.poll_phone = '';
- this.poll_type = 'user';
- this.poll_question = '';
- this.poll_options = ['', ''];
- this.poll_max_vote = 1;
+ sendReset() {
+ this.phone = '';
+ this.type = 'user';
+ this.question = '';
+ this.options = ['', ''];
+ this.max_vote = 1;
},
- addPollOption() {
- this.poll_options.push('')
+ addOption() {
+ this.options.push('')
},
- deletePollOption(index) {
- this.poll_options.splice(index, 1)
+ deleteOption(index) {
+ this.options.splice(index, 1)
}
},
template: `
-
+
Send
@@ -92,34 +92,34 @@ export default {
-
-
-
Send
-
-
- Send audio to user or group
-
-
-
-
+
@@ -151,25 +142,8 @@
-
-
-
Message
-
-
- Revoke any message in private or group chat
-
-
-
-
-
-
Message
-
-
- React any message in private or group chat
-
-
-
-
+
+
@@ -342,47 +316,6 @@