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

Remove process filters from the sidebar #951

Merged
merged 1 commit into from
Jan 24, 2025
Merged
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
9 changes: 2 additions & 7 deletions src/components/Dashboard/Menu/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { HiSquares2X2 } from 'react-icons/hi2'
import { IoIosSettings } from 'react-icons/io'
import { generatePath, matchPath, useLocation } from 'react-router-dom'
import { matchPath, useLocation } from 'react-router-dom'
import { Routes } from '~src/router/routes'
import { DashboardMenuItem } from './Item'
import { OrganizationSwitcher } from './OrganizationSwitcher'
Expand All @@ -27,13 +27,8 @@ export const DashboardMenuOptions = () => {
// },
{
label: t('voting_processes'),
route: Routes.dashboard.processes,
icon: HiSquares2X2,
children: [
{ label: t('all'), route: generatePath(Routes.dashboard.processes, { page: 1 }) },
{ label: t('active'), route: generatePath(Routes.dashboard.processes, { status: 'ready', page: 1 }) },
{ label: t('finished'), route: generatePath(Routes.dashboard.processes, { status: 'results', page: 1 }) },
// { label: t('draft'), route: '#draft' },
],
},
// {
// label: t('organization.census'),
Expand Down
39 changes: 39 additions & 0 deletions src/components/Process/ProcessStatusFilters.tsx
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really convinced about this component here... this is a component that can only be used in the dashboard processes index, because the filter links will send you there in any case... I might should have left it in elements (directly on its own element), but I wasn't convinced either.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Button, ButtonGroup, ButtonGroupProps } from '@chakra-ui/react'
import { Trans } from 'react-i18next'
import { generatePath, NavLink } from 'react-router-dom'
import { Routes } from '~routes'

type ProcessStatusFilterProps = ButtonGroupProps & {
status?: string
}

const ProcessStatusFilter = ({ status, ...rest }: ProcessStatusFilterProps) => (
<ButtonGroup isAttached {...rest}>
<Button
size='xs'
as={NavLink}
to={generatePath(Routes.dashboard.processes, { page: 1 })}
isActive={status === undefined}
>
<Trans i18nKey='all'>All</Trans>
</Button>
<Button
size='xs'
as={NavLink}
to={generatePath(Routes.dashboard.processes, { status: 'ready', page: 1 })}
isActive={status === 'ready'}
>
<Trans i18nKey='active'>Active</Trans>
</Button>
<Button
size='xs'
as={NavLink}
to={generatePath(Routes.dashboard.processes, { status: 'results', page: 1 })}
isActive={status === 'results'}
>
<Trans i18nKey='finished'>Finished</Trans>
</Button>
</ButtonGroup>
)

export default ProcessStatusFilter
6 changes: 4 additions & 2 deletions src/elements/dashboard/processes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { useTranslation } from 'react-i18next'
import { useLoaderData, useOutletContext, useParams } from 'react-router-dom'
import { DashboardContents } from '~components/Layout/Dashboard'
import Votings from '~components/Organization/Dashboard/Votings'
import ProcessStatusFilter from '~components/Process/ProcessStatusFilters'
import { DashboardLayoutContext } from '~elements/LayoutDashboard'

const OrganizationVotings = () => {
const { t } = useTranslation()
const { setBack, setTitle } = useOutletContext<DashboardLayoutContext>()
const data = useLoaderData()
const data = useLoaderData() as ElectionListWithPagination
const { status } = useParams<{ status?: string }>()

// Set page title
Expand All @@ -19,7 +20,8 @@ const OrganizationVotings = () => {
}, [setTitle, setBack])

return (
<DashboardContents>
<DashboardContents display='flex' flexDirection='column'>
<ProcessStatusFilter status={status} alignSelf='end' />
<Votings data={data as ElectionListWithPagination} status={status} />
</DashboardContents>
)
Expand Down
1 change: 1 addition & 0 deletions tsconfig.paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"~elements/*": ["elements/*"],
"~i18n": ["i18n/index.ts"],
"~i18n/*": ["i18n/*"],
"~routes": ["router/routes/index.ts"],
"~theme": ["theme/index.ts"],
"~theme/*" : ["theme/*"],
"~utils/*": ["utils/*"],
Expand Down