Skip to content

Commit 3c76235

Browse files
heejung-hongHyMike
authored andcommitted
created DRO Selection Modal and changed the DRO displayed in the projects page (#2660)
1 parent 4854902 commit 3c76235

2 files changed

Lines changed: 185 additions & 3 deletions

File tree

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
import { createUseStyles, useTheme } from "react-jss";
4+
import { MdLaunch, MdLocationCity } from "react-icons/md";
5+
import ModalDialog from "../UI/Modal";
6+
import RadioButton from "../UI/RadioButton";
7+
import Button from "../Button/Button";
8+
9+
const useStyles = createUseStyles(theme => ({
10+
container: {
11+
display: "flex",
12+
flexDirection: "column",
13+
alignItems: "center",
14+
width: "40rem",
15+
gap: "1rem",
16+
padding: "1rem"
17+
},
18+
buttonFlexBox: {
19+
display: "flex",
20+
flexDirection: "row",
21+
justifyContent: "center",
22+
margin: 0
23+
},
24+
heading1: theme.typography.heading1,
25+
heading2: theme.typography.heading2,
26+
subheading: {
27+
...theme.typography.subHeading,
28+
width: "85%"
29+
},
30+
externalLinkIcon: {
31+
fontSize: "20px",
32+
padding: " 0 0.4em",
33+
color: "#00F",
34+
verticalAlign: "middle"
35+
},
36+
icon: {
37+
height: "40px",
38+
width: "40px",
39+
color: theme.colorBlack,
40+
marginBottom: "0",
41+
verticalAlign: "middle",
42+
marginRight: "1rem"
43+
}
44+
}));
45+
46+
export default function DROSelectionModal({
47+
mounted,
48+
onClose,
49+
onConfirm,
50+
selectedDro,
51+
droOptions,
52+
onChange
53+
}) {
54+
const theme = useTheme();
55+
const classes = useStyles({ theme });
56+
57+
return (
58+
<ModalDialog
59+
mounted={mounted}
60+
onClose={onClose}
61+
onConfirm={onConfirm}
62+
onChange={onChange}
63+
>
64+
<div className={classes.container}>
65+
<div className={classes.heading1}>
66+
<MdLocationCity className={classes.icon} />
67+
Select Development Review Office
68+
</div>
69+
<div className={classes.subheading}>
70+
To submit your snapshot, select a Development Review Office based on
71+
the location of your project
72+
</div>
73+
<div className={classes.heading2}>
74+
Map of Development Review Offices
75+
<a
76+
href="https://ladot.lacity.gov/sites/default/files/documents/ladot-development-review-counter-info.pdf"
77+
target="_blank"
78+
className={classes.glossaryLink}
79+
rel="noreferrer"
80+
>
81+
<MdLaunch className={classes.externalLinkIcon} />
82+
</a>
83+
</div>
84+
{droOptions.map(dro => (
85+
<div
86+
key={dro.id}
87+
style={{
88+
display: "flex",
89+
flexDirection: "column",
90+
width: "100px",
91+
margin: "auto"
92+
}}
93+
>
94+
<RadioButton
95+
label={dro.name}
96+
value={dro.id}
97+
checked={selectedDro === dro.id}
98+
onChange={onChange}
99+
/>
100+
</div>
101+
))}
102+
<div className={classes.buttonFlexBox}>
103+
<Button onClick={onClose} variant="secondary">
104+
CANCEL
105+
</Button>
106+
<Button
107+
onClick={() => onConfirm("ok", selectedDro)}
108+
variant="primary"
109+
>
110+
CONFIRM
111+
</Button>
112+
</div>
113+
</div>
114+
</ModalDialog>
115+
);
116+
}
117+
118+
DROSelectionModal.propTypes = {
119+
mounted: PropTypes.bool.isRequired,
120+
onClose: PropTypes.func.isRequired,
121+
onConfirm: PropTypes.func.isRequired,
122+
selectedDro: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
123+
droOptions: PropTypes.array.isRequired,
124+
onChange: PropTypes.func.isRequired
125+
};

client/src/components/Projects/ProjectTableRow.jsx

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import ProjectContextMenu from "./ProjectContextMenu";
1818
import PdfPrint from "../PdfPrint/PdfPrint";
1919
import fetchEngineRules from "./fetchEngineRules";
2020
import * as droService from "../../services/dro.service";
21-
import UniversalSelect from "../UI/UniversalSelect";
21+
// import UniversalSelect from "../UI/UniversalSelect";
2222
import { ENABLE_UPDATE_TOTALS } from "../../helpers/Constants";
2323
import AdminNotesModal from "../Modals/ActionProjectAdminNotes";
2424
import WarningModal from "../Modals/WarningAdminNotesUnsavedChanges";
2525
import { Td, TdExpandable } from "../UI/TableData";
26+
import DROSelectionModal from "../Modals/DROSelectionModal";
2627

2728
const useStyles = createUseStyles(theme => ({
2829
actionIcons: {
@@ -196,7 +197,9 @@ const ProjectTableRow = ({
196197
const printRef = useRef();
197198
const [projectRules, setProjectRules] = useState(null);
198199
const [selectedDro, setSelectedDro] = useState(project.droId || "");
200+
const [committedDro, setCommittedDro] = useState(project.droId || "");
199201
const [droName, setDroName] = useState("N/A");
202+
const [DROSelectionModalOpen, setDROSelectionModalOpen] = useState(false);
200203

201204
// Download and process rules for PDF rendering
202205
useEffect(() => {
@@ -229,6 +232,27 @@ const ProjectTableRow = ({
229232
setSelectedDro(project.droId || "");
230233
}, [project.droId]);
231234

235+
const handleDROSelectionModalOpen = () => {
236+
setDROSelectionModalOpen(true);
237+
};
238+
239+
const handleDROSelectionModalClose = () => {
240+
setSelectedDro(committedDro);
241+
setDROSelectionModalOpen(false);
242+
};
243+
244+
const handleDROSelection = action => {
245+
if (action === "ok") {
246+
setCommittedDro(selectedDro);
247+
}
248+
setDROSelectionModalOpen(false);
249+
};
250+
251+
const getDroNameById = id => {
252+
const dro = droOptions.find(d => String(d.id) === String(id));
253+
return dro ? dro.name : "N/A";
254+
};
255+
232256
const handlePrintPdf = useReactToPrint({
233257
content: () => printRef.current,
234258
bodyClass: "printContainer",
@@ -314,7 +338,39 @@ const ProjectTableRow = ({
314338
{droOptions.length > 0 &&
315339
(isAdmin || (project.loginId === loginId && !project.dateSubmitted)) ? (
316340
<div style={{ width: "100px" }}>
317-
<UniversalSelect
341+
{!committedDro ? (
342+
<MdAdd
343+
onClick={handleDROSelectionModalOpen}
344+
style={{
345+
cursor: "pointer"
346+
}}
347+
/>
348+
) : (
349+
<span
350+
onClick={handleDROSelectionModalOpen}
351+
style={{
352+
color: "#0000FF",
353+
textDecoration: "underline",
354+
cursor: "pointer"
355+
}}
356+
>
357+
{getDroNameById(committedDro)}
358+
</span>
359+
)}
360+
361+
<DROSelectionModal
362+
mounted={DROSelectionModalOpen}
363+
onClose={handleDROSelectionModalClose}
364+
onConfirm={handleDROSelection}
365+
selectedDro={selectedDro}
366+
droOptions={droOptions}
367+
onChange={e => {
368+
const newDroId = e.target.value;
369+
setSelectedDro(newDroId);
370+
onDroChange(project.id, newDroId);
371+
}}
372+
/>
373+
{/* <UniversalSelect
318374
value={selectedDro}
319375
onChange={e => {
320376
const newDroId = e.target.value;
@@ -330,7 +386,7 @@ const ProjectTableRow = ({
330386
]}
331387
name="droId"
332388
className={classes.selectBox}
333-
/>
389+
/> */}
334390
</div>
335391
) : (
336392
<span>{droName}</span>
@@ -443,6 +499,7 @@ ProjectTableRow.propTypes = {
443499
handleSubmitModalOpen: PropTypes.func.isRequired,
444500
handleHide: PropTypes.func.isRequired,
445501
handleCheckboxChange: PropTypes.func.isRequired,
502+
handleDROSelectionModalOpen: PropTypes.func,
446503
checkedProjectIds: PropTypes.arrayOf(PropTypes.number).isRequired,
447504
droOptions: PropTypes.arrayOf(
448505
PropTypes.shape({

0 commit comments

Comments
 (0)