-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added complaint button, hidden as an easter egg 'complaint'. #791
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ef84f83
Added complaint button, hidden as an easter egg 'complaint'.
LiadOvdat5 41607a6
fix bug
LiadOvdat5 61dc27e
Merge branch 'main' into Add-Complaint-Button
LiadOvdat5 c54eaf4
fix bug
LiadOvdat5 2958356
Merge branch 'Add-Complaint-Button' of https://github.com/LiadOvdat5/…
LiadOvdat5 316a8f4
fix bug
LiadOvdat5 0e98a9d
returning position and siriRide to any in ComplaintModal
LiadOvdat5 f8dab1c
Update src/pages/components/map-related/MapLayers/ComplaintModal.tsx
LiadOvdat5 94715df
Update src/pages/components/map-related/MapLayers/ComplaintModal.tsx
LiadOvdat5 13023c7
making position point
LiadOvdat5 b5e1761
bring siriRide from inside of complaint modal instead of treafering it
LiadOvdat5 457fe41
Merge branch 'main' into Add-Complaint-Button
NoamGaash f8b6fb4
refactor: lint fix
NoamGaash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
src/pages/components/map-related/MapLayers/ComplaintModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
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 const, | ||
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something feels weird about this condition, are you sure it works as intended? |
||
} | ||
LiadOvdat5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const handleInputChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => { | ||
const { name, value } = e.target | ||
setComplaintData((prevData) => ({ ...prevData, [name]: value })) | ||
} | ||
|
||
const handleSelectChange = (e: SelectChangeEvent<string>) => { | ||
const { name, value } = e.target | ||
setComplaintData((prevData) => ({ ...prevData, [name]: value }) as const) | ||
} | ||
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 ( | ||
<Modal | ||
open={modalOpen} | ||
onClose={() => setModalOpen(false)} | ||
aria-labelledby="modal-modal-title" | ||
aria-describedby="modal-modal-description"> | ||
<Box className="modal" sx={modalStyle}> | ||
<h2>{t('complaint')}</h2> | ||
<form> | ||
<TextField | ||
label={t('first_name')} | ||
name="firstName" | ||
value={complaintData.firstName} | ||
onChange={handleInputChange} | ||
fullWidth | ||
margin="normal" | ||
//sx={{ textAlign: i18n.language === 'he' ? 'left' : 'right' }} | ||
LiadOvdat5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
<TextField | ||
label={t('last_name')} | ||
name="lastName" | ||
value={complaintData.lastName} | ||
onChange={handleInputChange} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label={t('id')} | ||
name="id" | ||
value={complaintData.id} | ||
onChange={handleInputChange} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label={t('email')} | ||
name="email" | ||
value={complaintData.email} | ||
onChange={handleInputChange} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<TextField | ||
label={t('phone')} | ||
name="phone" | ||
value={complaintData.phone} | ||
onChange={handleInputChange} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<FormControl fullWidth margin="normal"> | ||
<InputLabel>{t('complaint_type')}</InputLabel> | ||
<Select | ||
name="complaintType" | ||
value={complaintData.complaintType} | ||
onChange={handleSelectChange} | ||
sx={{ textAlign: i18n.language === 'he' ? 'left' : 'right' }}> | ||
<MenuItem value="other">{t('other')}</MenuItem> | ||
<MenuItem value="no_stop">{t('no_stop')}</MenuItem> | ||
<MenuItem value="no_ride">{t('no_ride')}</MenuItem> | ||
<MenuItem value="delay">{t('delay')}</MenuItem> | ||
<MenuItem value="overcrowded">{t('overcrowded')}</MenuItem> | ||
<MenuItem value="driver_behavior">{t('driver_behavior')}</MenuItem> | ||
<MenuItem value="early">{t('early')}</MenuItem> | ||
<MenuItem value="cleanliness">{t('cleanliness')}</MenuItem> | ||
<MenuItem value="fine_appeal">{t('fine_appeal')}</MenuItem> | ||
<MenuItem value="route_change">{t('route_change')}</MenuItem> | ||
<MenuItem value="line_switch">{t('line_switch')}</MenuItem> | ||
<MenuItem value="station_signs">{t('station_signs')}</MenuItem> | ||
</Select> | ||
</FormControl> | ||
<TextField | ||
label={t('description')} | ||
name="description" | ||
value={complaintData.description} | ||
onChange={handleInputChange} | ||
multiline | ||
rows={4} | ||
fullWidth | ||
margin="normal" | ||
/> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
onClick={handleSubmit} | ||
style={{ marginTop: '16px', borderRadius: '50px' }}> | ||
{t('submit_complaint')} | ||
</Button> | ||
</form> | ||
<Button | ||
variant="contained" | ||
color="success" | ||
onClick={() => setModalOpen(false)} | ||
style={{ marginTop: '16px', borderRadius: '50px' }}> | ||
{t('close_complaint')} | ||
</Button> | ||
</Box> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default ComplaintModal |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.