Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/ts/components/modals/ForgotPasswordModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ForgotPasswordModal() {
}));

return (
<AnimatedModal id="ForgotPassword" title="Forgot password">
<AnimatedModal id="ForgotPassword" title="Forgot password" mode="dialog">
<form
class="flex flex-col justify-center gap-4"
onSubmit={(e) => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/ts/components/modals/GoogleSignUpModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function GoogleSignupModal() {
<AnimatedModal
id={modalId}
title="Account name"
mode="dialog"
afterHide={() => void afterHide()}
>
<p>Please enter a username before continuing</p>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/ts/components/modals/UserReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function UserReportModal() {
<AnimatedModal
modalClass="max-w-3xl"
id="UserReport"
mode="dialog"
title={`Report user ${getUserToReport()?.name}`}
>
<p>
Expand Down
65 changes: 35 additions & 30 deletions frontend/src/ts/components/pages/profile/ActivityCalendar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestActivity } from "@monkeytype/schemas/users";
import { createSignal, JSXElement, onMount, Show } from "solid-js";
import { createEffect, createSignal, JSXElement, Show } from "solid-js";

import { get as getSeverConfiguration } from "../../../ape/server-configuration";
import { getSnapshot, getTestActivityCalendar } from "../../../db";
Expand All @@ -24,38 +24,43 @@ export function ActivityCalendar(props: {

let calendar: TestActivityCalendar | undefined;

const sync = () => {
if (props.testActivity === undefined || element() === undefined) {
calendar = undefined;
clearTestActivity(element()?.native);
return;
}

if (props.isAccountPage) {
//signals cannot store classes, use the testActivity from the snapshot for now
calendar = getSnapshot()?.testActivity;
} else {
calendar = new TestActivityCalendar(
props.testActivity.testsByDays,
new Date(props.testActivity.lastDay),
firstDayOfTheWeek,
);
}
createEffect(() =>
(() => {
if (
(!props.isAccountPage && props.testActivity === undefined) ||
(props.isAccountPage && getSnapshot()?.testActivity === undefined) ||
element() === undefined
) {
calendar = undefined;
clearTestActivity(element()?.native);
return;
}

initTestActivity(
// oxlint-disable-next-line typescript/no-non-null-assertion
element()!.native,
calendar,
);
if (props.isAccountPage) {
//signals cannot store classes, use the testActivity from the snapshot for now
calendar = getSnapshot()?.testActivity;
} else {
const testActivity = props.testActivity as TestActivity;
calendar = new TestActivityCalendar(
testActivity.testsByDays,
new Date(testActivity.lastDay),
firstDayOfTheWeek,
);
}

if (!props.isAccountPage) {
// oxlint-disable-next-line typescript/no-non-null-assertion
const title = element()!.qsr(".top .title");
title.appendHtml(" last 12 months");
}
};
initTestActivity(
// oxlint-disable-next-line typescript/no-non-null-assertion
element()!.native,
calendar,
);

onMount(() => sync());
if (!props.isAccountPage) {
// oxlint-disable-next-line typescript/no-non-null-assertion
const title = element()!.qsr(".top .title");
title.appendHtml(" last 12 months");
}
})(),
);

const yearOptions = () => {
const startYear =
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ts/components/pages/profile/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export function UserProfile(props: {
</Show>

<ActivityCalendar
testActivity={props.profile.testActivity}
testActivity={
props.isAccountPage ? undefined : props.profile.testActivity
}
isAccountPage={props.isAccountPage}
/>
</div>
Expand Down
Loading