Skip to content

Commit 1c22638

Browse files
committed
chore: supporting more correios shipping tags (fix) [#831]
sending post to https://app.ecomplus.io/extra/declaracao-correios html form post
1 parent df3d798 commit 1c22638

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/controllers/shipping-tags.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import axios from 'axios'
2-
31
export default function () {
42
const { $, ecomUtils, callApi, formatPhone, tabId, routeParams } = window
53
const store = window.Store || {}
@@ -164,7 +162,6 @@ export default function () {
164162
$appTab.find('.tags:last-child').after($shippingTags)
165163
$appTab.find('.spinner-linear').remove()
166164
$appTab.find('.doc-correios').click(() => {
167-
const url = 'https://app.ecomplus.io/extra/declaracao-correios'
168165
const body = { pedidos: [] }
169166
data.result.forEach((order, i) => {
170167
if (order.shipping_lines && order.shipping_lines[0]) {
@@ -202,10 +199,10 @@ export default function () {
202199
}
203200
}
204201
})
205-
axios.post(url, body).then(() => {
206-
const win = window.open(url, '_blank')
207-
win.focus()
208-
})
202+
const $correiosDeclaracao = $appTab.find('.correios-declaracao')
203+
const jsonInputValue = JSON.stringify(body).substring(1)
204+
$correiosDeclaracao.html(`<input name='{"trash":"' value='",${jsonInputValue}'>`)
205+
$correiosDeclaracao.submit()
209206
})
210207
}
211208
}

src/views/shipping-tags.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,11 @@
4444
<input type="hidden" name="to" value="4">
4545
<input type="hidden" name="remLembrar" value="1">
4646
</form>
47+
48+
<form
49+
class="correios-declaracao"
50+
action="https://app.ecomplus.io/extra/declaracao-correios"
51+
method="post"
52+
enctype="text/plain"
53+
>
54+
</form>

0 commit comments

Comments
 (0)