feat: enhance SLA management and authentication handling

- Updated the useConvexWithAuth hook to improve token management and logging for better debugging.
- Integrated automatic authentication handling in the central-chamados route, ensuring seamless user experience.
- Added a new mutation for migrating old SLA configurations to include a priority field, enhancing data consistency.
- Improved the display of SLA configurations in the UI, including detailed views and migration feedback for better user interaction.
- Refactored ticket loading logic to enrich ticket data with responsible user names, improving clarity in ticket management.
This commit is contained in:
2025-11-17 08:44:18 -03:00
parent fb784d6f7e
commit 5ef6ef8550
5 changed files with 613 additions and 70 deletions

View File

@@ -30,15 +30,25 @@ export function useConvexWithAuth() {
const clientWithAuth = client as ConvexClientWithAuth;
// Configurar token se disponível
if (clientWithAuth && typeof clientWithAuth.setAuth === "function" && token) {
if (clientWithAuth && token) {
try {
clientWithAuth.setAuth(token);
if (import.meta.env.DEV) {
console.log("✅ [useConvexWithAuth] Token configurado:", token.substring(0, 20) + "...");
// Tentar setAuth se disponível
if (typeof clientWithAuth.setAuth === "function") {
clientWithAuth.setAuth(token);
if (import.meta.env.DEV) {
console.log("✅ [useConvexWithAuth] Token configurado via setAuth:", token.substring(0, 20) + "...");
}
} else {
// Se setAuth não estiver disponível, o token deve ser passado via createSvelteAuthClient
if (import.meta.env.DEV) {
console.log(" [useConvexWithAuth] Token disponível, autenticação gerenciada por createSvelteAuthClient");
}
}
} catch (e) {
console.warn("⚠️ [useConvexWithAuth] Erro ao configurar token:", e);
}
} else if (!token && import.meta.env.DEV) {
console.warn("⚠️ [useConvexWithAuth] Token não disponível");
}
return client;