Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigate between circulars within specific circulars pages #2227

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
26 changes: 26 additions & 0 deletions app/routes/circulars.$circularId.($version)/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export default function () {
const linkString = `/circulars/${circularId}${
!latest && version ? `/${version}` : ''
}`
const previousCircularLinkString = `/circulars/${circularId - 1}${
version ? `/${version}` : ''
}`
const nextCircularLinkString = `/circulars/${circularId + 1}${
version ? `/${version}` : ''
}`
return (
<>
<ButtonGroup>
Expand Down Expand Up @@ -142,6 +148,26 @@ export default function () {
<h1 className="margin-bottom-0">GCN Circular {circularId}</h1>
<FrontMatter {...frontMatter} />
<Body className="margin-y-2">{body}</Body>
<ButtonGroup className="display-flex flex-justify-center">
<Link to={`${previousCircularLinkString}`} className="usa-button">
<div className="position-relative">
<Icon.ArrowBack
role="presentation"
className="position-absolute top-0 left-0"
/>
</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Previous Circular
</Link>
<Link to={`${nextCircularLinkString}`} className="usa-button">
<div className="position-relative">
<Icon.ArrowForward
role="presentation"
className="position-absolute top-0 left-0"
/>
</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next Circular
</Link>
</ButtonGroup>
</>
)
}
Expand Down
7 changes: 3 additions & 4 deletions app/routes/circulars/circulars.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,9 @@ export async function get(
): Promise<Circular> {
const circularVersions = await getDynamoDBVersionAutoIncrement(circularId)
const result = await circularVersions.get(version)
if (!result)
throw new Response(null, {
status: 404,
})
if (!result) {
throw redirect('/circulars')
}
return result as Circular
}

Expand Down
Loading