mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 12:31:26 -05:00
Fix Profile page type errors
This commit is contained in:
@@ -16,7 +16,7 @@ import { useAuth } from '@/hooks/useAuth';
|
|||||||
import { useProfile } from '@/hooks/useProfile';
|
import { useProfile } from '@/hooks/useProfile';
|
||||||
import { useUsernameValidation } from '@/hooks/useUsernameValidation';
|
import { useUsernameValidation } from '@/hooks/useUsernameValidation';
|
||||||
import { User, MapPin, Calendar, Star, Trophy, Settings, Camera, Edit3, Save, X, ArrowLeft, Check, AlertCircle, Loader2, UserX, FileText, Image } from 'lucide-react';
|
import { User, MapPin, Calendar, Star, Trophy, Settings, Camera, Edit3, Save, X, ArrowLeft, Check, AlertCircle, Loader2, UserX, FileText, Image } from 'lucide-react';
|
||||||
import { Profile as ProfileType, ActivityEntry } from '@/types/database';
|
import { Profile as ProfileType, ActivityEntry, ReviewActivity, SubmissionActivity, RankingActivity } from '@/types/database';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
import { PhotoUpload } from '@/components/upload/PhotoUpload';
|
import { PhotoUpload } from '@/components/upload/PhotoUpload';
|
||||||
@@ -693,38 +693,37 @@ export default function Profile() {
|
|||||||
|
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
{activity.type === 'review' ? (
|
{activity.type === 'review' ? (
|
||||||
|
(() => {
|
||||||
|
const reviewActivity = activity as ReviewActivity;
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center gap-2 mb-1">
|
<div className="flex items-center gap-2 mb-1">
|
||||||
<p className="font-medium">
|
<p className="font-medium">
|
||||||
{activity.title || 'Left a review'}
|
{reviewActivity.title || reviewActivity.description || 'Left a review'}
|
||||||
</p>
|
</p>
|
||||||
{(activity as any).moderation_status === 'pending' && (
|
|
||||||
<Badge variant="secondary" className="text-xs">Pending</Badge>
|
|
||||||
)}
|
|
||||||
{(activity as any).moderation_status === 'flagged' && (
|
|
||||||
<Badge variant="destructive" className="text-xs">Flagged</Badge>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1 mb-2">
|
<div className="flex items-center gap-1 mb-2">
|
||||||
{[...Array(5)].map((_, i) => (
|
{[...Array(5)].map((_, i) => (
|
||||||
<Star key={i} className={`w-3 h-3 ${i < (activity.rating || 0) ? 'fill-accent text-accent' : 'text-muted-foreground'}`} />
|
<Star key={i} className={`w-3 h-3 ${i < (reviewActivity.rating ?? 0) ? 'fill-accent text-accent' : 'text-muted-foreground'}`} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{(activity as any).park_id && activity.parks ? (
|
{reviewActivity.parks ? (
|
||||||
<Link to={`/parks/${activity.parks.slug || ''}`} className="text-sm text-muted-foreground hover:text-accent transition-colors">
|
<Link to={`/parks/${reviewActivity.parks.slug || ''}`} className="text-sm text-muted-foreground hover:text-accent transition-colors">
|
||||||
{activity.parks.name || 'Unknown Park'}
|
{reviewActivity.parks.name || 'Unknown Park'}
|
||||||
</Link>
|
</Link>
|
||||||
) : (activity as any).ride_id && activity.rides ? (
|
) : reviewActivity.rides ? (
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="text-sm text-muted-foreground">
|
||||||
<Link to={`/parks/${activity.rides.parks?.slug || ''}/rides/${activity.rides.slug || ''}`} className="hover:text-accent transition-colors">
|
<Link to={`/parks/${reviewActivity.rides.parks?.slug || ''}/rides/${reviewActivity.rides.slug || ''}`} className="hover:text-accent transition-colors">
|
||||||
{activity.rides.name || 'Unknown Ride'}
|
{reviewActivity.rides.name || 'Unknown Ride'}
|
||||||
</Link>
|
</Link>
|
||||||
{activity.rides.parks && (
|
{reviewActivity.rides.parks && (
|
||||||
<span className="text-muted-foreground/70"> at {activity.rides.parks.name || 'Unknown Park'}</span>
|
<span className="text-muted-foreground/70"> at {reviewActivity.rides.parks.name || 'Unknown Park'}</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
|
);
|
||||||
|
})()
|
||||||
) : activity.type === 'submission' ? (
|
) : activity.type === 'submission' ? (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center gap-2 mb-1">
|
<div className="flex items-center gap-2 mb-1">
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ export type ActivityEntry =
|
|||||||
| RankingActivity
|
| RankingActivity
|
||||||
| GenericActivity;
|
| GenericActivity;
|
||||||
|
|
||||||
interface ReviewActivity {
|
export interface ReviewActivity {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'review';
|
type: 'review';
|
||||||
created_at: string;
|
created_at: string;
|
||||||
@@ -300,7 +300,7 @@ interface ReviewActivity {
|
|||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SubmissionActivity {
|
export interface SubmissionActivity {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'submission';
|
type: 'submission';
|
||||||
created_at: string;
|
created_at: string;
|
||||||
@@ -310,7 +310,7 @@ interface SubmissionActivity {
|
|||||||
action?: string;
|
action?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RankingActivity {
|
export interface RankingActivity {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'ranking';
|
type: 'ranking';
|
||||||
created_at: string;
|
created_at: string;
|
||||||
@@ -319,7 +319,7 @@ interface RankingActivity {
|
|||||||
position?: number;
|
position?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GenericActivity {
|
export interface GenericActivity {
|
||||||
id: string;
|
id: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user