-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
444a29f
commit c3c4052
Showing
6 changed files
with
685 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import React, { PropsWithChildren } from "react" | ||
import { Button, Form, Modal } from "react-bootstrap" | ||
|
||
const possibleDurations = [ | ||
"1 hour", | ||
"2 hours", | ||
"3 hours", | ||
"4 hours", | ||
"5 hours", | ||
"6 hours", | ||
"7 hours", | ||
"8 hours", | ||
"Until end of service", | ||
"Until further notice", | ||
] | ||
|
||
const possibleReasons = [ | ||
"Accident", | ||
"Construction", | ||
"Demonstration", | ||
"Disabled bus", | ||
"Drawbridge being raised", | ||
"Electrical work", | ||
"Fire", | ||
"Hazmat condition", | ||
"Holiday", | ||
"Hurricane", | ||
"Maintenance", | ||
"Medical emergency", | ||
"Parade", | ||
"Police activity", | ||
"Snow", | ||
"Special event", | ||
"Tie replacement", | ||
"Traffic", | ||
"Weather", | ||
] | ||
|
||
interface SurroundingModalProps extends PropsWithChildren { | ||
onCancel: () => void | ||
onNext?: () => void | ||
onBack?: () => void | ||
onActivate?: () => void | ||
} | ||
|
||
const SurroundingModal = ({ | ||
onCancel, | ||
onNext, | ||
onBack, | ||
onActivate, | ||
children, | ||
}: SurroundingModalProps) => ( | ||
<Modal show animation={false}> | ||
<Modal.Header>Start detour</Modal.Header> | ||
<Modal.Body>{children}</Modal.Body> | ||
<Modal.Footer> | ||
{onBack && ( | ||
<Button variant="outline-primary" className="me-auto" onClick={onBack}> | ||
Back | ||
</Button> | ||
)} | ||
<Button variant="outline-primary" onClick={onCancel}> | ||
Cancel | ||
</Button> | ||
{onActivate ? ( | ||
<Button variant="primary" onClick={onActivate}> | ||
Activate detour | ||
</Button> | ||
) : ( | ||
<Button | ||
variant="primary" | ||
disabled={onNext === undefined} | ||
onClick={onNext} | ||
> | ||
Next | ||
</Button> | ||
)} | ||
</Modal.Footer> | ||
</Modal> | ||
) | ||
|
||
const SelectingDuration = ({ | ||
onSelectDuration, | ||
selectedDuration, | ||
}: { | ||
onSelectDuration: (duration: string) => void | ||
selectedDuration?: string | ||
}) => ( | ||
<Modal.Body> | ||
<h5>Step 1 of 3 - Select detour duration</h5> | ||
<p> | ||
<span>Time length</span> <span>(estimate)</span> | ||
</p> | ||
<Form> | ||
{possibleDurations.map((duration) => ( | ||
<Form.Check | ||
onChange={() => { | ||
onSelectDuration(duration) | ||
}} | ||
id={`duration-${duration}`} | ||
key={`duration-${duration}`} | ||
type="radio" | ||
label={duration} | ||
checked={selectedDuration === duration} | ||
/> | ||
))} | ||
</Form> | ||
</Modal.Body> | ||
) | ||
|
||
const SelectingReason = ({ | ||
onSelectReason, | ||
selectedReason, | ||
}: { | ||
onSelectReason: (reason: string) => void | ||
selectedReason?: string | ||
}) => ( | ||
<Modal.Body> | ||
<h5>Step 2 of 3 - Select reason for detour</h5> | ||
<Form> | ||
{possibleReasons.map((reason) => ( | ||
<Form.Check | ||
onChange={() => { | ||
onSelectReason(reason) | ||
}} | ||
id={`reason-${reason}`} | ||
key={`reason-${reason}`} | ||
type="radio" | ||
label={reason} | ||
checked={selectedReason === reason} | ||
/> | ||
))} | ||
</Form> | ||
</Modal.Body> | ||
) | ||
|
||
const Confirming = () => ( | ||
<Modal.Body> | ||
<h5>Step 3 of 3 - Activate detour</h5> | ||
<p>Are you sure that you want to activate this detour?</p> | ||
<p> | ||
Once activated, other Skate users, OIOs, and MBTA ridership will see this | ||
detour information. | ||
</p> | ||
<p className="fst-italic"> | ||
You will still need to radio people / whatever is accurate. | ||
</p> | ||
</Modal.Body> | ||
) | ||
|
||
export const ActivateDetour = { | ||
Modal: SurroundingModal, | ||
SelectingDuration, | ||
SelectingReason, | ||
Confirming, | ||
} |
This file contains 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 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 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
Oops, something went wrong.