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

Show Dashboard (Overview) Logic #4155

Closed
minotogna opened this issue Nov 28, 2024 · 0 comments · Fixed by #4166
Closed

Show Dashboard (Overview) Logic #4155

minotogna opened this issue Nov 28, 2024 · 0 comments · Fixed by #4166
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@minotogna
Copy link
Member

Current logic

export const useSections = (): Array<Section> => {
  const user = useUser()
  const { countryIso } = useCountryRouteParams()
  const assessment = useAssessment()
  const cycle = useCycle()

  return useMemo(() => {
    const sections: Array<Section> = []

    if (!cycle) return null

    const isFra2020 = assessment.props.name === AssessmentNames.fra && cycle.name === '2020'
    const showOverview = isFra2020 || Areas.isISOCountry(countryIso)

    if (showOverview) {
      sections.push({ name: SectionNames.Country.Home.overview, component: Overview })
    }

Proposal (pseudo)

export const useSections = (): Array<Section> => {
  const user = useUser()
  const { countryIso } = useCountryRouteParams()
  const assessment = useAssessment()
  const cycle = useCycle()
  const dashboardItems = getDashboardItems()

  return useMemo(() => {
    const sections: Array<Section> = []

    if (!cycle) return null

    const hasDashboardItems = dashboarditems.length > 0

    if (hasDashboardItems ) {
      sections.push({ name: SectionNames.Country.Home.overview, component: Overview })
    }
@minotogna minotogna assigned minotogna and sorja and unassigned minotogna Nov 28, 2024
@minotogna minotogna added the enhancement New feature or request label Nov 28, 2024
@minotogna minotogna added this to the 3.6.4 milestone Nov 28, 2024
@sorja sorja linked a pull request Nov 28, 2024 that will close this issue
1 task
@sorja sorja linked a pull request Nov 29, 2024 that will close this issue
@mergify mergify bot closed this as completed in #4166 Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants