@@ -16,55 +16,137 @@ import {
1616 areAllScenesSelectedInCart
1717} from '../../utils/dataHelper'
1818import { debounceTitilerOverlay } from '../../utils/mapHelper'
19+ import { Typography } from '@mui/material'
20+ import { Box } from '@mui/system'
1921
2022const PopupResults = ( props ) => {
2123 const dispatch = useDispatch ( )
2224 const _searchResults = useSelector ( ( state ) => state . mainSlice . searchResults )
2325 const _appConfig = useSelector ( ( state ) => state . mainSlice . appConfig )
2426
25- const [ viewState , setViewState ] = useState ( 'list' ) ;
26- const [ featureDetails , setFeatureDetails ] = useState ( ) ;
27+ const [ viewState , setViewState ] = useState ( 'list' )
28+ const [ featureDetails , setFeatureDetails ] = useState ( )
2729
28- const handleCardClick = ( id ) => {
29- // setViewState('details');
30- // setFeatureDetails(_searchResults.features.find((feature) => feature.properties.product_id === id))
30+ const handleCardClick = async ( link ) => {
31+ console . log ( link )
32+ await fetch ( link . href , {
33+ method : link . method ,
34+ headers : {
35+ 'Content-Type' : link . type ,
36+ Accept : '*/*'
37+ } ,
38+ body : JSON . stringify ( link . body )
39+ } )
3140 }
41+ console . log ( _searchResults )
3242
3343 return (
3444 < >
35- { viewState === 'list' ? < div data-testid = "testPopupResults" className = "popupResultsContainer" >
36- { _searchResults ? (
37- < div >
38- { _searchResults . features . map ( ( feature ) => {
39- return < div className = "opportunity-card" onClick = { ( ) => handleCardClick ( feature . properties . product_id ) } > < div >
40- < p > ID: < span > { feature . properties . id } </ span > </ p >
41- < p > Start time: < span > { feature . properties . start_datetime } </ span > </ p >
42- < p > End time: < span > { feature . properties . end_datetime } </ span > </ p >
43- </ div > </ div >
44- } ) }
45- </ div >
46- ) : (
47- < div className = "popupResultsEmpty" >
48- < span className = "popupResultsEmptyPrimaryText" > No Data Available</ span >
49- < span className = "popupResultsEmptySecondaryText" >
50- search and click opportunities on map to view details
51- </ span >
52- </ div >
53- ) }
54- </ div > : < div className = 'opportunity-details' >
55- < h4 > Opportunity Details</ h4 >
56- < p > Product ID: < span > { featureDetails . properties . product_id } </ span > </ p >
57- < p > Start time: < span > { featureDetails . properties . start_datetime } </ span > </ p >
58- < p > End time: < span > { featureDetails . properties . end_datetime } </ span > </ p >
59- < h5 > Constraints: </ h5 >
60- { Object . keys ( featureDetails . properties . constraints ) . map ( ( key ) => {
61- return < p > { key } - Min:{ featureDetails . properties . constraints [ key ] [ 0 ] } , Max:{ featureDetails . properties . constraints [ key ] [ 1 ] } </ p >
62- } ) }
63- </ div > }
64- </ >
45+ { viewState === 'list' ? (
46+ < div data-testid = "testPopupResults" className = "popupResultsContainer" >
47+ { _searchResults ? (
48+ < div >
49+ { _searchResults . features . map ( ( feature , inx ) => {
50+ return (
51+ < div
52+ className = "opportunity-card"
53+ onClick = { ( ) => handleCardClick ( feature . links [ 0 ] ) }
54+ key = { inx }
55+ >
56+ < div >
57+ < p >
58+ ID: < span > { feature . id } </ span >
59+ </ p >
60+
61+ { Object . keys ( feature . properties ) . map ( ( key ) => {
62+ if ( key === 'datetime' ) {
63+ const dateArray = feature . properties [ key ] . split ( '/' )
64+ return (
65+ < >
66+ < Box
67+ key = { key }
68+ display = "flex"
69+ flexDirection = "row"
70+ alignItems = "center"
71+ gap = { 2 }
72+ >
73+ < p > Start:</ p >
74+ < Typography variant = "caption" >
75+ { dateArray [ 0 ] }
76+ </ Typography >
77+ </ Box >
6578
79+ < Box
80+ key = { key }
81+ display = "flex"
82+ flexDirection = "row"
83+ alignItems = "center"
84+ gap = { 2 }
85+ >
86+ < p > End:</ p >
87+ < Typography variant = "caption" >
88+ { dateArray [ 1 ] }
89+ </ Typography >
90+ </ Box >
91+ </ >
92+ )
93+ }
94+ return (
95+ < Box
96+ key = { key }
97+ display = "flex"
98+ flexDirection = "row"
99+ alignItems = "center"
100+ gap = { 2 }
101+ >
102+ < p > { key } :</ p >
103+ < Typography variant = "caption" >
104+ { feature . properties [ key ] }
105+ </ Typography >
106+ </ Box >
107+ )
108+ } ) }
109+ </ div >
110+ </ div >
111+ )
112+ } ) }
113+ </ div >
114+ ) : (
115+ < div className = "popupResultsEmpty" >
116+ < span className = "popupResultsEmptyPrimaryText" >
117+ No Data Available
118+ </ span >
119+ < span className = "popupResultsEmptySecondaryText" >
120+ search and click opportunities on map to view details
121+ </ span >
122+ </ div >
123+ ) }
124+ </ div >
125+ ) : (
126+ < div className = "opportunity-details" >
127+ < h4 > Opportunity Details</ h4 >
128+ < p >
129+ Product ID: < span > { featureDetails . properties . product_id } </ span >
130+ </ p >
131+ < p >
132+ Start time: < span > { featureDetails . properties . start_datetime } </ span >
133+ </ p >
134+ < p >
135+ End time: < span > { featureDetails . properties . end_datetime } </ span >
136+ </ p >
137+ < h5 > Constraints: </ h5 >
138+ { Object . keys ( featureDetails . properties . constraints ) . map ( ( key ) => {
139+ return (
140+ < p >
141+ { key } - Min:{ featureDetails . properties . constraints [ key ] [ 0 ] } ,
142+ Max:{ featureDetails . properties . constraints [ key ] [ 1 ] } { ' ' }
143+ </ p >
144+ )
145+ } ) }
146+ </ div >
147+ ) }
148+ </ >
66149 )
67150}
68151
69-
70152export default PopupResults
0 commit comments