-
Notifications
You must be signed in to change notification settings - Fork 53
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
Trip page: Add warning about navigating away with unsaved changes #400
Changes from 6 commits
1328328
c9bc5ff
ce51a6a
96f4939
22c1734
f5efbc1
471c3f4
7eb7b8d
01d34e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import React, {useState} from 'react' | ||
|
||
import FormNavigationButtons from './form-navigation-buttons' | ||
import { PageHeading, StackedPaneContainer } from './styled' | ||
|
||
/** | ||
* This component handles the flow between screens for new OTP user accounts. | ||
*/ | ||
const StackedPaneDisplay = ({ onCancel, paneSequence, title }) => ( | ||
<> | ||
{title && <PageHeading>{title}</PageHeading>} | ||
{ | ||
paneSequence.map(({ pane: Pane, props, title }, index) => ( | ||
<StackedPaneContainer key={index}> | ||
<h3>{title}</h3> | ||
<div><Pane {...props} /></div> | ||
</StackedPaneContainer> | ||
)) | ||
} | ||
const StackedPaneDisplay = ({ onCancel, paneSequence, title }) => { | ||
// Create indicator of if cancel button was clicked so that child components can know | ||
const [isBeingCanceled, updateBeingCanceled] = useState(false) | ||
|
||
<FormNavigationButtons | ||
backButton={{ | ||
onClick: onCancel, | ||
text: 'Cancel' | ||
}} | ||
okayButton={{ | ||
text: 'Save Preferences', | ||
type: 'submit' | ||
}} | ||
/> | ||
</> | ||
) | ||
return ( | ||
<> | ||
{title && <PageHeading>{title}</PageHeading>} | ||
{ | ||
paneSequence.map(({ pane: Pane, props, title }, index) => ( | ||
<StackedPaneContainer key={index}> | ||
<h3>{title}</h3> | ||
<div><Pane canceled={isBeingCanceled} {...props} /></div> | ||
</StackedPaneContainer> | ||
)) | ||
} | ||
|
||
<FormNavigationButtons | ||
backButton={{ | ||
onClick: () => { updateBeingCanceled(true); onCancel() }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What formatting do @landonreed and @evansiroky prefer regarding the semicolon? Spread over multiple lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was created by prettier -- ambiguities like this should be resolved in the future once we get the new version of mastarm up and running (which should include auto formatting). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I was stuck on this a bit also, @binh-dam-ibigroup. Let's just go ahead and move to multiple lines, since we tend not to include semicolons anywhere in this code base. |
||
text: 'Cancel' | ||
}} | ||
okayButton={{ | ||
text: 'Save Preferences', | ||
type: 'submit' | ||
}} | ||
/> | ||
</>) | ||
} | ||
|
||
StackedPaneDisplay.propTypes = { | ||
onCancel: PropTypes.func.isRequired, | ||
|
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.
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.
For internationalization, we should stay away from these string concats. I recommend we just display one string for when you create a trip and one other string for when you modify a trip.