From 31f89a120ede2601d765d92498e23bf79b760dbb Mon Sep 17 00:00:00 2001 From: dhruvishah122 Date: Tue, 8 Oct 2024 00:19:25 +0530 Subject: [PATCH] close icon added --- client/src/components/SimpleDialog.jsx | 80 +++++++++++++++----------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/client/src/components/SimpleDialog.jsx b/client/src/components/SimpleDialog.jsx index 1043eb9..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 { 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 - { + 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;