mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-28 22:06:58 -05:00
Compare commits
3 Commits
de7b3fdea4
...
4e4876997e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e4876997e | ||
|
|
47607c55e2 | ||
|
|
13969b32e4 |
@@ -1,6 +1,7 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { queryKeys } from '@/lib/queryKeys';
|
import { queryKeys } from '@/lib/queryKeys';
|
||||||
|
import { toDateOnly } from '@/lib/dateUtils';
|
||||||
|
|
||||||
export function useHomepageRecentlyClosedParks(enabled = true) {
|
export function useHomepageRecentlyClosedParks(enabled = true) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -13,9 +14,9 @@ export function useHomepageRecentlyClosedParks(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('parks')
|
.from('parks')
|
||||||
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
||||||
.gte('closed_date', oneYearAgo.toISOString())
|
.gte('closing_date', toDateOnly(oneYearAgo))
|
||||||
.lte('closed_date', today.toISOString())
|
.lte('closing_date', toDateOnly(today))
|
||||||
.order('closed_date', { ascending: false })
|
.order('closing_date', { ascending: false })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
@@ -39,9 +40,9 @@ export function useHomepageRecentlyClosedRides(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('rides')
|
.from('rides')
|
||||||
.select(`*, park:parks(*, location:locations(*))`)
|
.select(`*, park:parks(*, location:locations(*))`)
|
||||||
.gte('closed_date', oneYearAgo.toISOString())
|
.gte('closing_date', toDateOnly(oneYearAgo))
|
||||||
.lte('closed_date', today.toISOString())
|
.lte('closing_date', toDateOnly(today))
|
||||||
.order('closed_date', { ascending: false })
|
.order('closing_date', { ascending: false })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { queryKeys } from '@/lib/queryKeys';
|
import { queryKeys } from '@/lib/queryKeys';
|
||||||
|
import { toDateOnly } from '@/lib/dateUtils';
|
||||||
|
|
||||||
export function useHomepageClosingSoonParks(enabled = true) {
|
export function useHomepageClosingSoonParks(enabled = true) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -13,9 +14,9 @@ export function useHomepageClosingSoonParks(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('parks')
|
.from('parks')
|
||||||
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
||||||
.gte('closed_date', today.toISOString())
|
.gte('closing_date', toDateOnly(today))
|
||||||
.lte('closed_date', sixMonthsFromNow.toISOString())
|
.lte('closing_date', toDateOnly(sixMonthsFromNow))
|
||||||
.order('closed_date', { ascending: true })
|
.order('closing_date', { ascending: true })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
@@ -39,9 +40,9 @@ export function useHomepageClosingSoonRides(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('rides')
|
.from('rides')
|
||||||
.select(`*, park:parks(*, location:locations(*))`)
|
.select(`*, park:parks(*, location:locations(*))`)
|
||||||
.gte('closed_date', today.toISOString())
|
.gte('closing_date', toDateOnly(today))
|
||||||
.lte('closed_date', sixMonthsFromNow.toISOString())
|
.lte('closing_date', toDateOnly(sixMonthsFromNow))
|
||||||
.order('closed_date', { ascending: true })
|
.order('closing_date', { ascending: true })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { queryKeys } from '@/lib/queryKeys';
|
import { queryKeys } from '@/lib/queryKeys';
|
||||||
|
import { toDateOnly } from '@/lib/dateUtils';
|
||||||
|
|
||||||
export function useHomepageRecentlyOpenedParks(enabled = true) {
|
export function useHomepageRecentlyOpenedParks(enabled = true) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -12,8 +13,8 @@ export function useHomepageRecentlyOpenedParks(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('parks')
|
.from('parks')
|
||||||
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
||||||
.gte('opened_date', oneYearAgo.toISOString())
|
.gte('opening_date', toDateOnly(oneYearAgo))
|
||||||
.order('opened_date', { ascending: false })
|
.order('opening_date', { ascending: false })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
@@ -36,8 +37,8 @@ export function useHomepageRecentlyOpenedRides(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('rides')
|
.from('rides')
|
||||||
.select(`*, park:parks(*, location:locations(*))`)
|
.select(`*, park:parks(*, location:locations(*))`)
|
||||||
.gte('opened_date', oneYearAgo.toISOString())
|
.gte('opening_date', toDateOnly(oneYearAgo))
|
||||||
.order('opened_date', { ascending: false })
|
.order('opening_date', { ascending: false })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { queryKeys } from '@/lib/queryKeys';
|
import { queryKeys } from '@/lib/queryKeys';
|
||||||
|
import { toDateOnly } from '@/lib/dateUtils';
|
||||||
|
|
||||||
export function useHomepageOpeningSoonParks(enabled = true) {
|
export function useHomepageOpeningSoonParks(enabled = true) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -13,9 +14,9 @@ export function useHomepageOpeningSoonParks(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('parks')
|
.from('parks')
|
||||||
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
.select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`)
|
||||||
.gte('opened_date', today.toISOString())
|
.gte('opening_date', toDateOnly(today))
|
||||||
.lte('opened_date', sixMonthsFromNow.toISOString())
|
.lte('opening_date', toDateOnly(sixMonthsFromNow))
|
||||||
.order('opened_date', { ascending: true })
|
.order('opening_date', { ascending: true })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
@@ -39,9 +40,9 @@ export function useHomepageOpeningSoonRides(enabled = true) {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('rides')
|
.from('rides')
|
||||||
.select(`*, park:parks(*, location:locations(*))`)
|
.select(`*, park:parks(*, location:locations(*))`)
|
||||||
.gte('opened_date', today.toISOString())
|
.gte('opening_date', toDateOnly(today))
|
||||||
.lte('opened_date', sixMonthsFromNow.toISOString())
|
.lte('opening_date', toDateOnly(sixMonthsFromNow))
|
||||||
.order('opened_date', { ascending: true })
|
.order('opening_date', { ascending: true })
|
||||||
.limit(12);
|
.limit(12);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export function useRequireMFA() {
|
|||||||
isEnrolled,
|
isEnrolled,
|
||||||
needsEnrollment: requiresMFA && !isEnrolled,
|
needsEnrollment: requiresMFA && !isEnrolled,
|
||||||
needsVerification,
|
needsVerification,
|
||||||
|
isBlocked: requiresMFA && (!isEnrolled || (isEnrolled && aal === 'aal1')), // Convenience flag
|
||||||
aal,
|
aal,
|
||||||
loading: loading || roleLoading,
|
loading: loading || roleLoading,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default function AdminDashboard() {
|
|||||||
useDocumentTitle('Dashboard - Admin');
|
useDocumentTitle('Dashboard - Admin');
|
||||||
const { user, loading: authLoading } = useAuth();
|
const { user, loading: authLoading } = useAuth();
|
||||||
const { isModerator, loading: roleLoading } = useUserRole();
|
const { isModerator, loading: roleLoading } = useUserRole();
|
||||||
const { needsEnrollment, loading: mfaLoading } = useRequireMFA();
|
const { needsEnrollment, needsVerification, loading: mfaLoading } = useRequireMFA();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const [activeTab, setActiveTab] = useState('moderation');
|
const [activeTab, setActiveTab] = useState('moderation');
|
||||||
@@ -138,8 +138,8 @@ export default function AdminDashboard() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MFA enforcement
|
// MFA enforcement - CRITICAL: Block if EITHER not enrolled OR needs verification
|
||||||
if (needsEnrollment) {
|
if (needsEnrollment || needsVerification) {
|
||||||
return (
|
return (
|
||||||
<AdminLayout>
|
<AdminLayout>
|
||||||
<MFARequiredAlert />
|
<MFARequiredAlert />
|
||||||
|
|||||||
Reference in New Issue
Block a user