Skip to content

Commit 90debca

Browse files
committed
feat: lesson today and fix calendar
1 parent 4c63743 commit 90debca

3 files changed

Lines changed: 93 additions & 20 deletions

File tree

client/src/components/calendar/Calendar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const Calendar = () => {
4444
);
4545

4646
return (
47-
<div className="w-[306px] h-[319px] rounded-[24px] bg-[#1E1927] px-[24px] py-[20px] shadow-[0px_6px_58px_0px_rgba(196,203,214,0.1)]">
47+
<div className="w-[306px] h-[280px] rounded-[24px] bg-[#1E1927] px-[20px] py-[12px] shadow-[0px_6px_58px_0px_rgba(196,203,214,0.1)]">
4848
<div className="flex items-center justify-between">
4949
<Button
5050
as="button"
@@ -67,15 +67,15 @@ export const Calendar = () => {
6767
</Button>
6868
</div>
6969

70-
<div className="mt-[12px] grid grid-cols-7 gap-y-[6px] text-[10px] text-[#9A9A9A]">
70+
<div className="mt-[8px] grid grid-cols-7 gap-y-[3px] text-[10px] text-[#9A9A9A]">
7171
{WEEKDAYS.map((day) => (
7272
<div key={day} className="text-center font-medium">
7373
{day}
7474
</div>
7575
))}
7676
</div>
7777

78-
<div className="mt-[8px] grid grid-cols-7 gap-y-[6px] text-[12px] text-[#EDEDED]">
78+
<div className="mt-[4px] grid grid-cols-7 gap-y-[3px] text-[12px] text-[#EDEDED]">
7979
{days.map((date, index) => {
8080
if (!date) {
8181
return <div key={`empty-${index}`} />;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { ReactNode } from "react";
2+
3+
type LessonCardProps = {
4+
lesson: string;
5+
student: string;
6+
price: string;
7+
date: string;
8+
time: string;
9+
isPast: boolean;
10+
videoCall: ReactNode;
11+
};
12+
13+
export const LessonCard = ({
14+
lesson,
15+
student,
16+
price,
17+
date,
18+
time,
19+
isPast,
20+
videoCall,
21+
}: LessonCardProps) => {
22+
const formatDate = (dateStr: string) => {
23+
const date = new Date(dateStr);
24+
return date.toLocaleDateString("en-US", {
25+
weekday: "short",
26+
month: "short",
27+
day: "numeric",
28+
});
29+
};
30+
31+
return (
32+
<div className="bg-dark-900/30 border border-blue-500/20 rounded-[16px] p-[20px] hover:border-blue-500/40 transition-all duration-300 hover:bg-dark-900/50">
33+
<div className="flex flex-col gap-[12px]">
34+
<div className="flex items-start justify-between">
35+
<div className="flex-1">
36+
<h3 className="text-white font-medium text-[16px] mb-[4px]">
37+
{lesson}
38+
</h3>
39+
<p className="text-gray-400 text-[14px]">{student}</p>
40+
</div>
41+
<div className="text-right">
42+
<p className="text-blue-400 font-semibold text-[16px]">
43+
{price} euro
44+
</p>
45+
<p className="text-gray-400 text-[12px] mt-[2px]">
46+
{formatDate(date)}{time}
47+
</p>
48+
</div>
49+
</div>
50+
51+
<div className="flex items-center justify-between pt-[8px] border-t border-gray-700/30">
52+
<div className="flex items-center gap-[8px]">
53+
<div
54+
className={`w-[8px] h-[8px] rounded-full ${
55+
isPast ? "bg-gray-500" : "bg-green-500"
56+
}`}
57+
/>
58+
<span className="text-[12px] text-gray-400">
59+
{isPast ? "Past" : "Active"}
60+
</span>
61+
</div>
62+
63+
<div className="flex items-center">{videoCall}</div>
64+
</div>
65+
</div>
66+
</div>
67+
);
68+
};

client/src/components/teacherDashboard/MyLessonsSection.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useMemo } from "react";
2-
import LessonsTable from "../table/LessonsTable";
32
import { Calendar } from "../calendar/Calendar";
43
import { PageTitle } from "../pageTitle/PageTitle";
54
import { NumberOfStudentsCard } from "./NumberOfStudentsCard";
65
import { RequestStudentsCard } from "./RequestStudentsCard";
6+
import { LessonCard } from "./LessonCard";
77
import { useTeacherAppointmentsQuery } from "../../features/appointments/query/useTeacherAppointmentsQuery";
88
import { useRegularStudentsQuery } from "../../features/appointments/query/useRegularStudentsQuery";
99
import { useAppointmentTime } from "../../features/appointments/hooks/useAppointmentTime";
@@ -37,7 +37,7 @@ export const MyLessonsSection = () => {
3737

3838
const today = new Date().toISOString().split("T")[0];
3939

40-
const rows = useMemo(() => {
40+
const lessons = useMemo(() => {
4141
const appointments = data?.appointments ?? [];
4242
return appointments
4343
.filter((appointment) => appointment.date === today)
@@ -46,16 +46,17 @@ export const MyLessonsSection = () => {
4646

4747
return {
4848
id: appointment.id,
49-
checked: appointment.status === "approved",
5049
lesson: appointment.lesson,
5150
student: appointment.studentName || appointment.studentId || "N/A",
5251
price: appointment.price,
52+
date: appointment.date,
53+
time: appointment.time,
5354
isPast,
5455
videoCall: (
5556
<Button
5657
as="button"
5758
variant="link"
58-
className="text-white underline text-[14px] md:text-[16px] hover:text-gray-300"
59+
className="text-blue-400 underline text-[12px] hover:text-blue-300 transition-colors"
5960
onClick={() =>
6061
confirmStartCall(
6162
appointment.studentId,
@@ -74,35 +75,39 @@ export const MyLessonsSection = () => {
7475
return (
7576
<div>
7677
<PageTitle title="General" />
77-
<div className="mt-6 flex flex-col items-center justify-center gap-[40px] lg:flex-row lg:justify-between">
78+
<div className="mt-6 flex flex-col items-center justify-center gap-[24px] lg:flex-row lg:justify-between lg:gap-[40px]">
7879
<NumberOfStudentsCard count={regularStudentsCount} />
7980
<RequestStudentsCard count={requestStudentsCount} />
8081
<Calendar />
8182
</div>
8283

8384
<PageTitle title="My lessons today" />
84-
<div className="mt-[28px]">
85+
<div className="mt-[12px]">
8586
{isLoading ? (
8687
<div className="py-8 text-center text-white">Loading lessons...</div>
8788
) : error ? (
8889
<div className="py-8 text-center text-white">
8990
Error loading lessons
9091
</div>
91-
) : rows.length === 0 ? (
92+
) : lessons.length === 0 ? (
9293
<div className="py-8 text-center text-white">
9394
No lessons scheduled for today
9495
</div>
9596
) : (
96-
<LessonsTable
97-
height={290}
98-
columns={[
99-
{ key: "lesson", label: "Lessons", width: "130px" },
100-
{ key: "student", label: "Students", width: "184px" },
101-
{ key: "price", label: "Price", width: "146px" },
102-
{ key: "videoCall", label: "Video call", width: "146px" },
103-
]}
104-
rows={rows}
105-
/>
97+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-[16px]">
98+
{lessons.map((lesson) => (
99+
<LessonCard
100+
key={lesson.id}
101+
lesson={lesson.lesson}
102+
student={lesson.student}
103+
price={lesson.price}
104+
date={lesson.date}
105+
time={lesson.time}
106+
isPast={lesson.isPast}
107+
videoCall={lesson.videoCall}
108+
/>
109+
))}
110+
</div>
106111
)}
107112
</div>
108113
</div>

0 commit comments

Comments
 (0)