Skip to content

Commit

Permalink
Link to new versions in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Redande committed Oct 6, 2023
1 parent aa1acc0 commit fc2e6e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion frontend/components/Profile/ProfileCompletionsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Typography } from "@mui/material"

import { FormSubmitButton } from "/components/Buttons/FormSubmitButton"
import { CompletionListItem } from "/components/Home/Completions"
import useIsNew from "/hooks/useIsNew"
import { useTranslator } from "/hooks/useTranslator"
import ProfileTranslations from "/translations/profile"
import { completionHasCourse } from "/util/guards"
Expand All @@ -15,6 +16,7 @@ interface CompletionsProps {
const ProfileCompletionsDisplay = (props: CompletionsProps) => {
const { completions } = props
const t = useTranslator(ProfileTranslations)
const isNew = useIsNew()

return (
<>
Expand All @@ -27,7 +29,11 @@ const ProfileCompletionsDisplay = (props: CompletionsProps) => {
{completions.length === 0 && (
<Typography>{t("nocompletionsText")}</Typography>
)}
<FormSubmitButton href="/profile/completions" variant="text" fullWidth>
<FormSubmitButton
href={isNew ? "/_new/profile/completions" : "/profile/completions"}
variant="text"
fullWidth
>
{t("seeCompletions")}
</FormSubmitButton>
</>
Expand Down
10 changes: 8 additions & 2 deletions frontend/components/Profile/ProfilePointsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormSubmitButton } from "/components/Buttons/FormSubmitButton"
import ErrorMessage from "/components/ErrorMessage"
import Spinner from "/components/Spinner"
import PointsListGrid from "/components/User/Points/PointsListGrid"
import useIsNew from "/hooks/useIsNew"
import { useTranslator } from "/hooks/useTranslator"
import ProfileTranslations from "/translations/profile"

Expand All @@ -12,12 +13,13 @@ import { CurrentUserProgressesDocument } from "/graphql/generated"
const ProfilePointsDisplay = () => {
const { data, error, loading } = useQuery(CurrentUserProgressesDocument)
const t = useTranslator(ProfileTranslations)
const isNew = useIsNew()

if (loading) {
return <Spinner />
}

if (error || !data) {
if (error ?? !data) {
return <ErrorMessage />
}

Expand All @@ -28,7 +30,11 @@ const ProfilePointsDisplay = () => {
return (
<>
<PointsListGrid data={data} showOnlyTen />
<FormSubmitButton href="/profile/points" variant="text" fullWidth>
<FormSubmitButton
href={isNew ? "/_new/profile/points" : "/profile/points"}
variant="text"
fullWidth
>
{t("seePoints")}
</FormSubmitButton>
</>
Expand Down

0 comments on commit fc2e6e7

Please sign in to comment.