diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74dc0a6..55614fa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,37 +1,36 @@ -name: Build Docker images - +name: Build and Deploy Docker images + on: push: - branches: ["master"] - + branches: ['master'] + pull_request: + branches: ['master'] + jobs: build-and-push-dockerfile-image: runs-on: ubuntu-latest - + steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup Bun - uses: oven-sh/setup-bun@v2 - - - name: Log in to Docker Hub + # Only login if we are actually going to push + if: github.event_name == 'push' uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} # Make sure to add the secrets in your repository in -> Settings -> Secrets (Actions) -> New repository secret - password: ${{ secrets.DOCKERHUB_TOKEN }} # Make sure to add the secrets in your repository in -> Settings -> Secrets (Actions) -> New repository secret - + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . file: ./apps/web/Dockerfile - push: true - # Make sure to replace with your own namespace and repository - tags: | - killercf/sgc:latest + # Only push on 'push' event (merge to master), not on 'pull_request' + push: ${{ github.event_name == 'push' }} + tags: killercf/sgc:latest platforms: linux/amd64 build-args: | PUBLIC_CONVEX_URL=${{ secrets.PUBLIC_CONVEX_URL }} - PUBLIC_CONVEX_SITE_URL=${{ secrets.PUBLIC_CONVEX_SITE_URL }} \ No newline at end of file + PUBLIC_CONVEX_SITE_URL=${{ secrets.PUBLIC_CONVEX_SITE_URL }} diff --git a/apps/web/src/routes/(dashboard)/almoxarifado/relatorios/+page.svelte b/apps/web/src/routes/(dashboard)/almoxarifado/relatorios/+page.svelte index 512dbe0..0027e48 100644 --- a/apps/web/src/routes/(dashboard)/almoxarifado/relatorios/+page.svelte +++ b/apps/web/src/routes/(dashboard)/almoxarifado/relatorios/+page.svelte @@ -13,7 +13,6 @@ Package, AlertTriangle, ArrowLeftRight, - Download, CheckCircle, ArrowDown, ArrowUp, @@ -21,6 +20,7 @@ FileText, FileSpreadsheet } from 'lucide-svelte'; + import { SvelteDate } from 'svelte/reactivity'; const statsQuery = useQuery(api.almoxarifado.obterEstatisticas, {}); const materiaisQuery = useQuery(api.almoxarifado.listarMateriais, {}); @@ -31,7 +31,7 @@ let tipoRelatorioGerando = $state(null); // Agrupar materiais por categoria - const materiaisPorCategoria = $derived(() => { + const materiaisPorCategoria = $derived.by(() => { if (!materiaisQuery.data) return {}; const agrupado: Record = {}; materiaisQuery.data.forEach((m) => { @@ -41,10 +41,10 @@ }); // Movimentações do mês - const movimentacoesMes = $derived(() => { + const movimentacoesMes = $derived.by(() => { if (!movimentacoesQuery.data) return { entrada: 0, saida: 0, ajuste: 0 }; const agora = Date.now(); - const inicioMes = new Date(agora); + const inicioMes = new SvelteDate(agora); inicioMes.setDate(1); inicioMes.setHours(0, 0, 0, 0); @@ -124,7 +124,10 @@ if (ctx) { ctx.drawImage(logoImg, 0, 0); const blob = await new Promise((resolve, reject) => { - canvas.toBlob((b) => (b ? resolve(b) : reject(new Error('Falha ao converter'))), 'image/png'); + canvas.toBlob( + (b) => (b ? resolve(b) : reject(new Error('Falha ao converter'))), + 'image/png' + ); }); return await blob.arrayBuffer(); } @@ -257,7 +260,10 @@ yPos += 15; const dados = materiaisPorCategoria; - const dadosArray = Object.entries(dados).map(([categoria, quantidade]) => [categoria, String(quantidade)]); + const dadosArray = Object.entries(dados).map(([categoria, quantidade]) => [ + categoria, + String(quantidade) + ]); if (dadosArray.length === 0) { doc.text('Nenhum dado disponível', 14, yPos); @@ -532,7 +538,12 @@ { header: 'Estoque Mínimo', key: 'estoqueMinimo', width: 18 } ]; - await adicionarTituloExcel(worksheet, 'RELATÓRIO DE MATERIAIS COM ESTOQUE BAIXO', 4, workbook); + await adicionarTituloExcel( + worksheet, + 'RELATÓRIO DE MATERIAIS COM ESTOQUE BAIXO', + 4, + workbook + ); const headerRow = worksheet.getRow(2); headerRow.values = ['Código', 'Material', 'Estoque Atual', 'Estoque Mínimo']; @@ -751,9 +762,7 @@