-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9204 - Edit mode/View mode functionality, removes /edit route in favor of dynamic id route #1604
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
base: main
Are you sure you want to change the base?
Conversation
…and improve routing
…alculation and simplify calculation handling
…er rendering of components and buttons
Bundle sizes [mpdx-react]Compared against 5939d0e
|
|
Preview branch generated at https://MPDX-9204-updated.d3dytjb8adxkk5.amplifyapp.com |
canac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Just a couple thoughts on ways you could consider refactoring the viewing vs editing logic.
...mponents/Reports/SalaryCalculator/Landing/NewSalaryCalculationLanding/LandingTestWrapper.tsx
Outdated
Show resolved
Hide resolved
.../Reports/SalaryCalculator/Landing/NewSalaryCalculationLanding/NewSalaryCalculatorLanding.tsx
Outdated
Show resolved
Hide resolved
src/components/Reports/SalaryCalculator/Landing/useLandingData.ts
Outdated
Show resolved
Hide resolved
src/components/Reports/SalaryCalculator/SalaryCalculatorContext/SalaryCalculatorContext.tsx
Outdated
Show resolved
Hide resolved
| } | ||
| router.push({ | ||
| pathname: `/accountLists/${accountListId}/reports/salaryCalculator/${calculation.id}`, | ||
| query: { mode: 'edit' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way we have this now, the user could add mode=edit to the URL (or go back to a page in their history) and the UI would let them try to edit a pending or approved request (although the server would block updates changes). I think we should flip it and set mode=view when the user wants to view an action-required request instead of editing it.
Then the context can set the editing flag to "(status is in-progress OR status is action-required) AND mode is not view".
src/components/Reports/SalaryCalculator/StepNavigation/StepNavigation.tsx
Show resolved
Hide resolved
|
|
||
| const iconPanelItems = useIconPanelItems(isDrawerOpen, toggleDrawer); | ||
|
|
||
| return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work to change MainContent to render the view step instead of CurrentStep if we are in view-only mode? Then I think you might not need the changes to useStepList. I haven't tried it though - maybe that doesn't work.
…nContent based on editing
| }) => ( | ||
| <LandingTestWrapper hasLatestCalculation onCall={onCall}> | ||
| <PendingRequestActions calculation={calculation} /> | ||
| <LandingTestWrapper hasLatestCalculation onCall={onCall} router={router}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
router={router}>
Realized I forgot to remove this from LandingTestWrapper here, I'll do that (just can't push without using --no-verify at the moment and I'd rather not do that if I can help it)
canac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work implementing my suggestions! Once staging is back up, I'd like to test the UI. But thanks for the updates here! Really solid work.
...mponents/Reports/SalaryCalculator/Landing/NewSalaryCalculationLanding/LandingTestWrapper.tsx
Outdated
Show resolved
Hide resolved
| const calculation = calculationData?.salaryRequest ?? null; | ||
| const [isDrawerOpen, setDrawerOpen] = useState(false); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of an effect, you could return something like drawerOpen: editing ? true : drawerOpen from the context (I'm not sure if that conditional is exactly what you were trying to accomplish). It might be better though to remove this useEffect and handle drawerOpen where it's used in SalaryCalculator.
Here's a section in an article about the pattern: https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes. The third code block (the "Best" one) is the approach I'm recommending here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice article, it was a helpful reference thanks
Description
Jira ticket
Setting complete to be
!isEditisuseStepListis not needed since the steps list won't render in view mode, so I can remove that if needed.Testing
Checklist:
/pr-reviewcommand locally and fixed any relevant suggestions