Skip to content

Commit

Permalink
refactor: apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-pajak committed Nov 25, 2024
1 parent 1beeec4 commit ff7cb5d
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 26 deletions.
1 change: 1 addition & 0 deletions apps/web/app/assets/svgs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export { default as Phone } from "./phone.svg?react";
export { default as FreeRight } from "./free-right.svg?react";
export { default as Checkmark } from "./checkmark.svg?react";
export { default as Flame } from "./flame.svg?react";
export { default as NoData } from "./no-data.svg?react";
20 changes: 20 additions & 0 deletions apps/web/app/assets/svgs/no-data.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import CryptoJS from "crypto-js";

import { AvatarImage } from "./ui/avatar";
import { AvatarImage } from "../ui/avatar";

import { DEFAULT_GRAVATAR_HASH } from "./gravatar.const";

type GravatarProps = {
email: string | undefined;
Expand All @@ -9,9 +11,7 @@ type GravatarProps = {
};

export const Gravatar = ({ email, size = 200, className = "" }: GravatarProps) => {
const defaultGravatarHash = "27205e5c51cb03f862138b22bcb5dc20f94a342e744ff6df1b8dc8af3c865109";

const hash = email ? CryptoJS.MD5(email.toLowerCase().trim()).toString() : defaultGravatarHash;
const hash = email ? CryptoJS.MD5(email.toLowerCase().trim()).toString() : DEFAULT_GRAVATAR_HASH;
const gravatarUrl = `https://www.gravatar.com/avatar/${hash}?s=${size}&d=mp`;

return (
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/components/Gravatar/gravatar.const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const DEFAULT_GRAVATAR_HASH =
"27205e5c51cb03f862138b22bcb5dc20f94a342e744ff6df1b8dc8af3c865109";
1 change: 1 addition & 0 deletions apps/web/app/components/Gravatar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Gravatar } from "./Gravatar";
2 changes: 1 addition & 1 deletion apps/web/app/modules/Courses/Lesson/QuizSummaryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const QuizSummaryModal = ({
<Button variant="outline">Try Again</Button>
</DialogTrigger>
<DialogTrigger asChild>
<Link to={`/course/${courseId}/`}>
<Link to={`/course/${courseId}`}>
<Button className="w-full">Back to Course</Button>
</Link>
</DialogTrigger>
Expand Down
5 changes: 0 additions & 5 deletions apps/web/app/modules/Courses/Lesson/Summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export default function Summary({ lesson }: SummaryProps) {

const lessonItemsSummary = getSummaryItems(lesson);

console.log({ lesson });
console.log({ lessonItemsSummary });
console.log({ lessonItemsCount });
console.log({ lessonItemsCompletedCount });

return (
<Card className="sr-only lg:not-sr-only rounded-none max-w-[383px] w-full flex flex-col grow border-none drop-shadow-primary">
{isQuiz && <QuizSummary data={lesson} lessonId={lesson.id} courseId={courseId} />}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/modules/Statistics/Statistics.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function StatisticsPage() {
{
state: "Started Courses",
percentage: userStatistics?.averageStats.courseStats.started,
fill: "var(--primary-700)",
fill: "var(--primary-300)",
},
],
[
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function StatisticsPage() {
{
state: "Wrong Answers",
percentage: userStatistics?.quizzes.totalWrongAnswers,
fill: "var(--primary-700)",
fill: "var(--primary-300)",
},
],
[userStatistics?.quizzes.totalCorrectAnswers, userStatistics?.quizzes.totalWrongAnswers],
Expand Down
40 changes: 29 additions & 11 deletions apps/web/app/modules/Statistics/components/ContinueLearningCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { Link } from "@remix-run/react";

import { Icon } from "~/components/Icon";
import { Button } from "~/components/ui/button";
import { Skeleton } from "~/components/ui/skeleton";
import { useUserRole } from "~/hooks/useUserRole";
import { LessonCard } from "~/modules/Courses/CourseView/LessonCard";
Expand All @@ -24,6 +28,22 @@ export const ContinueLearningCard = ({ isLoading = false, lesson }: ContinueLear
);
}

if (!lesson) {
return (
<div className="w-full h-full items-center justify-between flex-col md:gap-8 2xl:flex-col 2xl:gap-y-4 p-8 gap-y-4 bg-white rounded-lg drop-shadow-card 2xl:max-w-[296px] flex flex-col">
<div className="text-center md:w-fit 2xl:w-full">
<h2 className="body-lg-md text-neutral-950">
Currently don&apos;t have any enrolled lessons
</h2>
</div>
<Icon name="NoData" />
<Link to="/courses" className="w-full md:w-min 2xl:w-full">
<Button className="w-full">Search courses</Button>
</Link>
</div>
);
}

return (
<div className="w-full h-full md:flex-row md:gap-8 2xl:flex-col 2xl:gap-y-4 p-4 gap-y-4 bg-white rounded-lg drop-shadow-card 2xl:max-w-[296px] flex flex-col">
<div className="text-center md:w-fit 2xl:w-full">
Expand All @@ -35,17 +55,15 @@ export const ContinueLearningCard = ({ isLoading = false, lesson }: ContinueLear
{lesson?.courseDescription}
</p>
</div>
{lesson && (
<LessonCard
{...lesson}
customHref={`/course/${lesson.courseId}/lesson/${lesson.id}`}
isAdmin={isAdmin}
isEnrolled={!!lesson.enrolled}
itemsCount={lesson.itemsCount}
itemsCompletedCount={lesson.itemsCompletedCount}
index={1}
/>
)}
<LessonCard
{...lesson}
customHref={`/course/${lesson.courseId}/lesson/${lesson.id}`}
isAdmin={isAdmin}
isEnrolled={!!lesson.enrolled}
itemsCount={lesson.itemsCount}
itemsCompletedCount={lesson.itemsCompletedCount}
index={1}
/>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { keys, pickBy } from "lodash-es";

import { Gravatar } from "~/components/Gravatar";
import { Icon } from "~/components/Icon";
import { Avatar } from "~/components/ui/avatar";
Expand Down Expand Up @@ -79,7 +81,7 @@ export const ProfileWithCalendar = ({ user, isLoading = true, streak }: ProfileW
showOutsideDays
fixedWeeks
weekStartsOn={1}
dates={Object.keys(streak?.activityHistory || {}) ?? []}
dates={keys(pickBy(streak?.activityHistory, Boolean))}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/modules/Statistics/components/RatesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const RatesChart = ({ isLoading = false, resourceName, chartData }: Rates
axisLine={false}
tickFormatter={(value) => value.slice(0, 3)}
/>
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="dashed" />} />
<ChartTooltip cursor={false} content={<ChartTooltipContent />} />
<Bar dataKey="completed" fill="var(--color-completed)" />
<Bar dataKey="started" fill="var(--color-started)" />
</BarChart>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig(({ mode }) => {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
unstable_singleFetch: true,
v3_singleFetch: true,
},
ssr: false, // SPA MODE - Might migrate to React Router 7
routes,
Expand Down

0 comments on commit ff7cb5d

Please sign in to comment.