Refactor: Centralized Supabase Auth and implemented Auth Guards to prevent 401 errors
This commit is contained in:
@@ -10,6 +10,7 @@ import { closeSession } from '@/services/close-session';
|
||||
import { useSession } from '@/context/SessionContext';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
import { useI18n } from '@/i18n/I18nContext';
|
||||
import { useAuth } from '@/context/AuthContext';
|
||||
import SessionTimeline from '@/components/SessionTimeline';
|
||||
import SessionABVCurve from '@/components/SessionABVCurve';
|
||||
import OfflineIndicator from '@/components/OfflineIndicator';
|
||||
@@ -65,6 +66,7 @@ export default function SessionDetailPage() {
|
||||
const [tastings, setTastings] = useState<SessionTasting[]>([]);
|
||||
const [allBuddies, setAllBuddies] = useState<Buddy[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { user, isLoading: isAuthLoading } = useAuth();
|
||||
const { activeSession, setActiveSession } = useSession();
|
||||
const [isAddingParticipant, setIsAddingParticipant] = useState(false);
|
||||
const [isDeleting, setIsDeleting] = useState(false);
|
||||
@@ -72,7 +74,9 @@ export default function SessionDetailPage() {
|
||||
const [isBulkScanOpen, setIsBulkScanOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetchSessionData();
|
||||
if (!isAuthLoading && user) {
|
||||
fetchSessionData();
|
||||
}
|
||||
|
||||
// Subscribe to bottle updates for realtime processing status
|
||||
const channel = supabase
|
||||
|
||||
Reference in New Issue
Block a user