⚙️ Atualização local para GPI - Sync via Antigravity

This commit is contained in:
2026-03-18 21:48:53 +00:00
parent c6f69e1c1d
commit 73ab7b3b0f
34 changed files with 970 additions and 1115 deletions

View File

@@ -1,16 +1,16 @@
import React, { useState, useEffect, useCallback } from 'react';
import { useAuth } from '@clerk/clerk-react';
import { useAuth } from '../context/useAuth';
import api from '../services/api';
import type { INotification } from '../types';
import { NotificationContext } from './NotificationContextState';
export const NotificationProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const { orgId, isSignedIn } = useAuth();
const { appUser, isSignedIn } = useAuth();
const [notifications, setNotifications] = useState<INotification[]>([]);
const [loading, setLoading] = useState(false);
const fetchNotifications = useCallback(async () => {
if (!orgId || !isSignedIn) return;
if (!isSignedIn) return;
try {
if (notifications.length === 0) setLoading(true);
@@ -21,7 +21,7 @@ export const NotificationProvider: React.FC<{ children: React.ReactNode }> = ({
} finally {
setLoading(false);
}
}, [orgId, isSignedIn, notifications.length]);
}, [isSignedIn, notifications.length]);
const markAsRead = async (id: string) => {
try {
@@ -70,7 +70,7 @@ export const NotificationProvider: React.FC<{ children: React.ReactNode }> = ({
// Polling effect
useEffect(() => {
if (isSignedIn && orgId) {
if (isSignedIn) {
fetchNotifications(); // Initial fetch
const interval = setInterval(() => {
@@ -81,7 +81,7 @@ export const NotificationProvider: React.FC<{ children: React.ReactNode }> = ({
} else {
setNotifications([]);
}
}, [isSignedIn, orgId, fetchNotifications]);
}, [isSignedIn, fetchNotifications]);
const unreadCount = notifications.filter(n => !n.isRead).length;