Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 104x 104x 104x 104x 104x 104x 104x 104x 104x 52x 52x 52x 52x 1x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 39x 39x 39x 13x 13x 13x 13x 13x 13x 13x 13x 26x 26x 26x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 12x 12x 12x 1x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 39x 39x 39x 39x 39x 39x 52x 52x 52x 39x 39x 39x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 26x 26x 26x 26x 26x 26x 26x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x | 'use client';
import { GraduationCap, Clock, IndianRupee, Users, Globe, Calendar } from 'lucide-react';
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import type { TutorProfile } from '@/types/database';
// Schedule can be either object format or string range format
type TimeSlot = { start: string; end: string } | string;
interface AvailabilitySchedule {
[key: string]: TimeSlot[];
}
interface TutorSectionProps {
tutorProfile: TutorProfile;
}
const DAYS_ORDER = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
const DAY_LABELS: Record<string, string> = {
monday: 'Mon',
tuesday: 'Tue',
wednesday: 'Wed',
thursday: 'Thu',
friday: 'Fri',
saturday: 'Sat',
sunday: 'Sun',
};
function formatTime(time: string | undefined): string {
if (!time) return '';
const [hours, minutes] = time.split(':');
const hour = parseInt(hours);
if (isNaN(hour)) return time;
const ampm = hour >= 12 ? 'PM' : 'AM';
const displayHour = hour % 12 || 12;
return `${displayHour}:${minutes} ${ampm}`;
}
function formatSlot(slot: TimeSlot): string {
if (typeof slot === 'string') {
// Handle "16:00-20:00" string format
const [start, end] = slot.split('-');
return `${formatTime(start)} - ${formatTime(end)}`;
}
// Handle { start, end } object format
return `${formatTime(slot.start)} - ${formatTime(slot.end)}`;
}
export function TutorSection({ tutorProfile }: TutorSectionProps) {
const schedule = (tutorProfile.availability_schedule as AvailabilitySchedule) || {};
const availableDays = DAYS_ORDER.filter((day) => schedule[day] && schedule[day].length > 0);
return (
<div className="space-y-8">
{/* Subjects & Grade Levels */}
<div className="space-y-4">
{tutorProfile.subjects && (tutorProfile.subjects as string[]).length > 0 && (
<div>
<h3 className="mb-2 text-sm font-medium text-muted-foreground">Subjects</h3>
<div className="flex flex-wrap gap-2">
{(tutorProfile.subjects as string[]).map((subject: string) => (
<Badge key={subject} variant="secondary">
{subject}
</Badge>
))}
</div>
</div>
)}
{tutorProfile.grade_levels && (tutorProfile.grade_levels as string[]).length > 0 && (
<div>
<h3 className="mb-2 text-sm font-medium text-muted-foreground">Grade Levels</h3>
<div className="flex flex-wrap gap-2">
{(tutorProfile.grade_levels as string[]).map((level: string) => (
<Badge key={level} variant="outline">
{level}
</Badge>
))}
</div>
</div>
)}
</div>
{/* Info Cards */}
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{/* Rate Card */}
{tutorProfile.hourly_rate_inr && (
<Card>
<CardContent className="flex items-center gap-3 pt-4">
<div className="rounded-lg bg-primary/10 p-2">
<IndianRupee className="h-5 w-5 text-primary" />
</div>
<div>
<p className="text-sm text-muted-foreground">Hourly Rate</p>
<p className="text-lg font-semibold">
₹{(tutorProfile.hourly_rate_inr / 100).toLocaleString()}/hr
</p>
</div>
</CardContent>
</Card>
)}
{/* Trial Session Card */}
{tutorProfile.trial_duration_minutes && (
<Card>
<CardContent className="flex items-center gap-3 pt-4">
<div className="rounded-lg bg-green-500/10 p-2">
<Clock className="h-5 w-5 text-green-600" />
</div>
<div>
<p className="text-sm text-muted-foreground">Trial Session</p>
<p className="text-lg font-semibold">
{tutorProfile.trial_session_price === 0
? 'Free'
: `₹${((tutorProfile.trial_session_price || 0) / 100).toLocaleString()}`}
<span className="text-sm font-normal text-muted-foreground">
{' '}
({tutorProfile.trial_duration_minutes} min)
</span>
</p>
</div>
</CardContent>
</Card>
)}
{/* Experience Card */}
{tutorProfile.years_experience && tutorProfile.years_experience > 0 && (
<Card>
<CardContent className="flex items-center gap-3 pt-4">
<div className="rounded-lg bg-purple-500/10 p-2">
<GraduationCap className="h-5 w-5 text-purple-600" />
</div>
<div>
<p className="text-sm text-muted-foreground">Experience</p>
<p className="text-lg font-semibold">{tutorProfile.years_experience}+ years</p>
</div>
</CardContent>
</Card>
)}
</div>
{/* Status & Booking */}
<div className="flex flex-wrap items-center gap-3">
{tutorProfile.is_accepting_students ? (
<Badge className="bg-green-500/10 text-green-600">
<Users className="mr-1 h-3 w-3" />
Accepting Students
</Badge>
) : (
<Badge variant="secondary">Not Accepting Students</Badge>
)}
{tutorProfile.instant_booking && <Badge variant="outline">Instant Booking</Badge>}
{tutorProfile.teaching_modes && tutorProfile.teaching_modes.length > 0 && (
<>
{tutorProfile.teaching_modes.includes('online') && (
<Badge variant="outline">Online</Badge>
)}
{tutorProfile.teaching_modes.includes('in_person') && (
<Badge variant="outline">In-Person</Badge>
)}
</>
)}
</div>
{/* Teaching Languages */}
{tutorProfile.teaching_languages && tutorProfile.teaching_languages.length > 0 && (
<div className="flex items-center gap-2">
<Globe className="h-4 w-4 text-muted-foreground" />
<span className="text-sm text-muted-foreground">Teaches in:</span>
<span className="text-sm">{tutorProfile.teaching_languages.join(', ')}</span>
</div>
)}
{/* Availability Schedule */}
{availableDays.length > 0 && (
<div>
<h3 className="mb-3 flex items-center gap-2 text-lg font-semibold">
<Calendar className="h-5 w-5" />
Weekly Availability
</h3>
<Card>
<CardContent className="divide-y pt-4">
{availableDays.map((day) => (
<div
key={day}
className="flex items-center justify-between py-2 first:pt-0 last:pb-0"
>
<span className="font-medium">{DAY_LABELS[day]}</span>
<div className="flex flex-wrap gap-2">
{schedule[day].map((slot, idx) => (
<Badge key={idx} variant="secondary" className="text-xs">
{formatSlot(slot)}
</Badge>
))}
</div>
</div>
))}
</CardContent>
</Card>
{tutorProfile.timezone && (
<p className="mt-2 text-xs text-muted-foreground">
Times shown in {tutorProfile.timezone}
</p>
)}
</div>
)}
{/* Qualifications */}
{tutorProfile.qualifications && (tutorProfile.qualifications as unknown[]).length > 0 && (
<div>
<h3 className="mb-2 text-sm font-medium text-muted-foreground">Qualifications</h3>
<div className="flex flex-wrap gap-2">
{(tutorProfile.qualifications as unknown[]).map((qual, idx) => {
const label =
typeof qual === 'string'
? qual
: typeof qual === 'object' && qual !== null
? [
(qual as Record<string, unknown>).title,
(qual as Record<string, unknown>).institution,
(qual as Record<string, unknown>).year,
]
.filter(Boolean)
.join(' - ')
: String(qual);
return (
<Badge key={`${label}-${idx}`} variant="outline">
{label}
</Badge>
);
})}
</div>
</div>
)}
{/* Education */}
{tutorProfile.education && (
<div>
<h3 className="mb-2 text-sm font-medium text-muted-foreground">Education</h3>
<p className="text-sm">{tutorProfile.education}</p>
</div>
)}
</div>
);
}
|