-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render project workflows on the server
Request workflows for the home page in getServerSideProps, then pass the workflow data down to the Hero component as a prop.
- Loading branch information
1 parent
e73ae1f
commit 1314c84
Showing
3 changed files
with
29 additions
and
75 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/app-project/pages/projects/[owner]/[project]/index.js
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 +1,18 @@ | ||
import { projects } from '@zooniverse/panoptes-js' | ||
import fetchWorkflowsHelper from '@screens/ProjectHomePage/components/Hero/helpers/fetchWorkflowsHelper' | ||
export { default } from '@screens/ProjectHomePage' | ||
|
||
async function getProjectWorkflows([project]) { | ||
const workflows = await fetchWorkflowsHelper('en', project.links['active_workflows'], project.configuration['default_workflow']) | ||
return workflows | ||
} | ||
export async function getServerSideProps({ params, req, res }) { | ||
const { owner, project } = params | ||
const query = { | ||
slug: `${owner}/${project}` | ||
} | ||
const response = await projects.get({ query }) | ||
const workflows = await getProjectWorkflows(response.body.projects) | ||
const props = { workflows } | ||
return ({ props }) | ||
} |
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