-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from oliverbutler/seo
🔍 Improve SEO and statically build sprint page
- Loading branch information
Showing
22 changed files
with
216 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Alert } from '@xeo/ui'; | ||
|
||
interface Props { | ||
errorMessage: string | React.ReactNode; | ||
} | ||
|
||
export const Error: React.FunctionComponent<Props> = ({ errorMessage }) => { | ||
return ( | ||
<div className="w-full h-screen flex justify-center items-center"> | ||
<Alert variation="danger">{errorMessage}</Alert> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,28 @@ | ||
import { Sprint } from '@prisma/client'; | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import { DataPlotType, getDataForSprintChart } from 'utils/sprint/chart'; | ||
import { prisma } from 'utils/db'; | ||
import { DataPlotType } from 'utils/sprint/chart'; | ||
import { withSentry } from '@sentry/nextjs'; | ||
import { apiError, APIGetRequest, apiResponse } from 'utils/api'; | ||
import { getSprintAndPlotDataForPage } from 'utils/sprint/sprint-history'; | ||
|
||
export type GetSprintHistoryRequest = { | ||
method: 'GET'; | ||
responseBody: { | ||
sprint: Sprint; | ||
sprintHistoryPlotData: DataPlotType[]; | ||
}; | ||
}; | ||
export type GetSprintHistoryRequest = APIGetRequest<{ | ||
sprint: Sprint; | ||
sprintHistoryPlotData: DataPlotType[]; | ||
}>; | ||
|
||
/** | ||
* ⚠️ Public Facing Route | ||
*/ | ||
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | ||
const sprintId = req.query.sprintId as string; | ||
|
||
const sprint = await prisma.sprint.findFirst({ | ||
where: { | ||
id: sprintId, | ||
}, | ||
include: { | ||
backlog: { | ||
include: { | ||
notionStatusLinks: true, | ||
}, | ||
}, | ||
sprintHistory: { | ||
include: { | ||
sprintStatusHistory: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
const sprintAndPlotData = await getSprintAndPlotDataForPage(sprintId); | ||
|
||
if (!sprint) { | ||
return res.status(404).json({ message: 'Sprint not found' }); | ||
if (!sprintAndPlotData) { | ||
return apiError(res, { message: 'Sprint not found' }, 404); | ||
} | ||
|
||
const sprintHistoryPlotData = getDataForSprintChart( | ||
sprint, | ||
sprint.sprintHistory, | ||
sprint.backlog.notionStatusLinks | ||
); | ||
|
||
// Remove backlog and sprintHistory from the response to avoid sending unnecessary data | ||
const { backlog, sprintHistory, ...restSprint } = sprint; | ||
|
||
const returnValue: GetSprintHistoryRequest['responseBody'] = { | ||
sprint: restSprint, | ||
sprintHistoryPlotData, | ||
}; | ||
|
||
return res.status(200).json(returnValue); | ||
return apiResponse<GetSprintHistoryRequest>(res, sprintAndPlotData); | ||
}; | ||
|
||
export default withSentry(handler); |
Oops, something went wrong.
640e1b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: