Skip to content

Commit 9825079

Browse files
committed
feat(ui): New Book-Lesson Dialog
1 parent 53012da commit 9825079

File tree

9 files changed

+127
-72
lines changed

9 files changed

+127
-72
lines changed
Lines changed: 15 additions & 0 deletions
Loading

packages/assets/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"./InfoCircle": "./dist/InfoCircle.tsx",
109109
"./Info": "./dist/Info.tsx",
110110
"./Instagram": "./dist/Instagram.tsx",
111+
"./LoadingV2": "./dist/LoadingV2.tsx",
111112
"./LandingHomeCta": "./dist/LandingHomeCta.tsx",
112113
"./LeftArrowHead": "./dist/LeftArrowHead.tsx",
113114
"./Linkedin": "./dist/Linkedin.tsx",

packages/ui/src/components/Dialog/Dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const Dialog: React.FC<{
163163
variant === "default" ? (
164164
<>
165165
<Optional show={!hiddenTitle}>
166-
<div className="flex justify-between items-center md:items-start w-full">
166+
<div className="flex justify-between border-b items-center md:items-start w-full">
167167
<Title>{title}</Title>
168168
<Optional show={!!close}>
169169
<Close
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Meta, StoryObj } from "@storybook/react";
2+
import { Block } from "@/components/Lessons/ManageLesson/Block";
3+
import { identity } from "lodash";
4+
5+
type Component = typeof Block;
6+
type Story = StoryObj<Component>;
7+
8+
const meta: Meta<Component> = {
9+
title: "Lessons/ManageLessonDialog/Block",
10+
component: Block,
11+
parameters: {
12+
layout: "centered",
13+
},
14+
};
15+
16+
export default meta;
17+
18+
export const Unverified: Story = {
19+
args: {
20+
type: "unverified",
21+
close: identity,
22+
submit: () => alert("Submit clicked"),
23+
},
24+
};
25+
26+
export const HasBooked: Story = {
27+
args: {
28+
type: "has-booked",
29+
close: identity,
30+
},
31+
};
32+

packages/ui/src/components/Lessons/ManageLesson/Block.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ export const Block: React.FC<{
3838
}, [type]);
3939

4040
return (
41-
<div className="px-4 md:px-0 md:w-full">
42-
<div className="w-12 h-12 flex items-center justify-center bg-brand-50 rounded-full">
43-
<div className="w-7 h-7 flex items-center justify-center bg-brand-100 rounded-full ">
44-
{<data.icon className="[&>*]:stroke-brand-700 w-6 h-6" />}
45-
</div>
46-
</div>
41+
<div className="px-4 md:px-0 md:max-w-[350px]">
4742
<div className="flex flex-col gap-1 mt-4 mb-6">
4843
<Typography
4944
tag="p"
@@ -56,13 +51,6 @@ export const Block: React.FC<{
5651
</Typography>
5752
</div>
5853
<div className="flex items-center gap-3">
59-
<Button
60-
size="large"
61-
onClick={type === "unverified" ? submit : close}
62-
className="w-full whitespace-nowrap"
63-
>
64-
{intl(data.action)}
65-
</Button>
6654

6755
{type === "unverified" ? (
6856
<Button
@@ -74,6 +62,15 @@ export const Block: React.FC<{
7462
{intl("global.labels.cancel")}
7563
</Button>
7664
) : null}
65+
66+
<Button
67+
size="large"
68+
onClick={type === "unverified" ? submit : close}
69+
className="w-full whitespace-nowrap"
70+
>
71+
{intl(data.action)}
72+
</Button>
73+
7774
</div>
7875
</div>
7976
);

packages/ui/src/components/Lessons/ManageLesson/ManageLessonDialog.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,20 @@ import { concat, isEmpty } from "lodash";
2525
import React, { useCallback, useEffect, useMemo, useState } from "react";
2626
import { arabicTimezoneNames } from "@/constants/labels";
2727
import { Block } from "@/components/Lessons/ManageLesson/Block";
28+
import { Link } from "react-router-dom";
29+
import { Web } from "@litespace/utils/routes";
2830

2931
const LoadingWrapper: React.FC<{
3032
tutorName: string | null;
31-
}> = ({ tutorName }) => {
33+
}> = () => {
3234
const intl = useFormatMessage();
3335
const { md } = useMediaQuery();
3436

3537
return (
36-
<div className="w-full flex flex-col justify-center items-center gap-8 md:mt-[109px] md:mb-[110px]">
38+
<div className="w-full flex flex-col justify-center items-center gap-8 mt-4">
3739
<Loading
38-
size={md ? "medium" : "small"}
39-
text={
40-
tutorName
41-
? intl("book-lesson.loading-slots", { tutor: tutorName })
42-
: undefined
43-
}
40+
size={md ? "large" : "small"}
41+
text={intl("book-lesson.loading-slots")}
4442
/>
4543
</div>
4644
);
@@ -54,7 +52,7 @@ const Error: React.FC<{
5452
const { md } = useMediaQuery();
5553

5654
return (
57-
<div className="md:w-full flex flex-col justify-center items-center gap-8 md:mt-[82px] md:mb-[82px]">
55+
<div className="md:w-full mt-4">
5856
<LoadingError
5957
error={intl("book-lesson.error-slots", { tutor: tutorName })}
6058
retry={retry}
@@ -115,7 +113,7 @@ const DepletedSubscription: React.FC = () => {
115113
<NoMoreMinutes className="w-[168px] h-[168px]" />
116114
<Typography
117115
tag="p"
118-
className="text-caption sm:text-body font-bold text-natural-700"
116+
className="text-caption sm:text-body text-natural-700"
119117
>
120118
{intl("book-lesson.depleted-subscription")}
121119
</Typography>
@@ -345,17 +343,18 @@ export const ManageLessonDialog: React.FC<{
345343
<Typography tag="p" className="text-caption font-bold">
346344
{intl("book-lesson.title-1")}
347345
</Typography>
346+
348347
<Typography
349348
tag="p"
350349
className="text-tiny md:max-w-[340px] text-natural-600"
351350
>
352-
{intl("book-lesson.title-2")}
351+
{intl("book-lesson.title-2", { value: name })}
353352
</Typography>
354353
</div>
355354
</div>
356355
}
357356
className={cn(
358-
"flex flex-col !w-auto max-w-[350px] md:min-w-[450px] md:max-w-max mx-auto py-4 lg:!py-6 _sm:w-[512px] [&>div:first-child]:!px-4 sm:[&>div:first-child]:!px-0",
357+
"flex flex-col !w-auto max-w-[350px] max-h-[324px] md:min-w-[450px] md:max-w-max mx-auto py-4 lg:!py-6 _sm:w-[512px] [&>div:first-child]:!px-4 sm:[&>div:first-child]:!px-0 ",
359358
{
360359
"!left-0 right-0 translate-x-0": !sm,
361360
}
@@ -377,6 +376,15 @@ export const ManageLessonDialog: React.FC<{
377376
{depletedSubscription && !error && !loading ? (
378377
<Animation key="depleted-subscription" id="depleted-subscription">
379378
<DepletedSubscription />
379+
380+
<Link to={Web.Plans}>
381+
<Button
382+
className="w-full text-body font-medium mt-4"
383+
size="medium"
384+
>
385+
{intl("book-lesson.button.plans")}
386+
</Button>
387+
</Link>
380388
</Animation>
381389
) : null}
382390

@@ -475,6 +483,7 @@ export const ManageLessonDialog: React.FC<{
475483
],
476484
})}
477485
</Typography>
486+
478487
<Confirm
479488
disabled={!lessonDetails.slotId || !lessonDetails.start}
480489
track={track}

packages/ui/src/components/Loading/Loading.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import React from "react";
22
import { Typography } from "@litespace/ui/Typography";
33
import cn from "classnames";
4-
import Spinner from "@litespace/assets/Spinner";
4+
import LoadingV2 from "@litespace/assets/LoadingV2";
55

66
export const Loading: React.FC<{
77
text?: string;
88
size?: "small" | "medium" | "large";
99
}> = ({ text, size = "small" }) => {
1010
return (
1111
<div className="flex flex-col justify-center items-center gap-4">
12-
<Spinner
13-
className={cn("stroke-natural-600", {
14-
"w-spinner-2x h-spinner-2x [&_circle]:stroke-[2]": size === "small",
15-
"w-spinner-3x h-spinner-3x [&_circle]:stroke-[1.5]":
16-
size === "medium",
17-
"w-spinner-4x h-spinner-4x [&_circle]:stroke-[1]": size === "large",
12+
<LoadingV2
13+
className={cn({
14+
"w-spinner-2x h-spinner-2x [&_path]:fill-[2]": size === "small",
15+
"w-spinner-3x h-spinner-3x [&_path]:fill-[1.5]": size === "medium",
16+
"w-spinner-4x h-spinner-4x [&_path]:fill-[2]": size === "large",
1817
})}
1918
/>
20-
2119
{text ? (
2220
<Typography
2321
tag="span"

packages/ui/src/components/Loading/LoadingError.tsx

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,50 @@ export const LoadingError: React.FC<{
4141

4242
return (
4343
// NOTE: don't specify a size for it, do it in the parent component
44-
<div className="flex flex-col items-center justify-center mx-auto">
45-
<div
46-
className={cn(
47-
"flex items-center justify-center rounded-full bg-destructive-200 p-[2.5px]",
48-
{
49-
"w-8 h-8": size === "small",
50-
"w-16 h-16": size === "medium",
51-
"w-20 h-20": size === "large",
52-
}
53-
)}
54-
>
55-
<ExclaimationMarkCircle />
56-
</div>
57-
<Typography
58-
tag="span"
59-
className={cn("text-natural-950 text-center mt-6 sm:mt-4 mb-4", {
60-
"text-tiny font-normal": size === "small",
61-
"text-caption font-semibold": size !== "small",
62-
})}
63-
>
64-
{error || intl("error.loading-error")}
65-
</Typography>
66-
<div className="flex flex-row items-center justify-center gap-4 w-full">
67-
<Button
68-
size={size === "large" ? "medium" : "small"}
69-
onClick={retry}
70-
variant="primary"
71-
className="w-full text-tiny"
44+
<div className="flex flex-col items-center justify-center mx-auto">
45+
<div
46+
className={cn(
47+
"flex items-center justify-center rounded-full bg-destructive-200 p-[2.5px]",
48+
{
49+
"w-8 h-8": size === "small",
50+
"w-16 h-16": size === "medium",
51+
"w-20 h-20": size === "large",
52+
}
53+
)}
7254
>
73-
{intl("labels.retry")}
74-
</Button>
55+
<ExclaimationMarkCircle />
56+
</div>
57+
58+
<Typography
59+
tag="span"
60+
className={cn("text-natural-950 text-center mt-6 sm:mt-4 mb-4", {
61+
"text-tiny font-normal": size === "small",
62+
"text-caption font-semibold": size !== "small",
63+
})}
64+
>
65+
{error || intl("error.loading-error")}
66+
</Typography> <div className="flex flex-row justify-center gap-4 w-full">
7567
<Button
76-
size={size === "large" ? "medium" : "small"}
68+
size={size === "large" ? "small" : "medium"}
7769
variant="secondary"
78-
className="w-full text-tiny"
70+
className="w-full text-tiny flex-1"
7971
disabled={saving}
8072
loading={saving}
8173
onClick={save}
8274
>
8375
{intl("labels.report")}
8476
</Button>
77+
78+
<Button
79+
size={size === "large" ? "small" : "medium"}
80+
onClick={retry}
81+
variant="primary"
82+
className="w-full text-tiny flex-1"
83+
>
84+
{intl("labels.retry")}
85+
</Button>
86+
8587
</div>
86-
</div>
88+
</div>
8789
);
8890
};

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,14 +928,15 @@
928928
"book-lesson.has-booked-lessons.title": "تريد حجز جلسة اخري؟",
929929
"book-lesson.has-booked-lessons.description": "سوف يكون بامكانك حجز جلسة اخري بمجرد انتهائك من حصتك المحجوزة سابقا.",
930930
"book-lesson.has-booked-lessons.action": "موافق",
931-
"book-lesson.title-1": "احجز جلستك الآن",
932-
"book-lesson.title-2": "بعد جلستك الأولى ستكون تعرفت علي معلمك مع تحديد مستواك ووضع خطة واضحة للوصول لهدفك. ",
931+
"book-lesson.title-1": "أحجز حصتك الأن",
932+
"book-lesson.title-2": "أحجز الأن مع {value}",
933933
"book-lesson.title": "إحجز جلسة مع {tutor}",
934-
"book-lesson.depleted-subscription": "دقائقك لا تكفي لحجز جلسة لهذا الأسبوع",
934+
"book-lesson.depleted-subscription": "ليس لديك أي دقائق متبقية في الباقة لهذا الأسبوع",
935+
"book-lesson.button.plans": "تصفح الباقات",
935936
"book-lesson.confirm": "تاكيد الموعد",
936-
"book-lesson.remind-me": "ذكرني عند توفر المواعيد",
937+
"book-lesson.remind-me": "ذكرني عند توفر مواعيد",
937938
"book-lesson.edit": "تعديل الموعد",
938-
"book-lesson.loading-slots": "برجاء الانتظار، جاري احضار جدول {tutor}",
939+
"book-lesson.loading-slots": "برجاء الانتظار... جاري تحميل الجدول!",
939940
"book-lesson.error-slots": "عذرًا، حدث خطأ أثناء تحميل الجدول!",
940941
"book-lesson.empty-slots": "جميع المواعيد المتاحة محجوزة",
941942
"book-lesson.empty-slots-at-this-time": "جميع المواعيد المتاحة في هذا الوقت محجوزة",

0 commit comments

Comments
 (0)