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 22, 2024
1 parent af32bfd commit 8805632
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
10 changes: 8 additions & 2 deletions apps/web/app/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - react-day-picker untyped library
import { DayPicker } from "react-day-picker";

import { Checkmark } from "~/assets/svgs";
Expand All @@ -12,10 +14,14 @@ export type CalendarProps = ComponentProps<typeof DayPicker> & {
};

type CustomDayContentProps = DayProps & {
"data-day": string;
dates: string[] | undefined;
day: { outside: boolean | undefined };
children: { props: { children: string } };
};

function CustomDayContent({ dates, ...props }: CustomDayContentProps) {
console.log({ props });
if (dates?.includes(props?.["data-day"])) {
const classes = cn(
"text-primary-foreground hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground p-0 border aspect-square size-8 text-sm flex items-center justify-center has-[button]:hover:!bg-success-200 rounded-full has-[button]:hover:aria-selected:!bg-success-500 has-[button]:hover:text-accent-foreground has-[button]:hover:aria-selected:text-primary-foreground",
Expand Down Expand Up @@ -96,8 +102,8 @@ function Calendar({
Day: ({ ...props }) => {
return <CustomDayContent dates={dates} {...props} />;
},
PreviousMonthButton: ({ ...props }) => <div className="sr-only" />,
NextMonthButton: ({ ...props }) => <div className="sr-only" />,
PreviousMonthButton: () => <div className="sr-only" />,
NextMonthButton: () => <div className="sr-only" />,
}}
{...props}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const AvgPercentScoreChart = ({
dominantBaseline="middle"
>
<tspan x={viewBox.cx} y={viewBox.cy} className="fill-primary-950 h3">
{isEmptyChart ? "No data" : label}
{isEmptyChart ? "No data" : `${label}%`}
</tspan>
</text>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { GetUserStatisticsResponse } from "~/api/generated-api";

type ContinueLearningCardProps = {
isLoading: boolean;
lesson: GetUserStatisticsResponse["data"]["lastLesson"];
lesson: GetUserStatisticsResponse["data"]["lastLesson"] | undefined;
};

export const ContinueLearningCard = ({ isLoading = false, lesson }: ContinueLearningCardProps) => {
Expand Down Expand Up @@ -35,14 +35,16 @@ export const ContinueLearningCard = ({ isLoading = false, lesson }: ContinueLear
{lesson?.courseDescription}
</p>
</div>
<LessonCard
{...lesson}
isAdmin={isAdmin}
isEnrolled={!!lesson?.enrolled}
itemsCount={lesson?.itemsCount}
itemsCompletedCount={lesson?.itemsCompletedCount}
index={1}
/>
{lesson && (
<LessonCard
{...lesson}
isAdmin={isAdmin}
isEnrolled={!!lesson.enrolled}
itemsCount={lesson.itemsCount}
itemsCompletedCount={lesson.itemsCompletedCount}
index={1}
/>
)}
</div>
);
};
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 @@ -135,7 +135,7 @@ export const RatesChart = ({ isLoading = false, resourceName, chartData }: Rates
return (
<ChartLegendBadge
key={config.label as string}
label={config.label}
label={`${config.label} ${resourceName}`}
dotColor={config.color}
/>
);
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/modules/Statistics/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type Data =
| Record<string, { started: number; completed: number; completionRate: number }>
| object
| undefined;

export const parseRatesChartData = (data: Data) => {
Expand Down

0 comments on commit 8805632

Please sign in to comment.