diff --git a/.gitea/Workflow/renovate.yaml b/.gitea/Workflow/renovate.yaml new file mode 100644 index 0000000..6d2b4fa --- /dev/null +++ b/.gitea/Workflow/renovate.yaml @@ -0,0 +1,21 @@ +name: Renovate Bot +on: + schedule: + - cron: '0 6 * * *' + workflow_dispatch: + +jobs: + renovate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Self-hosted Renovate + uses: docker://renovate/renovate:latest + env: + RENOVATE_PLATFORM: 'gitea' + RENOVATE_ENDPOINT: 'http://git.jurunense.com/api/v1' + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} + RENOVATE_AUTODISCOVER: 'true' + RENOVATE_REQUIRE_CONFIG: 'required' \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 0000000..aa80e02 --- /dev/null +++ b/config.js @@ -0,0 +1,7 @@ +module.exports = { + platform: 'gitea', + endpoint: 'https://git.jurunense.com/api/v1', + token: 'a605ffac82b25e40bc913c8b3f4344d07462fa47', + autodiscover: true, + onboarding: true, +}; \ No newline at end of file diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..d138551 --- /dev/null +++ b/renovate.json @@ -0,0 +1,71 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ], + "labels": [ + "dependências" + ], + "assignees": [ + "renovate-bot" + ], + "timezone": "America/Belem", + "schedule": [ + "before 6am on Monday" + ], + "packageRules": [ + { + "matchPackagePatterns": [ + "^@radix-ui/" + ], + "groupName": "Radix UI" + }, + { + "matchPackageNames": [ + "next", + "eslint-config-next" + ], + "groupName": "Next.js" + }, + { + "matchPackageNames": [ + "react", + "react-dom", + "@types/react", + "@types/react-dom" + ], + "groupName": "React" + }, + { + "matchPackageNames": [ + "oracledb", + "@types/oracledb" + ], + "groupName": "Oracle Database" + }, + { + "matchPackageNames": [ + "tailwindcss", + "tailwindcss-animate", + "tailwind-merge", + "postcss" + ], + "groupName": "Tailwind CSS" + }, + { + "matchPackageNames": [ + "typescript", + "@types/node" + ], + "groupName": "TypeScript" + } + ], + "vulnerabilityAlerts": { + "labels": [ + "segurança" + ], + "assignees": [ + "renovate-bot" + ] + } +} \ No newline at end of file diff --git a/src/app/action/update-baldinho.ts b/src/app/action/update-baldinho.ts index 05ac44b..75b5042 100644 --- a/src/app/action/update-baldinho.ts +++ b/src/app/action/update-baldinho.ts @@ -13,10 +13,6 @@ async function updateBladinho(delivery: boolean, date: Date) { const year = date.getFullYear(); const formattedDate = `${day}/${month}/${year}`; - console.log( - `🔄 Tentando atualizar: data=${formattedDate}, delivery=${deliveryValue}` - ); - // Usa objeto de binds para evitar problemas com palavras reservadas // TO_DATE converte a string DD/MM/YYYY para DATE do Oracle const sql = ` @@ -29,17 +25,7 @@ async function updateBladinho(delivery: boolean, date: Date) { dataVal: formattedDate, }; - console.log('📝 SQL:', sql); - console.log('📦 Binds:', JSON.stringify(binds, null, 2)); - const rowsAffected = await executeOracleUpdate(sql, binds); - console.log(`✅ UPDATE concluído: ${rowsAffected} linha(s) atualizada(s)`); - - if (rowsAffected === 0) { - console.warn( - '⚠️ Nenhuma linha foi atualizada. Verifique se a data existe na tabela.' - ); - } return rowsAffected; } @@ -51,8 +37,6 @@ async function updateBaldinhoDaysSale(daysSale: number): Promise { }; const result = await executeOracleUpdate(sql, binds); - console.log(`✅ UPDATE concluído: ${result} linha(s) atualizada(s)`); - return result; } @@ -64,15 +48,11 @@ async function updateBaldinhoDeliverySize( deliverySize: deliverySize, }; const result = await executeOracleUpdate(sql, binds); - console.log(`✅ UPDATE concluído: ${result} linha(s) atualizada(s)`); return result; } export async function changeNoDelivery(date: Date, delivery: boolean) { await updateBladinho(delivery, date); - console.log( - `clicado: ${date.toLocaleDateString('pt-BR')}, delivery: ${delivery}` - ); // Next 16 requires cache profile; empty config preserves current defaults revalidateTag('baldinho', {}); revalidatePath('/dias-rota'); @@ -80,14 +60,12 @@ export async function changeNoDelivery(date: Date, delivery: boolean) { export async function changeBaldinhoDaysSale(daysSale: number) { await updateBaldinhoDaysSale(daysSale); - console.log(`clicado: ${daysSale}`); - revalidateTag('baldinho'); + revalidateTag('baldinho', {}); revalidatePath('/dias-rota'); } export async function changeBaldinhoDeliverySize(deliverySize: number) { await updateBaldinhoDeliverySize(deliverySize); - console.log(`clicado: ${deliverySize}`); - revalidateTag('baldinho'); + revalidateTag('baldinho', {}); revalidatePath('/dias-rota'); } diff --git a/src/app/dias-rota/pagina.tsx b/src/app/dias-rota/pagina.tsx index 80456fd..1a1e067 100644 --- a/src/app/dias-rota/pagina.tsx +++ b/src/app/dias-rota/pagina.tsx @@ -77,13 +77,6 @@ const Pagina = ({ bladinhoData }: PaginaProps) => { ); const [isLoadingDaysSale, setIsLoadingDaysSale] = useState(false); const [isLoadingDeliverySize, setIsLoadingDeliverySize] = useState(false); - // Estado para controlar a abertura do AlertDialog - const [isDialogOpen, setIsDialogOpen] = useState(false); - // Estado para armazenar a data e o novo valor de delivery quando o usuário clicar - const [pendingUpdate, setPendingUpdate] = useState<{ - date: Date; - delivery: boolean; - } | null>(null); const features = useMemo(() => { return bladinhoData.map((item) => { @@ -196,26 +189,6 @@ const Pagina = ({ bladinhoData }: PaginaProps) => { } finally { setIsLoadingDaysSale(false); } - - // Armazena os dados e abre o dialog - setPendingUpdate({ date, delivery: newDelivery }); - setIsDialogOpen(true); - }; - - const handleConfirmUpdate = async () => { - if (pendingUpdate) { - // Executa o update apenas quando o usuário confirmar - await changeNoDelivery(pendingUpdate.date, pendingUpdate.delivery); - // Fecha o dialog e limpa o estado - setIsDialogOpen(false); - setPendingUpdate(null); - } - }; - - const handleCancelUpdate = () => { - // Apenas fecha o dialog e limpa o estado, sem fazer update - setIsDialogOpen(false); - setPendingUpdate(null); }; const handleBaldinhoDeliverySizeChange = async (deliverySize: number) => { diff --git a/src/db/oracle.ts b/src/db/oracle.ts index f7b98e8..90c2a36 100644 --- a/src/db/oracle.ts +++ b/src/db/oracle.ts @@ -27,9 +27,7 @@ export async function getOraclePool(): Promise { if (!pool) { try { pool = await oracledb.createPool(oracleConfig); - console.log('✅ Pool Oracle criado com sucesso'); } catch (error) { - console.error('❌ Erro ao criar pool Oracle:', error); throw error; } } @@ -51,7 +49,6 @@ export async function executeOracleQuery( }); return result.rows || []; } catch (error) { - console.error('❌ Erro ao executar query Oracle:', error); throw error; } finally { if (connection) { @@ -69,26 +66,12 @@ export async function executeOracleUpdate( try { connection = await pool.getConnection(); - console.log( - '🔍 Executando UPDATE com binds:', - JSON.stringify(binds, null, 2) - ); const result = await connection.execute(sql, binds, { autoCommit: true, // Commit automático para UPDATE }); const rowsAffected = result.rowsAffected || 0; - console.log(`✅ UPDATE executado: ${rowsAffected} linha(s) afetada(s)`); - if (rowsAffected === 0) { - console.warn( - '⚠️ ATENÇÃO: Nenhuma linha foi afetada pelo UPDATE. Verifique:' - ); - console.warn(' - Se a data existe na tabela PCDIASUTEIS'); - console.warn(' - Se CODFILIAL = 12 corresponde ao registro'); - console.warn(' - Se o formato da data está correto'); - } return rowsAffected; } catch (error) { - console.error('❌ Erro ao executar UPDATE Oracle:', error); throw error; } finally { if (connection) { @@ -101,7 +84,6 @@ export async function closeOraclePool(): Promise { if (pool) { await pool.close(); pool = null; - console.log('✅ Pool Oracle fechado'); } } diff --git a/tsconfig.json b/tsconfig.json index 53c6f65..877b650 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ {