diff --git a/src/views/components/SendAudio.js b/src/views/components/SendAudio.js
index 7e014cd..baf09d1 100644
--- a/src/views/components/SendAudio.js
+++ b/src/views/components/SendAudio.js
@@ -34,7 +34,7 @@ export default {
try {
let payload = new FormData();
payload.append("phone", this.phone_id)
- payload.append("audio", $("#file")[0].files[0])
+ payload.append("audio", $("#file_audio")[0].files[0])
const response = await window.http.post(`/send/audio`, payload)
this.handleReset();
return response.data.message;
@@ -51,7 +51,7 @@ export default {
handleReset() {
this.phone = '';
this.type = 'user';
- $("#file").val('');
+ $("#file_audio").val('');
},
},
template:`
@@ -87,10 +87,9 @@ export default {
-
-
-
Caption
-
File
-
-
+
+
Upload file
diff --git a/src/views/components/SendImage.js b/src/views/components/SendImage.js
new file mode 100644
index 0000000..f7b4aa4
--- /dev/null
+++ b/src/views/components/SendImage.js
@@ -0,0 +1,141 @@
+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.sendApi()
+ showSuccessInfo(response)
+ $('#modalSendImage').modal('hide');
+ } catch (err) {
+ showErrorInfo(err)
+ }
+ },
+ async sendApi() {
+ 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);
+ } else {
+ 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/SendVideo.js b/src/views/components/SendVideo.js
index 65b9285..d3d3517 100644
--- a/src/views/components/SendVideo.js
+++ b/src/views/components/SendVideo.js
@@ -47,7 +47,7 @@ export default {
payload.append("caption", this.caption)
payload.append("view_once", this.view_once)
payload.append("compress", this.compress)
- payload.append("video", $("#file")[0].files[0])
+ payload.append('video', $("#file_video")[0].files[0])
let response = await window.http.post(`/send/video`, payload)
this.handleReset();
return response.data.message;
@@ -67,7 +67,7 @@ export default {
this.compress = false;
this.phone = '';
this.type = 'user';
- $("#file").val('');
+ $("#file_video").val('');
},
},
template: `
@@ -126,8 +126,8 @@ export default {
Video
-
-
+
+
Upload video
diff --git a/src/views/index.html b/src/views/index.html
index 548ee09..2233ab2 100644
--- a/src/views/index.html
+++ b/src/views/index.html
@@ -82,18 +82,8 @@
-
-
-
Send
-
-
- Send image with
-
jpg/jpeg/png
- type
-
-
-
+
@@ -222,66 +212,6 @@
-
-
-
@@ -454,6 +384,7 @@
{{ end }}