Skip to content

Commit

Permalink
download pedido ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunobento1990 committed Nov 2, 2024
1 parent a9bf4e7 commit 0d2a860
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/@open-adm/pages/pedidos/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { generatePdfFromBase64 } from 'src/@open-adm/utils/download-pdf'

export function useConfig() {
const { navigate } = useNavigateApp();
const api = useNewApi({
method: 'GET',
url: 'pedidos/download-pedido?pedidoId=',
});

async function downloadPedido(id: string) {
const api = useNewApi({
method: 'GET',
url: 'pedidos/download-pedido?pedidoId='
});
const pdfBase64 = await api.fecth<any>({ urlParams: `${id}` });
const pdfBase64 = await api.fecth<any>({ urlParams: `${id}`, message: 'Download efetuado com sucesso!' });
if (pdfBase64?.pdf) {
const pdf = await generatePdfFromBase64(pdfBase64.pdf);
const link = document.createElement('a');
Expand All @@ -24,6 +24,7 @@ export function useConfig() {
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
navigate('/pedidos')
}
}

Expand Down Expand Up @@ -75,7 +76,7 @@ export function useConfig() {
return (
<Tooltip title="Download do pedido" placement="top">
<IconButton
onClick={() => downloadPedido(params.id)}
onClick={() => downloadPedido(`${params.id}`)}
>
<IconifyIcon
icon='material-symbols-light:download'
Expand Down

0 comments on commit 0d2a860

Please sign in to comment.