refactor: improve type safety and error handling in vacation management components
- Updated the `AprovarFerias.svelte` component to use specific types for `solicitacao` and `gestorId`, enhancing type safety. - Improved error handling by refining catch blocks to handle errors more accurately. - Made minor adjustments to ensure consistent code formatting and readability across the component.
This commit is contained in:
@@ -106,7 +106,7 @@ export const salvarConfigEmail = mutation({
|
||||
|
||||
/**
|
||||
* Testar conexão SMTP (action - precisa de Node.js)
|
||||
*
|
||||
*
|
||||
* NOTA: Esta action será implementada quando instalarmos nodemailer.
|
||||
* Por enquanto, retorna sucesso simulado para não bloquear o desenvolvimento.
|
||||
*/
|
||||
@@ -126,11 +126,14 @@ export const testarConexaoSMTP = action({
|
||||
handler: async (ctx, args) => {
|
||||
// TODO: Implementar teste real com nodemailer
|
||||
// Por enquanto, simula sucesso
|
||||
|
||||
|
||||
try {
|
||||
// Validações básicas
|
||||
if (!args.servidor || args.servidor.trim() === "") {
|
||||
return { sucesso: false as const, erro: "Servidor SMTP não pode estar vazio" };
|
||||
return {
|
||||
sucesso: false as const,
|
||||
erro: "Servidor SMTP não pode estar vazio",
|
||||
};
|
||||
}
|
||||
|
||||
if (args.porta < 1 || args.porta > 65535) {
|
||||
@@ -141,10 +144,17 @@ export const testarConexaoSMTP = action({
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
// Retornar sucesso simulado
|
||||
console.log("⚠️ AVISO: Teste de conexão SMTP simulado (nodemailer não instalado ainda)");
|
||||
console.log(
|
||||
"⚠️ AVISO: Teste de conexão SMTP simulado (nodemailer não instalado ainda)"
|
||||
);
|
||||
return { sucesso: true as const };
|
||||
} catch (error: any) {
|
||||
return { sucesso: false as const, erro: error.message || "Erro ao testar conexão" };
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
sucesso: false as const,
|
||||
erro: errorMessage || "Erro ao testar conexão",
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -162,5 +172,3 @@ export const marcarConfigTestada = mutation({
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user