refactor: integrate current user data across components
- Replaced instances of `authStore` with `currentUser` to streamline user authentication handling. - Updated permission checks and user-related data retrieval to utilize the new `useQuery` for better performance and clarity. - Cleaned up component structures and improved formatting for consistency and readability. - Enhanced error handling and user feedback mechanisms in various components to improve user experience.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import { goto } from "$app/navigation";
|
||||
import { useQuery, useConvexClient } from "convex-svelte";
|
||||
import { api } from "@sgse-app/backend/convex/_generated/api";
|
||||
import { authStore } from "$lib/stores/auth.svelte";
|
||||
import AprovarAusencias from "$lib/components/AprovarAusencias.svelte";
|
||||
import type { Id } from "@sgse-app/backend/convex/_generated/dataModel";
|
||||
|
||||
const client = useConvexClient();
|
||||
const currentUser = useQuery(api.auth.getCurrentUser, {});
|
||||
|
||||
// Buscar TODAS as solicitações de ausências
|
||||
const todasAusenciasQuery = useQuery(api.ausencias.listarTodas, {});
|
||||
@@ -390,7 +390,7 @@
|
||||
</main>
|
||||
|
||||
<!-- Modal de Aprovação -->
|
||||
{#if solicitacaoSelecionada && authStore.usuario}
|
||||
{#if solicitacaoSelecionada && currentUser.data}
|
||||
{#await client.query(api.ausencias.obterDetalhes, {
|
||||
solicitacaoId: solicitacaoSelecionada,
|
||||
}) then detalhes}
|
||||
@@ -399,7 +399,7 @@
|
||||
<div class="modal-box max-w-4xl">
|
||||
<AprovarAusencias
|
||||
solicitacao={detalhes}
|
||||
gestorId={authStore.usuario._id}
|
||||
gestorId={currentUser.data._id}
|
||||
onSucesso={recarregar}
|
||||
onCancelar={() => (solicitacaoSelecionada = null)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user