mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 11:51:14 -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 { 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 { 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 { useToast } from '@/hooks/use-toast';
|
||||
import { PhotoUpload } from '@/components/upload/PhotoUpload';
|
||||
@@ -693,38 +693,37 @@ export default function Profile() {
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
{activity.type === 'review' ? (
|
||||
<>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<p className="font-medium">
|
||||
{activity.title || 'Left a review'}
|
||||
</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 className="flex items-center gap-1 mb-2">
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<Star key={i} className={`w-3 h-3 ${i < (activity.rating || 0) ? 'fill-accent text-accent' : 'text-muted-foreground'}`} />
|
||||
))}
|
||||
</div>
|
||||
{(activity as any).park_id && activity.parks ? (
|
||||
<Link to={`/parks/${activity.parks.slug || ''}`} className="text-sm text-muted-foreground hover:text-accent transition-colors">
|
||||
{activity.parks.name || 'Unknown Park'}
|
||||
</Link>
|
||||
) : (activity as any).ride_id && activity.rides ? (
|
||||
<div className="text-sm text-muted-foreground">
|
||||
<Link to={`/parks/${activity.rides.parks?.slug || ''}/rides/${activity.rides.slug || ''}`} className="hover:text-accent transition-colors">
|
||||
{activity.rides.name || 'Unknown Ride'}
|
||||
</Link>
|
||||
{activity.rides.parks && (
|
||||
<span className="text-muted-foreground/70"> at {activity.rides.parks.name || 'Unknown Park'}</span>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
(() => {
|
||||
const reviewActivity = activity as ReviewActivity;
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<p className="font-medium">
|
||||
{reviewActivity.title || reviewActivity.description || 'Left a review'}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 mb-2">
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<Star key={i} className={`w-3 h-3 ${i < (reviewActivity.rating ?? 0) ? 'fill-accent text-accent' : 'text-muted-foreground'}`} />
|
||||
))}
|
||||
</div>
|
||||
{reviewActivity.parks ? (
|
||||
<Link to={`/parks/${reviewActivity.parks.slug || ''}`} className="text-sm text-muted-foreground hover:text-accent transition-colors">
|
||||
{reviewActivity.parks.name || 'Unknown Park'}
|
||||
</Link>
|
||||
) : reviewActivity.rides ? (
|
||||
<div className="text-sm text-muted-foreground">
|
||||
<Link to={`/parks/${reviewActivity.rides.parks?.slug || ''}/rides/${reviewActivity.rides.slug || ''}`} className="hover:text-accent transition-colors">
|
||||
{reviewActivity.rides.name || 'Unknown Ride'}
|
||||
</Link>
|
||||
{reviewActivity.rides.parks && (
|
||||
<span className="text-muted-foreground/70"> at {reviewActivity.rides.parks.name || 'Unknown Park'}</span>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
})()
|
||||
) : activity.type === 'submission' ? (
|
||||
<>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
|
||||
@@ -288,7 +288,7 @@ export type ActivityEntry =
|
||||
| RankingActivity
|
||||
| GenericActivity;
|
||||
|
||||
interface ReviewActivity {
|
||||
export interface ReviewActivity {
|
||||
id: string;
|
||||
type: 'review';
|
||||
created_at: string;
|
||||
@@ -300,7 +300,7 @@ interface ReviewActivity {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface SubmissionActivity {
|
||||
export interface SubmissionActivity {
|
||||
id: string;
|
||||
type: 'submission';
|
||||
created_at: string;
|
||||
@@ -310,7 +310,7 @@ interface SubmissionActivity {
|
||||
action?: string;
|
||||
}
|
||||
|
||||
interface RankingActivity {
|
||||
export interface RankingActivity {
|
||||
id: string;
|
||||
type: 'ranking';
|
||||
created_at: string;
|
||||
@@ -319,7 +319,7 @@ interface RankingActivity {
|
||||
position?: number;
|
||||
}
|
||||
|
||||
interface GenericActivity {
|
||||
export interface GenericActivity {
|
||||
id: string;
|
||||
type?: string;
|
||||
created_at: string;
|
||||
|
||||
Reference in New Issue
Block a user