mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 05:31:13 -05:00
Fix remaining compliance violations
This commit is contained in:
@@ -273,20 +273,24 @@ export function ContentTabs() {
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7 3xl:grid-cols-8 gap-4 lg:gap-5 xl:gap-4 2xl:gap-5">
|
||||
{recentlyOpened.map((entity: any) => (
|
||||
{recentlyOpened.map((entity) => (
|
||||
entity.entityType === 'park' ? (
|
||||
<div key={entity.id} className="relative">
|
||||
<ParkCard park={entity} />
|
||||
<Badge className="absolute top-2 right-2 bg-green-500/90 text-white backdrop-blur-sm">
|
||||
{new Date(entity.opening_date).getFullYear()}
|
||||
</Badge>
|
||||
{entity.opening_date && (
|
||||
<Badge className="absolute top-2 right-2 bg-green-500/90 text-white backdrop-blur-sm">
|
||||
{new Date(entity.opening_date).getFullYear()}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div key={entity.id} className="relative">
|
||||
<RideCard ride={entity} />
|
||||
<Badge className="absolute top-2 right-2 bg-green-500/90 text-white backdrop-blur-sm">
|
||||
{new Date(entity.opening_date).getFullYear()}
|
||||
</Badge>
|
||||
{entity.opening_date && (
|
||||
<Badge className="absolute top-2 right-2 bg-green-500/90 text-white backdrop-blur-sm">
|
||||
{new Date(entity.opening_date).getFullYear()}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
))}
|
||||
|
||||
@@ -19,10 +19,11 @@ export function NotificationCenter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const handleNotificationClick = (notification: any) => {
|
||||
const handleNotificationClick = (notification: { data?: Record<string, unknown> }) => {
|
||||
// Handle navigation based on notification payload
|
||||
if (notification.data?.url) {
|
||||
navigate(notification.data.url);
|
||||
const data = notification.data as { url?: string } | undefined;
|
||||
if (data?.url) {
|
||||
navigate(data.url);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ import { useAuth } from './useAuth';
|
||||
import { useUserRole } from './useUserRole';
|
||||
import { useToast } from './use-toast';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import type { Json } from '@/integrations/supabase/types';
|
||||
|
||||
interface AdminSetting {
|
||||
id: string;
|
||||
setting_key: string;
|
||||
setting_value: any;
|
||||
setting_value: unknown;
|
||||
category: string;
|
||||
description: string;
|
||||
}
|
||||
@@ -46,11 +47,11 @@ export function useAdminSettings() {
|
||||
}, [settings]);
|
||||
|
||||
const updateSettingMutation = useMutation({
|
||||
mutationFn: async ({ key, value }: { key: string; value: any }) => {
|
||||
mutationFn: async ({ key, value }: { key: string; value: unknown }) => {
|
||||
const { error } = await supabase
|
||||
.from('admin_settings')
|
||||
.update({
|
||||
setting_value: value,
|
||||
setting_value: value as Json,
|
||||
updated_by: user?.id,
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
@@ -65,7 +66,7 @@ export function useAdminSettings() {
|
||||
description: "The setting has been saved successfully.",
|
||||
});
|
||||
},
|
||||
onError: (error: any) => {
|
||||
onError: (error: Error) => {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to update setting",
|
||||
@@ -74,17 +75,17 @@ export function useAdminSettings() {
|
||||
}
|
||||
});
|
||||
|
||||
const getSettingValue = useCallback((key: string, defaultValue: any = null) => {
|
||||
const getSettingValue = useCallback((key: string, defaultValue: unknown = null) => {
|
||||
return settingsMap[key] ?? defaultValue;
|
||||
}, [settingsMap]);
|
||||
|
||||
const updateSetting = async (key: string, value: any) => {
|
||||
const updateSetting = async (key: string, value: unknown) => {
|
||||
return updateSettingMutation.mutateAsync({ key, value });
|
||||
};
|
||||
|
||||
// Helper functions for common settings (memoized with useCallback for stable references)
|
||||
const getAutoFlagThreshold = useCallback(() => {
|
||||
return parseInt(getSettingValue('moderation.auto_flag_threshold', '3'));
|
||||
return parseInt(String(getSettingValue('moderation.auto_flag_threshold', '3')));
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getRequireApproval = useCallback(() => {
|
||||
@@ -94,7 +95,7 @@ export function useAdminSettings() {
|
||||
|
||||
const getBanDurations = useCallback(() => {
|
||||
const value = getSettingValue('moderation.ban_durations', ['1d', '7d', '30d', 'permanent']);
|
||||
return Array.isArray(value) ? value : JSON.parse(value || '[]');
|
||||
return Array.isArray(value) ? value : JSON.parse(String(value || '[]'));
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getEmailAlertsEnabled = useCallback(() => {
|
||||
@@ -103,11 +104,11 @@ export function useAdminSettings() {
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getReportThreshold = useCallback(() => {
|
||||
return parseInt(getSettingValue('notifications.report_threshold', '5'));
|
||||
return parseInt(String(getSettingValue('notifications.report_threshold', '5')));
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getAuditRetentionDays = useCallback(() => {
|
||||
return parseInt(getSettingValue('system.audit_retention_days', '365'));
|
||||
return parseInt(String(getSettingValue('system.audit_retention_days', '365')));
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getAutoCleanupEnabled = useCallback(() => {
|
||||
@@ -115,10 +116,11 @@ export function useAdminSettings() {
|
||||
return value === true || value === 'true';
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getAdminPanelRefreshMode = useCallback(() => {
|
||||
const getAdminPanelRefreshMode = useCallback((): 'auto' | 'manual' => {
|
||||
const value = getSettingValue('system.admin_panel_refresh_mode', 'auto');
|
||||
// Remove quotes if they exist (JSON string stored in DB)
|
||||
return typeof value === 'string' ? value.replace(/"/g, '') : value;
|
||||
const cleanValue = typeof value === 'string' ? value.replace(/"/g, '') : String(value);
|
||||
return (cleanValue === 'manual' ? 'manual' : 'auto') as 'auto' | 'manual';
|
||||
}, [getSettingValue]);
|
||||
|
||||
const getAdminPanelPollInterval = useCallback(() => {
|
||||
|
||||
@@ -1137,7 +1137,7 @@ export async function rejectSubmissionItems(
|
||||
.eq('id', itemId);
|
||||
|
||||
if (error) {
|
||||
console.error(`Error rejecting item ${itemId}:`, error);
|
||||
logger.error('Error rejecting item', { error, itemId });
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
@@ -1171,7 +1171,7 @@ async function updateSubmissionStatusAfterRejection(submissionId: string): Promi
|
||||
.eq('submission_id', submissionId);
|
||||
|
||||
if (fetchError) {
|
||||
console.error('Error fetching submission items:', fetchError);
|
||||
logger.error('Error fetching submission items', { error: fetchError, submissionId });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1202,7 +1202,7 @@ async function updateSubmissionStatusAfterRejection(submissionId: string): Promi
|
||||
.eq('id', submissionId);
|
||||
|
||||
if (updateError) {
|
||||
console.error('Error updating submission status:', updateError);
|
||||
logger.error('Error updating submission status', { error: updateError, submissionId });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user