@@ -58,8 +58,9 @@ const LocationApprove: FC<IProps> = ({ isOpen, onClose, news, newFlashTitle }) =
58
58
const { userStore } = store ;
59
59
const [ shouldApprove , setApproveStatus ] = useState ( true ) ;
60
60
const [ locationChanged , setLocationChanged ] = useState ( false ) ;
61
- const [ newStreetLoc , setNewStreetLoc ] = useState < IStreetData | null > ( null ) ;
62
- const [ newGpsLoc , setNewGpsLoc ] = useState < IGpsData | null > ( null ) ;
61
+ const [ newStreetLoc , setNewStreetLoc ] = useState < IStreetData | undefined > ( undefined ) ;
62
+ const [ newGpsLoc , setNewGpsLoc ] = useState < IGpsData | undefined > ( undefined ) ;
63
+ const [ newPointLoc , setNewPointLoc ] = useState < IPoint | undefined > ( undefined ) ;
63
64
const [ locationToDisplay , setLocationToDisplay ] = useState ( news . curr_cbs_location_text ) ;
64
65
// Unauthorized user shouldn't be able to open the window in the first place
65
66
const userInfo = userStore . userInfo && userStore . userInfo . data && userStore . userInfo . data . firstName ?
@@ -68,14 +69,23 @@ const LocationApprove: FC<IProps> = ({ isOpen, onClose, news, newFlashTitle }) =
68
69
function handleApproveButton ( ) {
69
70
if ( shouldApprove && locationChanged ) {
70
71
if ( newStreetLoc ) {
71
- updateNews ( news . id , locationQualificationOptions . MANUAL , newStreetLoc , null ) ;
72
+ updateNews ( {
73
+ newsId : news . id ,
74
+ newLocationQualification : locationQualificationOptions . MANUAL ,
75
+ streetLocation : newStreetLoc ,
76
+ } ) ;
72
77
} else {
73
- updateNews ( news . id , locationQualificationOptions . MANUAL , null , newGpsLoc ) ;
78
+ updateNews ( {
79
+ newsId : news . id ,
80
+ newLocationQualification : locationQualificationOptions . MANUAL ,
81
+ gpsLocation : newGpsLoc ,
82
+ pointLocation : newPointLoc ,
83
+ } ) ;
74
84
}
75
85
} else if ( shouldApprove ) {
76
- updateNews ( news . id , locationQualificationOptions . VERIFIED , null , null ) ;
86
+ updateNews ( { newsId : news . id , newLocationQualification : locationQualificationOptions . VERIFIED } ) ;
77
87
} else {
78
- updateNews ( news . id , locationQualificationOptions . REJECTED , null , null ) ;
88
+ updateNews ( { newsId : news . id , newLocationQualification : locationQualificationOptions . REJECTED } ) ;
79
89
}
80
90
onCloseInitValues ( ) ;
81
91
window . location . reload ( ) ;
@@ -94,13 +104,14 @@ const LocationApprove: FC<IProps> = ({ isOpen, onClose, news, newFlashTitle }) =
94
104
95
105
const onMapLocationChange = useCallback (
96
106
( location : IPoint ) => {
97
- setLocationChanged ( true ) ;
107
+ setNewPointLoc ( location ) ;
98
108
store . fetchGpsLocation ( location ) ;
99
109
if ( store . gpsLocationData ) {
100
110
setNewGpsLoc ( store . gpsLocationData ) ;
101
111
setLocationToDisplay ( t ( 'mapDialog.road' ) + " " + store . gpsLocationData . road1 + " - " +
102
112
store . gpsLocationData . road_segment_name ) ;
103
113
}
114
+ setLocationChanged ( true ) ;
104
115
} ,
105
116
[ t , store ] ,
106
117
) ;
0 commit comments