Skip to content

Commit

Permalink
Tidy up getServerSideProps
Browse files Browse the repository at this point in the history
Remove the getProjectWorkflowsHelper. Get the workflow language from the project.
  • Loading branch information
eatyourgreens committed Sep 25, 2020
1 parent 305b6dd commit 6d5d637
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/app-project/pages/projects/[owner]/[project]/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { projects } from '@zooniverse/panoptes-js'
import fetchWorkflowsHelper from '@helpers/fetchWorkflowsHelper'
export { default } from '@screens/ProjectHomePage'

async function getProjectWorkflows([project], env) {
const language = 'en'
const { active_workflows, default_workflow } = project.links
const workflows = await fetchWorkflowsHelper(language, active_workflows, default_workflow, env)
return workflows
}
export { default } from '@screens/ProjectHomePage'

export async function getServerSideProps({ params, query, req, res }) {
const { owner, project } = params
Expand All @@ -17,7 +11,10 @@ export async function getServerSideProps({ params, query, req, res }) {
slug: `${owner}/${project}`
}
const response = await projects.get({ query: projectQuery })
const workflows = await getProjectWorkflows(response.body.projects, env)
const [projectData] = response.body.projects
const language = projectData.primary_language
const { active_workflows, default_workflow } = projectData.links
const workflows = await fetchWorkflowsHelper(language, active_workflows, default_workflow, env)
const props = { workflows }
return ({ props })
}

0 comments on commit 6d5d637

Please sign in to comment.