-
Notifications
You must be signed in to change notification settings - Fork 127
feat: navigation update for results page #9000
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
Open
bookwormsuf
wants to merge
6
commits into
develop
Choose a base branch
from
feat/navigation-updates
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e52386
navigation update for results page
bookwormsuf 4169abe
linting fixes
bookwormsuf aa2ab43
linting fixes + tried to fix nested scrolling on charts
bookwormsuf 7870e09
Potential fix for pull request finding 'Unused variable, import, func…
bookwormsuf 029ec45
Potential fix for pull request finding 'Unused variable, import, func…
bookwormsuf c1773e7
linting fixes
bookwormsuf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
91 changes: 82 additions & 9 deletions
91
frontend/src/features/admin-form/responses/FormResultsLayout.tsx
This file contains hidden or 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,16 +1,89 @@ | ||
| import { Outlet } from 'react-router-dom' | ||
| import { Flex } from '@chakra-ui/react' | ||
| import { useCallback } from 'react' | ||
| import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom' | ||
| import { Box, Flex, Spacer, Tabs } from '@chakra-ui/react' | ||
|
|
||
| import { | ||
| ACTIVE_ADMINFORM_RESULTS_ROUTE_REGEX, | ||
| ADMINFORM_RESULTS_SUBROUTE, | ||
| ADMINFORM_ROUTE, | ||
| RESULTS_CHARTS_SUBROUTE, | ||
| RESULTS_FEEDBACK_SUBROUTE, | ||
| RESULTS_RESPONSES_SUBROUTE, | ||
| } from '~constants/routes' | ||
| import { useDraggable } from '~hooks/useDraggable' | ||
|
|
||
| import { FormResultsNavbar } from './components/FormResultsNavbar' | ||
|
|
||
| /** | ||
| * Page for rendering subroutes via `Outlet` component for admin form result pages. | ||
| */ | ||
| export const FormResultsLayout = (): JSX.Element => { | ||
| const { ref, onMouseDown } = useDraggable<HTMLDivElement>() | ||
| const { formId } = useParams() | ||
| const navigate = useNavigate() | ||
| const { pathname } = useLocation() | ||
|
|
||
| if (!formId) throw new Error('No formId provided') | ||
|
|
||
| const checkTabActive = useCallback( | ||
| (to: string) => { | ||
| const match = pathname.match(ACTIVE_ADMINFORM_RESULTS_ROUTE_REGEX) | ||
| return (match?.[2] ?? '/') === `/${to}` | ||
| }, | ||
| [pathname], | ||
| ) | ||
|
|
||
| const tabConfig = [ | ||
| { path: RESULTS_RESPONSES_SUBROUTE }, | ||
| { path: RESULTS_FEEDBACK_SUBROUTE }, | ||
| { path: RESULTS_CHARTS_SUBROUTE }, | ||
| ] | ||
|
|
||
| const tabIndex = tabConfig.findIndex((tab) => checkTabActive(tab.path)) | ||
|
|
||
| const handleTabChange = (index: number) => { | ||
| const subRoute = tabConfig[index].path | ||
| const path = subRoute | ||
| ? `${ADMINFORM_ROUTE}/${formId}/${ADMINFORM_RESULTS_SUBROUTE}/${subRoute}` | ||
| : `${ADMINFORM_ROUTE}/${formId}/${ADMINFORM_RESULTS_SUBROUTE}` | ||
| navigate(path) | ||
| } | ||
|
|
||
| return ( | ||
| <Flex flexDir="column" flex={1} overflow="hidden" pos="relative"> | ||
| <FormResultsNavbar /> | ||
| <Outlet /> | ||
| </Flex> | ||
| <Box overflowX="hidden" overflowY="auto" position="relative" flex={1}> | ||
| {' '} | ||
| <Tabs | ||
| orientation="vertical" | ||
| variant="line" | ||
| py={{ base: '2.5rem', lg: '3.125rem' }} | ||
| pl={{ base: 0, md: '1.75rem', lg: '2rem' }} | ||
| pr={{ base: '1.5rem', md: '1.75rem', lg: '2rem' }} | ||
| index={tabIndex === -1 ? 0 : tabIndex} | ||
| onChange={handleTabChange} | ||
| > | ||
| <Flex | ||
| h="max-content" | ||
| flex={1} | ||
| flexShrink={0} | ||
| ref={ref} | ||
| onMouseDown={onMouseDown} | ||
| position="sticky" | ||
| zIndex={0} | ||
| top={{ base: '2.5rem', lg: '3.125rem' }} | ||
| borderTopColor="neutral.300" | ||
| w={{ base: 'auto', lg: '21rem' }} | ||
| __css={{ | ||
| scrollbarWidth: 0, | ||
| '&::-webkit-scrollbar': { | ||
| width: 0, | ||
| height: 0, | ||
| }, | ||
| }} | ||
| > | ||
| <FormResultsNavbar /> | ||
| </Flex> | ||
| <Box maxW="69.5rem" mt={0} w="100%" minW={0} overflowX="hidden"> | ||
| <Outlet /> | ||
| </Box> | ||
| <Spacer /> | ||
| </Tabs> | ||
| </Box> | ||
| ) | ||
| } |
This file contains hidden or 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
9 changes: 3 additions & 6 deletions
9
frontend/src/features/admin-form/responses/ResponsesPage/ResponsesLayout.tsx
This file contains hidden or 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,17 +1,14 @@ | ||
| import { Outlet } from 'react-router-dom' | ||
|
|
||
| import { ResponsesTabWrapper } from './common/ResponsesTabWrapper' | ||
| import { UnlockedResponsesProvider } from './storage/UnlockedResponses' | ||
|
|
||
| /** | ||
| * Page for rendering subroutes via `Outlet` component for admin form result responses pages. | ||
| */ | ||
| export const ResponsesLayout = (): JSX.Element => { | ||
| return ( | ||
| <ResponsesTabWrapper> | ||
| <UnlockedResponsesProvider> | ||
| <Outlet /> | ||
| </UnlockedResponsesProvider> | ||
| </ResponsesTabWrapper> | ||
| <UnlockedResponsesProvider> | ||
| <Outlet /> | ||
| </UnlockedResponsesProvider> | ||
| ) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.