@@ -18,11 +18,12 @@ import ProjectContextMenu from "./ProjectContextMenu";
1818import PdfPrint from "../PdfPrint/PdfPrint" ;
1919import fetchEngineRules from "./fetchEngineRules" ;
2020import * as droService from "../../services/dro.service" ;
21- import UniversalSelect from "../UI/UniversalSelect" ;
21+ // import UniversalSelect from "../UI/UniversalSelect";
2222import { ENABLE_UPDATE_TOTALS } from "../../helpers/Constants" ;
2323import AdminNotesModal from "../Modals/ActionProjectAdminNotes" ;
2424import WarningModal from "../Modals/WarningAdminNotesUnsavedChanges" ;
2525import { Td , TdExpandable } from "../UI/TableData" ;
26+ import DROSelectionModal from "../Modals/DROSelectionModal" ;
2627
2728const 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