Skip to content

Commit

Permalink
fix(lib-user): use next/link for internal app routes (#6379)
Browse files Browse the repository at this point in the history
* fix(lib-user): use next/link for internal app routes

Use `next/link` for the home page link to user stats, and the link to your stats certificate.

Also fix the `lib-user` peer dependencies, which were still requiring Next.js 13.5.

* use next/link for See All in Groups Preview component on homepage

---------

Co-authored-by: Delilah <[email protected]>
  • Loading branch information
eatyourgreens and goplayoutside3 authored Oct 19, 2024
1 parent 95d66db commit d2b2191
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Loader, SpacedText } from '@zooniverse/react-components'
import { Anchor, Box, Paragraph } from 'grommet'
import { arrayOf, bool, func, shape, string } from 'prop-types'
import Link from 'next/link'

import { ContentBox } from '@components/shared'
import GroupCardContainer from '../GroupCard/GroupCardContainer.js'
Expand All @@ -17,7 +18,7 @@ export default function PreviewLayout({
return (
<ContentBox
linkLabel='See all'
linkProps={{ href: `/users/${authUser?.login}/groups` }}
linkProps={{ as: Link, href: `/users/${authUser?.login}/groups` }}
title='My Groups'
>
{loading && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SpacedHeading, SpacedText } from '@zooniverse/react-components'

import DashboardLink from './components/DashboardLink.js'
import StatsTabsContainer from './components/StatsTabs/StatsTabsContainer.js'
import Link from 'next/link'

const LinkToBlogPost = styled(Anchor)`
position: absolute;
Expand Down Expand Up @@ -253,6 +254,7 @@ export default function Dashboard({ user, userLoading }) {
<Relative fill>
<StyledStatsLink
alignSelf={size === 'small' ? 'center' : 'end'}
forwardedAs={Link}
href={`/users/${user?.login}/stats`}
label={<SpacedText>More Stats</SpacedText>}
icon={<FormNext />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Previous } from 'grommet-icons'
import { string } from 'prop-types'

import { HeaderButton } from '@components/shared'
import Link from 'next/link'

function HeaderLink({
href,
Expand All @@ -10,6 +11,7 @@ function HeaderLink({
}) {
return (
<HeaderButton
forwardedAs={Link}
href={href}
icon={<Previous color='white' size='small' />}
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
StyledTab
} from './components'
import { getDateRangeSelectOptions, getProjectSelectOptions } from './helpers'
import Link from 'next/link'

const DEFAULT_HANDLER = () => true
const DEFAULT_DATE_RANGE = {
Expand Down Expand Up @@ -291,7 +292,7 @@ function MainContent({
margin={{ top: 'small' }}
>
<StyledCertificateButton
forwardedAs='a'
forwardedAs={Link}
color='neutral-1'
href={`/users/${source.login}/stats/certificate${window.location.search}`}
label='Generate Volunteer Certificate'
Expand Down

0 comments on commit d2b2191

Please sign in to comment.