+
Update
diff --git a/src/views/components/SendAudio.js b/src/views/components/SendAudio.js
new file mode 100644
index 0000000..7651ddd
--- /dev/null
+++ b/src/views/components/SendAudio.js
@@ -0,0 +1,107 @@
+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: {
+ 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 = 'user';
+ $("#file_audio").val('');
+ },
+ },
+ template: `
+
+
+
Send
+
+
+ Send audio to user or group
+
+
+
+
+
+
+ `
+}
\ No newline at end of file
diff --git a/src/views/components/SendContact.js b/src/views/components/SendContact.js
new file mode 100644
index 0000000..2123962
--- /dev/null
+++ b/src/views/components/SendContact.js
@@ -0,0 +1,117 @@
+export default {
+ name: 'SendContact',
+ data() {
+ return {
+ type: 'user',
+ phone: '',
+ card_name: '',
+ card_phone: '',
+ loading: false,
+ }
+ },
+ computed: {
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
+ }
+ },
+ methods: {
+ openModal() {
+ $('#modalSendContact').modal({
+ onApprove: function () {
+ return false;
+ }
+ }).modal('show');
+ },
+ async handleSubmit() {
+ try {
+ this.loading = true;
+ let response = await this.submitApi()
+ showSuccessInfo(response)
+ $('#modalSendContact').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ } finally {
+ this.loading = false;
+ }
+ },
+ async submitApi() {
+ this.loading = true;
+ try {
+ const payload = {
+ phone: this.phone_id,
+ contact_name: this.card_name,
+ contact_phone: this.card_phone
+ }
+ let response = await window.http.post(`/send/contact`, 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.card_name = '';
+ this.card_phone = '';
+ this.type = 'user';
+ },
+ },
+ template: `
+
+
+
Send
+
+
+ Send contact to user or group
+
+
+
+
+
+
+ `
+}
\ No newline at end of file
diff --git a/src/views/components/SendFile.js b/src/views/components/SendFile.js
new file mode 100644
index 0000000..7039f72
--- /dev/null
+++ b/src/views/components/SendFile.js
@@ -0,0 +1,122 @@
+export default {
+ name: 'SendFile',
+ props: {
+ maxFileSize: {
+ type: String,
+ required: true,
+ }
+ },
+ data() {
+ return {
+ caption: '',
+ type: 'user',
+ phone: '',
+ loading: false,
+ }
+ },
+ computed: {
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
+ }
+ },
+ methods: {
+ openModal() {
+ $('#modalSendFile').modal({
+ onApprove: function () {
+ return false;
+ }
+ }).modal('show');
+ },
+ async handleSubmit() {
+ try {
+ let response = await this.submitApi()
+ showSuccessInfo(response)
+ $('#modalSendFile').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ }
+ },
+ async submitApi() {
+ this.loading = true;
+ try {
+ let payload = new FormData();
+ payload.append("caption", this.caption)
+ payload.append("phone", this.phone_id)
+ payload.append("file", $("#file_file")[0].files[0])
+ let response = await window.http.post(`/send/file`, 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.caption = '';
+ this.phone = '';
+ this.type = 'user';
+ $("#file_file").val('');
+ },
+ },
+ template: `
+
+
+
Send
+
+
+ Send any file up to
+
{{ maxFileSize }}
+
+
+
+
+
+
+ `
+}
\ No newline at end of file
diff --git a/src/views/components/SendImage.js b/src/views/components/SendImage.js
new file mode 100644
index 0000000..04ae09e
--- /dev/null
+++ b/src/views/components/SendImage.js
@@ -0,0 +1,139 @@
+export default {
+ name: 'SendImage',
+ data() {
+ return {
+ phone: '',
+ view_once: false,
+ compress: false,
+ caption: '',
+ type: 'user',
+ loading: false,
+ selected_file: null
+ }
+ },
+ computed: {
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
+ }
+ },
+ methods: {
+ openModal() {
+ $('#modalSendImage').modal({
+ onApprove: function () {
+ return false;
+ }
+ }).modal('show');
+ },
+ async handleSubmit() {
+ try {
+ let response = await this.submitApi()
+ showSuccessInfo(response)
+ $('#modalSendImage').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ }
+ },
+ async submitApi() {
+ this.loading = true;
+ try {
+ let payload = new FormData();
+ payload.append("phone", this.phone_id)
+ payload.append("view_once", this.view_once)
+ payload.append("compress", this.compress)
+ payload.append("caption", this.caption)
+ payload.append('image', $("#file_image")[0].files[0])
+
+ let response = await window.http.post(`/send/image`, 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.view_once = false;
+ this.compress = false;
+ this.phone = '';
+ this.caption = '';
+ this.type = 'user';
+ $("#file_image").val('');
+ },
+ },
+ template: `
+
+
+
Send
+
+
+ Send image with
+
jpg/jpeg/png
+ type
+
+
+
+
+
+
+ `
+}
\ No newline at end of file
diff --git a/src/views/components/SendLocation.js b/src/views/components/SendLocation.js
new file mode 100644
index 0000000..ce6c479
--- /dev/null
+++ b/src/views/components/SendLocation.js
@@ -0,0 +1,115 @@
+export default {
+ name: 'SendLocation',
+ data() {
+ return {
+ type: 'user',
+ phone: '',
+ latitude: '',
+ longitude: '',
+ loading: false,
+ }
+ },
+ computed: {
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
+ }
+ },
+ methods: {
+ openModal() {
+ $('#modalSendLocation').modal({
+ onApprove: function () {
+ return false;
+ }
+ }).modal('show');
+ },
+ async handleSubmit() {
+ try {
+ let response = await this.submitApi()
+ showSuccessInfo(response)
+ $('#modalSendLocation').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ }
+ },
+ async submitApi() {
+ this.loading = true;
+ try {
+ const payload = {
+ phone: this.phone_id,
+ latitude: this.latitude,
+ longitude: this.longitude
+ };
+
+ const response = await window.http.post(`/send/location`, 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.latitude = '';
+ this.longitude = '';
+ this.type = 'user';
+ },
+ },
+ template: `
+
+
+
Send
+
+
+ Send location to user or group
+
+
+
+
+
+
+ `
+}
\ No newline at end of file
diff --git a/src/views/components/SendMessage.js b/src/views/components/SendMessage.js
new file mode 100644
index 0000000..6f56779
--- /dev/null
+++ b/src/views/components/SendMessage.js
@@ -0,0 +1,118 @@
+export default {
+ name: 'SendMessage',
+ data() {
+ return {
+ type: 'user',
+ phone: '',
+ text: '',
+ reply_id: '',
+ loading: false,
+ }
+ },
+ computed: {
+ phone_id() {
+ return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}`
+ }
+ },
+ methods: {
+ openModal() {
+ $('#modalSendMessage').modal({
+ onApprove: function () {
+ return false;
+ }
+ }).modal('show');
+ },
+ async handleSubmit() {
+ try {
+ let response = await this.submitApi()
+ showSuccessInfo(response)
+ $('#modalSendMessage').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ }
+ },
+ async submitApi() {
+ this.loading = true;
+ try {
+ const payload = {
+ phone: this.phone_id,
+ message: this.text,
+ }
+ if (this.reply_id !== '') {
+ payload.reply_id = this.reply_id;
+ }
+
+ let response = await window.http.post(`/send/message`, 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.text = '';
+ this.type = 'user';
+ this.reply_id = '';
+ },
+ },
+ template: `
+
+
+
Send
+
+
+ Send any message 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..5ef2ce7 100644
--- a/src/views/components/SendPoll.js
+++ b/src/views/components/SendPoll.js
@@ -3,76 +3,73 @@ 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() {
+ openModal() {
$('#modalSendPoll').modal({
onApprove: function () {
return false;
}
}).modal('show');
},
- async sendPollProcess() {
+ async handleSubmit() {
try {
- let response = await this.sendPollApi()
+ let response = await this.submitApi()
window.showSuccessInfo(response)
$('#modalSendPoll').modal('hide');
} catch (err) {
window.showErrorInfo(err)
}
},
- sendPollApi() {
- return new Promise(async (resolve, reject) => {
- try {
- this.poll_loading = true;
- const payload = {
- phone: this.poll_phone_id,
- question: this.poll_question,
- max_answer: this.poll_max_vote,
- options: this.poll_options
- }
- let response = await window.http.post(`/send/poll`, payload)
- this.sendPollReset();
- resolve(response.data.message)
- } catch (error) {
- if (error.response) {
- reject(error.response.data.message)
- } else {
- reject(error.message)
- }
- } finally {
- this.poll_loading = false;
+ async submitApi() {
+ this.loading = true;
+ try {
+ const payload = {
+ phone: this.phone_id,
+ question: this.question,
+ max_answer: this.max_vote,
+ options: this.options
+ }
+ const response = await window.http.post(`/send/poll`, 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;
+ }
},
- sendPollReset() {
- this.poll_phone = '';
- this.poll_type = 'user';
- this.poll_question = '';
- this.poll_options = ['', ''];
- this.poll_max_vote = 1;
+ handleReset() {
+ 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: `
-