diff --git a/client/src/components/SimpleDialog.jsx b/client/src/components/SimpleDialog.jsx index c0d8d33..5998d13 100644 --- a/client/src/components/SimpleDialog.jsx +++ b/client/src/components/SimpleDialog.jsx @@ -1,31 +1,30 @@ import Button from '@mui/material/Button'; import DialogTitle from '@mui/material/DialogTitle'; import Dialog from '@mui/material/Dialog'; -import { Input } from '@mui/material'; -import { useState,useEffect } from 'react'; -import { toast } from 'react-hot-toast'; +import { Input, IconButton } from '@mui/material'; +import CloseIcon from '@mui/icons-material/Close'; +import { useState, useEffect } from 'react'; + function SimpleDialog(props) { const { onClose, open } = props; const [pincode, setPincode] = useState(''); const [suggestions, setSuggestions] = useState([]); - + const handleClose = () => { - if(pincode.length === 6 && localStorage.getItem('userArea')){ - onClose(); - } - else - { - toast.error("Please enter a valid pincode & select an area from the list."); + if (pincode.length === 6 && localStorage.getItem('userArea')) { + onClose(); + } else { + alert("Please enter a valid pincode & select an area from the list."); } }; - + useEffect(() => { const fetchSuggestions = async () => { try { if (pincode.length === 6) { const response = await fetch(`https://api.postalpincode.in/pincode/${pincode}`); const data = await response.json(); - + if (data[0]?.Status === 'Success') { const areaSuggestions = data[0]?.PostOffice?.map((office) => office.Name) || []; setSuggestions(areaSuggestions); @@ -40,23 +39,37 @@ function SimpleDialog(props) { setSuggestions([]); } }; - + fetchSuggestions(); }, [pincode]); - + const handleListItemClick = (value) => { onClose(value); }; - + const handleInputChange = (e) => { setPincode(e.target.value); }; - + return ( <> - Enter your Pincode -
+ + Enter your Pincode + theme.palette.grey[500], + }} + > + + + +
{ @@ -73,34 +86,35 @@ function SimpleDialog(props) { onChange={handleInputChange} className="mb-3" /> - - - +
- +
-
    - {suggestions.map((suggestion, index) => ( - <> - + }} + > + {suggestion} +
    - - ))} -
-
+ + ))} + +
); - } +} -export default SimpleDialog; \ No newline at end of file +export default SimpleDialog;