From ef84f833c6f7bcdb88424a5cb1153971fd62cc20 Mon Sep 17 00:00:00 2001 From: LiadOvdat5 Date: Sun, 9 Jun 2024 19:23:26 +0300 Subject: [PATCH 01/10] Added complaint button, hidden as an easter egg 'complaint'. when opened you can write your info and submit. --- src/locale/en.json | 24 +++ src/locale/he.json | 23 +++ .../map-related/MapLayers/BusToolTip.tsx | 24 +++ .../map-related/MapLayers/ComplaintModal.tsx | 171 ++++++++++++++++++ 4 files changed, 242 insertions(+) create mode 100644 src/pages/components/map-related/MapLayers/ComplaintModal.tsx diff --git a/src/locale/en.json b/src/locale/en.json index 8daae722..00ea3612 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -129,6 +129,30 @@ "coords": "coords", "hide_document": "Hide geeks data", "show_document": "Show geeks data", + "open_complaint": "Open complaint", + "close_complaint": "Close complaint", + "complaint": "Complaint", + "first_name": "First Name", + "last_name": "Last Name", + "id": "ID", + "email": "Email", + "phone": "Phone Number", + "complaint_type": "Complaint Type", + "other": "Other", + "no_stop": "No Stop at Station", + "no_ride": "No Ride", + "delay": "Delay", + "overcrowded": "Overcrowded", + "driver_behavior": "Driver Behavior", + "early": "Early Arrival", + "cleanliness": "Cleanliness and Condition of the Bus", + "fine_appeal": "Fine Appeal", + "route_change": "Route Change", + "line_switch": "Line Switch", + "station_signs": "Station Information Signs", + "description": "Description", + "submit_complaint": "Submit Complaint", + "lineProfile": { "title": "Profile for Line", "notFound": "We couldn't find the line you were looking for :(", diff --git a/src/locale/he.json b/src/locale/he.json index a752b01d..766b73d1 100644 --- a/src/locale/he.json +++ b/src/locale/he.json @@ -134,6 +134,29 @@ "coords": "נ.צ.", "hide_document": "הסתר מידע לגיקים", "show_document": "הצג מידע לגיקים", + "open_complaint": "פתח תלונה", + "close_complaint": "סגור תלונה", + "complaint": "תלונה", + "first_name": "שם פרטי", + "last_name": "שם משפחה", + "id": "מספר תעודת זהות", + "email": "דואר אלקטרוני", + "phone": "מספר טלפון", + "complaint_type": "סוג התלונה", + "other": "אחר", + "no_stop": "אי עצירה בתחנה", + "no_ride": "אי ביצוע נסיעה", + "delay": "איחור", + "overcrowded": "עומס נוסעים", + "driver_behavior": "התנהגות נהג", + "early": "הקדמה", + "cleanliness": "נקיות ותקינות האוטובוס", + "fine_appeal": "ערעור על קנס", + "route_change": "שינוי מסלול", + "line_switch": "מעבר בין קווים", + "station_signs": "תקינות שלטי מידע בתחנה", + "description": "תיאור", + "submit_complaint": "שלח תלונה", "lineProfile": { "title": "פרופיל קו", "notFound": "לא הצלחנו למצוא את הקו שחיפשת :(", diff --git a/src/pages/components/map-related/MapLayers/BusToolTip.tsx b/src/pages/components/map-related/MapLayers/BusToolTip.tsx index 0f4771cd..f0722c2f 100644 --- a/src/pages/components/map-related/MapLayers/BusToolTip.tsx +++ b/src/pages/components/map-related/MapLayers/BusToolTip.tsx @@ -10,6 +10,9 @@ import { useTranslation } from 'react-i18next' import { Spin } from 'antd' import cn from 'classnames' import CustomTreeView from '../../CustomTreeView' +import { EasterEgg } from '../../../EasterEgg/EasterEgg' + +import ComplaintModal from './ComplaintModal' export type BusToolTipProps = { position: Point; icon: string } @@ -18,6 +21,7 @@ export function BusToolTip({ position, icon }: BusToolTipProps) { const [isLoading, setIsLoading] = useState(false) const [showJson, setShowJson] = useState(false) const { t, i18n } = useTranslation() + const [modalOpen, setModalOpen] = useState(false) useEffect(() => { setIsLoading(true) @@ -93,6 +97,26 @@ export function BusToolTip({ position, icon }: BusToolTipProps) { onClick={() => setShowJson((showJson) => !showJson)}> {showJson ? t('hide_document') : t('show_document')} + + {/* Open Complaint Button */} + + + + + {/* Complaint Modal */} + + {showJson && (
e.stopPropagation()}> diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx new file mode 100644 index 00000000..c015952a --- /dev/null +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -0,0 +1,171 @@ +import { useState, ChangeEvent } from 'react' +import { + Box, + Button, + FormControl, + InputLabel, + MenuItem, + Modal, + Select, + TextField, + SelectChangeEvent, +} from '@mui/material' +import { useTranslation } from 'react-i18next' + +interface ComplaintModalProps { + modalOpen: boolean + setModalOpen: (open: boolean) => void + position: any + siriRide: any +} + +const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: ComplaintModalProps) => { + const { t, i18n } = useTranslation() + const [complaintData, setComplaintData] = useState({ + firstName: '', + lastName: '', + id: '', + email: '', + phone: '', + complaintType: '', + description: '', + }) + + const modalStyle = { + position: 'absolute' as 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 400, + bgcolor: 'background.paper', + border: '2px solid #000', + boxShadow: 24, + p: 4, + textAlign: i18n.language === 'he' ? 'left' : 'right', + } + + const handleInputChange = (e: ChangeEvent) => { + const { name, value } = e.target + setComplaintData((prevData) => ({ ...prevData, [name]: value })) + } + + const handleSelectChange = (e: SelectChangeEvent) => { + const { name, value } = e.target + setComplaintData((prevData) => ({ ...prevData, [name]: value })) + } + + const handleSubmit = () => { + const complaintPayload = { + userData: complaintData, + databusData: { + operator: siriRide?.gtfsRideGtfsRouteId, + ...position, + }, + } + console.log(complaintPayload) + // Handle the form submission, e.g., send it to an API + setModalOpen(false) + } + + return ( + setModalOpen(false)} + aria-labelledby="modal-modal-title" + aria-describedby="modal-modal-description"> + +

{t('complaint')}

+
+ + + + + + + {t('complaint_type')} + + + + + + +
+
+ ) +} + +export default ComplaintModal From 41607a635b13da7891c6bb4980b916f3447958e5 Mon Sep 17 00:00:00 2001 From: LiadOvdat5 Date: Mon, 10 Jun 2024 08:57:50 +0300 Subject: [PATCH 02/10] fix bug --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index c015952a..a936012e 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -51,7 +51,7 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai const handleSelectChange = (e: SelectChangeEvent) => { const { name, value } = e.target - setComplaintData((prevData) => ({ ...prevData, [name]: value })) + setComplaintData((prevData) => ({ ...prevData, [name]: value } as const)) } const handleSubmit = () => { From c54eaf42675f9f7207d81a49f6f9214973b68f64 Mon Sep 17 00:00:00 2001 From: LiadOvdat5 Date: Mon, 10 Jun 2024 09:01:01 +0300 Subject: [PATCH 03/10] fix bug --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index a936012e..0310166c 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -51,9 +51,8 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai const handleSelectChange = (e: SelectChangeEvent) => { const { name, value } = e.target - setComplaintData((prevData) => ({ ...prevData, [name]: value } as const)) + setComplaintData((prevData) => ({ ...prevData, [name]: value }) as const) } - const handleSubmit = () => { const complaintPayload = { userData: complaintData, From 316a8f46883f179a8f0ee6bad96ecfec91295b73 Mon Sep 17 00:00:00 2001 From: LiadOvdat5 Date: Mon, 10 Jun 2024 09:06:48 +0300 Subject: [PATCH 04/10] fix bug --- .../components/map-related/MapLayers/ComplaintModal.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index 0310166c..ca5c36b9 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -15,8 +15,8 @@ import { useTranslation } from 'react-i18next' interface ComplaintModalProps { modalOpen: boolean setModalOpen: (open: boolean) => void - position: any - siriRide: any + position: { lat: number; lng: number } + siriRide: { gtfsRideGtfsRouteId: string } } const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: ComplaintModalProps) => { @@ -32,7 +32,7 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai }) const modalStyle = { - position: 'absolute' as 'absolute', + position: 'absolute' as const, top: '50%', left: '50%', transform: 'translate(-50%, -50%)', From 0e98a9dfa3973783db0a3eb04004e2a3530261a5 Mon Sep 17 00:00:00 2001 From: LiadOvdat5 Date: Mon, 10 Jun 2024 09:11:27 +0300 Subject: [PATCH 05/10] returning position and siriRide to any in ComplaintModal --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index ca5c36b9..0b4aacd0 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -15,8 +15,8 @@ import { useTranslation } from 'react-i18next' interface ComplaintModalProps { modalOpen: boolean setModalOpen: (open: boolean) => void - position: { lat: number; lng: number } - siriRide: { gtfsRideGtfsRouteId: string } + position: any + siriRide: any } const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: ComplaintModalProps) => { From f8dab1c16b2f1e187038c4241c51b10a5eaf1000 Mon Sep 17 00:00:00 2001 From: Liad Ovdat <61656328+LiadOvdat5@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:22:13 +0300 Subject: [PATCH 06/10] Update src/pages/components/map-related/MapLayers/ComplaintModal.tsx Co-authored-by: Noam Gaash --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index 0b4aacd0..cc90d319 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -42,7 +42,7 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai boxShadow: 24, p: 4, textAlign: i18n.language === 'he' ? 'left' : 'right', - } + } as const const handleInputChange = (e: ChangeEvent) => { const { name, value } = e.target From 94715df58929b94ad60a021856dd2f6006968948 Mon Sep 17 00:00:00 2001 From: Liad Ovdat <61656328+LiadOvdat5@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:22:20 +0300 Subject: [PATCH 07/10] Update src/pages/components/map-related/MapLayers/ComplaintModal.tsx Co-authored-by: Noam Gaash --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index cc90d319..94ac3a8d 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -82,7 +82,6 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai onChange={handleInputChange} fullWidth margin="normal" - //sx={{ textAlign: i18n.language === 'he' ? 'left' : 'right' }} /> Date: Tue, 11 Jun 2024 12:32:42 +0300 Subject: [PATCH 08/10] making position point --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index 94ac3a8d..bc7be70c 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -11,16 +11,18 @@ import { SelectChangeEvent, } from '@mui/material' import { useTranslation } from 'react-i18next' +import { Point } from 'src/pages/timeBasedMap' interface ComplaintModalProps { modalOpen: boolean setModalOpen: (open: boolean) => void - position: any + position: Point siriRide: any } const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: ComplaintModalProps) => { const { t, i18n } = useTranslation() + const [complaintData, setComplaintData] = useState({ firstName: '', lastName: '', From b5e176189c263dc1d4e097dd71ac23caaa7cab1e Mon Sep 17 00:00:00 2001 From: LiadOvdat5 Date: Thu, 13 Jun 2024 14:54:39 +0300 Subject: [PATCH 09/10] bring siriRide from inside of complaint modal instead of treafering it --- .../map-related/MapLayers/BusToolTip.tsx | 7 +- .../map-related/MapLayers/ComplaintModal.tsx | 223 ++++++++++-------- 2 files changed, 124 insertions(+), 106 deletions(-) diff --git a/src/pages/components/map-related/MapLayers/BusToolTip.tsx b/src/pages/components/map-related/MapLayers/BusToolTip.tsx index 8ec5f105..ad7a2dbc 100644 --- a/src/pages/components/map-related/MapLayers/BusToolTip.tsx +++ b/src/pages/components/map-related/MapLayers/BusToolTip.tsx @@ -110,12 +110,7 @@ export function BusToolTip({ position, icon }: BusToolTipProps) { {/* Complaint Modal */} - + {showJson && (
e.stopPropagation()}> diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index bc7be70c..b66f9e56 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -1,4 +1,4 @@ -import { useState, ChangeEvent } from 'react' +import { useState, ChangeEvent, useEffect } from 'react' import { Box, Button, @@ -9,20 +9,23 @@ import { Select, TextField, SelectChangeEvent, + CircularProgress, } from '@mui/material' import { useTranslation } from 'react-i18next' import { Point } from 'src/pages/timeBasedMap' +import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client' +import { getSiriRideWithRelated } from 'src/api/siriService' interface ComplaintModalProps { modalOpen: boolean setModalOpen: (open: boolean) => void position: Point - siriRide: any } -const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: ComplaintModalProps) => { +const ComplaintModal = ({ modalOpen, setModalOpen, position }: ComplaintModalProps) => { const { t, i18n } = useTranslation() - + const [siriRide, setSiriRide] = useState() + const [isLoading, setIsLoading] = useState(false) const [complaintData, setComplaintData] = useState({ firstName: '', lastName: '', @@ -33,6 +36,17 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai description: '', }) + useEffect(() => { + setIsLoading(true) + getSiriRideWithRelated( + position.point!.siri_route__id.toString(), + position.point!.siri_ride__vehicle_ref.toString(), + position.point!.siri_route__line_ref.toString(), + ) + .then((siriRideRes: SiriRideWithRelatedPydanticModel) => setSiriRide(siriRideRes)) + .finally(() => setIsLoading(false)) + }, [position]) + const modalStyle = { position: 'absolute' as const, top: '50%', @@ -69,102 +83,111 @@ const ComplaintModal = ({ modalOpen, setModalOpen, position, siriRide }: Complai } return ( - setModalOpen(false)} - aria-labelledby="modal-modal-title" - aria-describedby="modal-modal-description"> - -

{t('complaint')}

-
- - - - - - - {t('complaint_type')} - - - - - - -
-
+
+ {isLoading || !siriRide ? ( +
+ {t('loading_routes')} + +
+ ) : ( + setModalOpen(false)} + aria-labelledby="modal-modal-title" + aria-describedby="modal-modal-description"> + +

{t('complaint')}

+
+ + + + + + + {t('complaint_type')} + + + + + + +
+
+ )} +
) } From f8b6fb4ef99200a89652204410f2c0bf4603cabf Mon Sep 17 00:00:00 2001 From: Noam Gaash Date: Tue, 18 Jun 2024 09:10:30 +0300 Subject: [PATCH 10/10] refactor: lint fix --- src/pages/components/map-related/MapLayers/ComplaintModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx index b66f9e56..d93f94ba 100644 --- a/src/pages/components/map-related/MapLayers/ComplaintModal.tsx +++ b/src/pages/components/map-related/MapLayers/ComplaintModal.tsx @@ -12,8 +12,8 @@ import { CircularProgress, } from '@mui/material' import { useTranslation } from 'react-i18next' -import { Point } from 'src/pages/timeBasedMap' import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client' +import { Point } from 'src/pages/timeBasedMap' import { getSiriRideWithRelated } from 'src/api/siriService' interface ComplaintModalProps {