Skip to content

Commit df3d798

Browse files
committed
fix: supporting more correios shipping tags [#831]
sending post to https://app.ecomplus.io/extra/declaracao-correios
1 parent 94a10b5 commit df3d798

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"standard.vscode-standard",
55
"xabikos.javascriptsnippets",
66
"digitalbrainstem.javascript-ejs-support",
7-
"octref.vetur",
8-
"bierner.lit-html"
7+
"octref.vetur"
98
]
109
}

src/controllers/shipping-tags.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import axios from 'axios'
2+
13
export default function () {
24
const { $, ecomUtils, callApi, formatPhone, tabId, routeParams } = window
35
const store = window.Store || {}
@@ -162,13 +164,14 @@ export default function () {
162164
$appTab.find('.tags:last-child').after($shippingTags)
163165
$appTab.find('.spinner-linear').remove()
164166
$appTab.find('.doc-correios').click(() => {
165-
let url = 'https://declaracao-correios.netlify.app/?'
167+
const url = 'https://app.ecomplus.io/extra/declaracao-correios'
168+
const body = { pedidos: [] }
166169
data.result.forEach((order, i) => {
167170
if (order.shipping_lines && order.shipping_lines[0]) {
168171
const { to, from } = order.shipping_lines[0]
169172
if (from && to) {
170173
const pkg = order.shipping_lines[0].package
171-
url += `&pedido=${encodeURIComponent(JSON.stringify({
174+
body.pedidos.push({
172175
remNome: from.name || store.corporate_name,
173176
remEndereco: `${from.street}, ${from.number}, ${(from.borough || '')}`,
174177
remLinha2: `${(from.complement || '')} - ${(from.near_to || '')}`,
@@ -190,17 +193,19 @@ export default function () {
190193
})),
191194
peso: pkg && pkg.weight
192195
? (!pkg.weight.unit || pkg.weight.unit === 'kg')
193-
? pkg.weight.value
194-
: pkg.weight.unit === 'g'
195-
? pkg.weight.value / 1000
196-
: undefined
196+
? pkg.weight.value
197+
: pkg.weight.unit === 'g'
198+
? pkg.weight.value / 1000
199+
: undefined
197200
: undefined
198-
}))}`
201+
})
199202
}
200203
}
201204
})
202-
const win = window.open(url, '_blank')
203-
win.focus()
205+
axios.post(url, body).then(() => {
206+
const win = window.open(url, '_blank')
207+
win.focus()
208+
})
204209
})
205210
}
206211
}

0 commit comments

Comments
 (0)