Skip to content

Commit 62edc67

Browse files
committed
feat(ui): new lesson card for tutors
1 parent 655246c commit 62edc67

File tree

4 files changed

+79
-60
lines changed

4 files changed

+79
-60
lines changed

apps/web/src/components/UpcomingLessons/Content.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import { Button } from "@litespace/ui/Button";
2828
import { UNCANCELLABLE_LESSON_HOURS } from "@litespace/utils";
2929
import CloseCircle from "@litespace/assets/CloseCircle";
3030
import { ConfirmationDialog } from "@litespace/ui/ConfirmationDialog";
31-
// import { range } from "lodash";
32-
// import { faker } from "@faker-js/faker/locale/ar";
3331

3432
type Lessons = ILesson.FindUserLessonsApiResponse["list"];
3533

@@ -145,6 +143,7 @@ export const Content: React.FC<{
145143
<div>
146144
<div className="grid grid-cols-[repeat(auto-fill,minmax(385px,1fr))] gap-x-2 md:gap-x-3 gap-y-4 md:gap-y-6">
147145
{list.map((item) => {
146+
console.log("list", item.lesson);
148147
const tutor = item.members.find(
149148
(member) =>
150149
member.role === IUser.Role.Tutor ||
@@ -154,7 +153,7 @@ export const Content: React.FC<{
154153
const otherMember = item.members.find(
155154
(member) => member.role !== user.role
156155
);
157-
156+
console.log("members: ", item.members);
158157
if (!tutor || !otherMember) return null;
159158
return (
160159
<motion.div
@@ -212,8 +211,8 @@ export const Content: React.FC<{
212211
otherMember.role === IUser.Role.Student
213212
? "student"
214213
: "tutor",
215-
// topics: range(7).map(() => faker.lorem.words(1)),
216-
// level: "C1",
214+
// topics: ,
215+
// level: "A1",
217216
}}
218217
sendingMessage={sendingMessageLessonId === item.lesson.id}
219218
disabled={!!sendingMessageLessonId}

packages/ui/src/components/Lessons/LessonCard.stories.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const BeforeJoinForStudent: Story = {
3232
image: url,
3333
role: "tutor",
3434
topics: range(7).map(() => faker.lorem.words(1)),
35-
level: "C1",
3635
},
3736
...actions,
3837
},
@@ -133,8 +132,7 @@ export const AfterLessonFinishForStudent: Story = {
133132
name: faker.person.fullName(),
134133
image: url,
135134
role: "tutor",
136-
topics: range(7).map(() => faker.lorem.words(1)),
137-
level: "C1",
135+
topics: range(9).map(() => faker.lorem.words(1)),
138136
},
139137
...actions,
140138
},

packages/ui/src/components/Lessons/LessonCard.tsx

Lines changed: 71 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export type Props = {
2828
* @note role shall be `student` when the current user is tutor and vice versa
2929
*/
3030
role: "tutor" | "student";
31-
topics: Array<string>;
32-
level: string;
31+
topics?: string[];
32+
level?: string;
3333
};
3434

3535
sendingMessage: boolean;
@@ -138,10 +138,12 @@ export const LessonCard: React.FC<Props> = ({
138138
}, [getTitle]);
139139

140140
const isEnded = useMemo(() => end.isBefore(dayjs()), [end]);
141+
141142
const isOngoing = useMemo(
142143
() => !canceled && dayjs().isBetween(dayjs(start), end),
143144
[canceled, start, end]
144145
);
146+
145147
const isFuture = useMemo(
146148
() => !canceled && dayjs().isBefore(dayjs(start)),
147149
[canceled, start]
@@ -203,8 +205,8 @@ export const LessonCard: React.FC<Props> = ({
203205
}, [canceled, currentUserRole, isEnded, intl, onJoin, onRebook, onSendMsg]);
204206

205207
const buttonType = useMemo(
206-
() => (currentUserRole === "tutor" && isOngoing ? "main" : "natural"),
207-
[currentUserRole, isOngoing]
208+
() => (isOngoing ? "main" : "natural"),
209+
[isOngoing]
208210
);
209211

210212
const button = (
@@ -216,15 +218,21 @@ export const LessonCard: React.FC<Props> = ({
216218
onClick={action.onClick}
217219
loading={sendingMessage}
218220
>
219-
<Typography
220-
tag="span"
221-
className={cn(
222-
"text-caption font-semibold",
223-
isOngoing ? "text-natural-50" : "text-natural-700"
224-
)}
225-
>
226-
{action.label}
227-
</Typography>
221+
{isOngoing ? (
222+
<Typography
223+
tag="span"
224+
className={cn("text-caption font-semibold text-natural-50")}
225+
>
226+
{action.label}
227+
</Typography>
228+
) : (
229+
<Typography
230+
tag="span"
231+
className="text-caption font-semibold text-natural-700"
232+
>
233+
{action.label}
234+
</Typography>
235+
)}
228236
</Button>
229237
);
230238

@@ -261,28 +269,35 @@ export const LessonCard: React.FC<Props> = ({
261269
>
262270
{title}
263271
</Typography>
272+
264273
{!canceled ? (
265-
<Menu actions={actions}>
266-
<More className="[&>*]:fill-natural-800 w-4 h-1" />
267-
</Menu>
274+
<div className="border border-natural-100 rounded-lg py-1 px-2">
275+
<Menu actions={actions}>
276+
<More className="w-4 h-1 transform -rotate-90 [&>*]:fill-natural-800" />
277+
</Menu>
278+
</div>
268279
) : null}
269280
</>
270281
)}
271282
</div>
283+
272284
<div className="flex flex-col gap-6">
273285
<div className="flex gap-2">
274286
<div className="relative min-w-[74px] min-h-[74px] aspect-square shrink-0">
275-
<div
276-
className={cn(
277-
"absolute w-[19px] h-[19px] right-0 top-0 p-0.5 bg-success-700 rounded-full z-10",
278-
"flex items-center justify-center"
279-
)}
280-
>
281-
<Typography tag="span" className="text-natural-0 text-[10px]">
282-
{member.level}
283-
</Typography>
284-
</div>
285-
<div className="w-full h-full rounded-full overflow-hidden">
287+
{currentUserRole === "tutor" ? (
288+
<div
289+
className={cn(
290+
"absolute w-[19px] h-[19px] right-0 top-0 p-0.5 bg-success-700 rounded-full z-10",
291+
"flex items-center justify-center"
292+
)}
293+
>
294+
<Typography tag="span" className="text-natural-0 text-[10px]">
295+
{member.level}
296+
</Typography>
297+
</div>
298+
) : null}
299+
300+
<div className="w-full h-full max-w-[75px] max-h-[75px] rounded-full overflow-hidden">
286301
<AvatarV2 src={member.image} alt={member.name} id={member.id} />
287302
</div>
288303
</div>
@@ -299,10 +314,10 @@ export const LessonCard: React.FC<Props> = ({
299314
<Clock className="w-3.5 h-3.5" />
300315
<Typography
301316
tag="span"
302-
className="text-natural-700 flex items-center text-tiny font-normal"
317+
className="flex items-center text-tiny text-natural-700"
303318
>
304319
{dayjs(start).format("h:mm a")}
305-
{" - "}
320+
{" الي "}
306321
{dayjs(start).add(duration, "minutes").format("h:mm a")}
307322
</Typography>
308323
</div>
@@ -318,26 +333,31 @@ export const LessonCard: React.FC<Props> = ({
318333
</div>
319334
</div>
320335

321-
<div className="mt-2 flex items-center gap-1">
322-
{member.topics.slice(0, 4).map((topic) => (
323-
<Typography
324-
key={topic}
325-
tag="span"
326-
className="border border-natural-500 rounded-[200px] px-1.5 py-1"
327-
>
328-
{topic}
329-
</Typography>
330-
))}
331-
{member.topics.length > 4 && (
332-
<Typography
333-
key="remaining"
334-
tag="span"
335-
className="border border-natural-500 rounded-[200px] px-1.5 py-1"
336-
>
337-
{member.topics.length - 4}+
338-
</Typography>
339-
)}
340-
</div>
336+
{currentUserRole === "tutor" &&
337+
member.topics &&
338+
member.topics.length > 0 ? (
339+
<div className="mt-2 flex items-center gap-1">
340+
{member.topics.slice(0, 4).map((topic) => (
341+
<Typography
342+
key={topic}
343+
tag="span"
344+
className="text-tiny text-natural-500 border border-natural-500 rounded-[200px] px-1.5 py-1"
345+
>
346+
{topic}
347+
</Typography>
348+
))}
349+
350+
{member.topics.length > 4 && (
351+
<Typography
352+
key="remaining"
353+
tag="span"
354+
className="text-tiny text-natural-500 border border-natural-500 rounded-[200px] px-1.5 py-1"
355+
>
356+
{member.topics.length - 4}+
357+
</Typography>
358+
)}
359+
</div>
360+
) : null}
341361
</div>
342362
</div>
343363
<div className="flex gap-4">
@@ -346,7 +366,9 @@ export const LessonCard: React.FC<Props> = ({
346366
<Button
347367
startIcon={<AllMessages className="icon w-4 h-4" />}
348368
type="natural"
369+
variant="secondary"
349370
size="large"
371+
onClick={onSendMsg}
350372
/>
351373
)}
352374
</div>

packages/ui/src/locales/ar-eg.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,12 @@
829829
"lessons.loading-error": "عذرًا، حدث خطأ أثناء تحميل جدول الحصص، برجاء المحاولة مرة أخرى",
830830
"lessons.button.rebook": "إعادة الحجز",
831831
"lessons.button.join": "دخول الحصة",
832-
"lessons.button.send-message": "إرسال رسالة",
832+
"lessons.button.send-message": "تواصل مع الطالب",
833833
"lessons.button.contact-student": "تواصل مع الطالب",
834834
"lessons.button.find-tutors": "تصفح المعلمين",
835-
"lessons.canceled-by-tutor": "لقد تم إلغاء الحصة من قبل المعلم",
835+
"lessons.canceled-by-tutor": "لقد قام المعلم بألغاء الدرس",
836836
"lessons.canceled-by-student": "لقد قام الطالب بإلغاء الحصة",
837-
"lessons.canceled-by-you": "لقد قمت بإلغاء الحصة",
837+
"lessons.canceled-by-you": "لقد قمت انت بألغاء الحصة",
838838
"lessons.reported-by-you": "تم الإبلاغ عن الحصة",
839839
"lessons.time-to-join": "باقي علي الجلسة {value}",
840840
"lessons.time-to-end-lesson": "باقي علي انتهاء الجلسة {value}",

0 commit comments

Comments
 (0)