design modal map in step 2

This commit is contained in:
Ehsan
2024-10-21 00:30:50 +03:30
parent 24fbae8797
commit 97939fb101
5 changed files with 143 additions and 62 deletions
+2 -3
View File
@@ -9,7 +9,7 @@ import GeneralInformation from "./listMenu/generalInformation";
import Step from "./Step"; import Step from "./Step";
function AddDoctorPage() { function AddDoctorPage() {
const [value, setValue] = useState(2); const [value, setValue] = useState(1);
const [data, setData] = useState({ const [data, setData] = useState({
general: { general: {
name: { value: "", placeholder: "احسان احمدی", isEdit: true }, name: { value: "", placeholder: "احسان احمدی", isEdit: true },
@@ -25,7 +25,7 @@ function AddDoctorPage() {
degree: { value: "", isEdit: true }, degree: { value: "", isEdit: true },
}, },
office: { office: {
address: { value: "", isEdit: true }, address: { value: "مپ", isEdit: true },
phone: { value: "", placeholder: 1741025645, isEdit: true }, phone: { value: "", placeholder: 1741025645, isEdit: true },
office_number1: { value: "", isEdit: true }, office_number1: { value: "", isEdit: true },
office_number2: { value: "", isEdit: true }, office_number2: { value: "", isEdit: true },
@@ -83,7 +83,6 @@ function AddDoctorPage() {
}, },
], ],
}); });
console.log(data);
const components = [ const components = [
<GeneralInformation <GeneralInformation
@@ -5,8 +5,15 @@ import EditField from "@/app/component/EditField";
import ContentText from "@/app/component/ContentText"; import ContentText from "@/app/component/ContentText";
import AddLocationP from "@/components/icons/AddLocationP"; import AddLocationP from "@/components/icons/AddLocationP";
import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect"; import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
import { useState } from "react";
import ModalMap from "./modal";
function Form({ parent, data, setData }) { function Form({ parent, data, setData }) {
const [open, setOpen] = useState(false);
const handleClose = () => setOpen(false);
const handleOpen = () => setOpen(true);
const changeData = (value, type, name) => const changeData = (value, type, name) =>
type !== "isEdit" && type !== "isEdit" &&
setData((prev) => { setData((prev) => {
@@ -23,65 +30,74 @@ function Form({ parent, data, setData }) {
}); });
return ( return (
<div className="mt-[24px] grid grid-cols-1 md:grid-cols-2 gap-x-[48px] gap-y-[24px]"> <>
<ContentText text="استان"> <div className="mt-[24px] grid grid-cols-1 md:grid-cols-2 gap-x-[48px] gap-y-[24px]">
<AutoCompleteSelect <ContentText text="استان">
updateData={changeData} <AutoCompleteSelect
label="انتخاب کنید..." updateData={changeData}
name="state" label="انتخاب کنید..."
list={state} name="state"
/> list={state}
</ContentText> />
<ContentText text="شهر"> </ContentText>
<AutoCompleteSelect <ContentText text="شهر">
updateData={changeData} <AutoCompleteSelect
label="انتخاب کنید..." updateData={changeData}
name="city" label="انتخاب کنید..."
list={city} name="city"
/> list={city}
</ContentText> />
<ContentText text="آدرس"> </ContentText>
<EditField <ContentText text="آدرس">
icon={<AddLocationP />} <div className="relative w-full">
isTransparent={true} <EditField
placeholder="از روی نقشه انتخاب کنید..." icon={<AddLocationP />}
iconGray={true} isTransparent={true}
changeData={changeData} placeholder="از روی نقشه انتخاب کنید..."
data={data?.address} iconGray={true}
name="address" changeData={changeData}
/> data={data?.address}
</ContentText> name="address"
<ContentText text="شماره موبایل"> />
<EditField <div
isTransparent={true} className="absolute left-0 top-0 w-full h-full opacity-0 z-10 cursor-pointer"
placeholder="شماره موبایل" onClick={handleOpen}
iconGray={true} ></div>
changeData={changeData} </div>
data={data?.phone} </ContentText>
name="phone" <ContentText text="شماره موبایل">
/> <EditField
</ContentText> isTransparent={true}
<ContentText text="شماره مطب"> placeholder="شماره موبایل"
<EditField iconGray={true}
isTransparent={true} changeData={changeData}
placeholder="شماره مطب" data={data?.phone}
iconGray={true} name="phone"
changeData={changeData} />
data={data?.office_number1} </ContentText>
name="office_number1" <ContentText text="شماره مطب">
/> <EditField
</ContentText> isTransparent={true}
<ContentText text="شماره مطب"> placeholder="شماره مطب"
<EditField iconGray={true}
isTransparent={true} changeData={changeData}
placeholder="شماره مطب" data={data?.office_number1}
iconGray={true} name="office_number1"
changeData={changeData} />
data={data?.office_number2} </ContentText>
name="office_number2" <ContentText text="شماره مطب">
/> <EditField
</ContentText> isTransparent={true}
</div> placeholder="شماره مطب"
iconGray={true}
changeData={changeData}
data={data?.office_number2}
name="office_number2"
/>
</ContentText>
</div>
<ModalMap open={open} handleClose={handleClose} />
</>
); );
} }
@@ -0,0 +1,53 @@
import { styleDefault } from "@/mui";
import { Modal } from "@mui/material";
import { useState } from "react";
import MapPicker from "react-google-map-picker";
const DefaultLocation = {
lat: 9.912345921562734,
lng: 105.97776559918576,
};
const DefaultZoom = 10;
function ModalMap({ open, handleClose }) {
const [defaultLocation, setDefaultLocation] = useState(DefaultLocation);
const [location, setLocation] = useState(defaultLocation);
const [zoom, setZoom] = useState(DefaultZoom);
function handleChangeLocation(lat, lng) {
setLocation({ lat: lat, lng: lng });
}
function handleChangeZoom(newZoom) {
setZoom(newZoom);
}
function handleResetLocation() {
setDefaultLocation({ ...DefaultLocation });
setZoom(DefaultZoom);
}
return (
<Modal open={open} onClose={handleClose} className="w-full">
<div
style={styleDefault}
className="!px-[16px] !overflow-auto md:!min-w-[580px] md:!px-[24px] lg:!px-[32px] !py-[24px] !bg-[#FFF] !rounded-[8px] !shadow-[0px_1px_24.8px_0px_rgba(204,_204,_204,_0.18)]
!w-full md:!w-fit !h-full md:!h-fit !flex !flex-col !justify-between !max-h-screen md:!max-h-[calc(100%_-_32px)]"
>
<MapPicker
zoom={zoom}
mapTypeId="roadmap"
style={{ height: "500px" }}
onChangeZoom={handleChangeZoom}
defaultLocation={defaultLocation}
onChangeLocation={handleChangeLocation}
apiKey="AIzaSyD07E1VvpsN_0FvsmKAj4nK9GnLq-9jtj8"
/>
</div>
</Modal>
);
}
export default ModalMap;
+12
View File
@@ -27,6 +27,7 @@
"npm": "^10.8.2", "npm": "^10.8.2",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18", "react-dom": "^18",
"react-google-map-picker": "^1.2.3",
"styled-components": "^6.1.11", "styled-components": "^6.1.11",
"stylis": "^4.3.4", "stylis": "^4.3.4",
"stylis-plugin-rtl": "^2.1.1", "stylis-plugin-rtl": "^2.1.1",
@@ -19059,6 +19060,17 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
"integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg=="
}, },
"node_modules/react-google-map-picker": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/react-google-map-picker/-/react-google-map-picker-1.2.3.tgz",
"integrity": "sha512-XeIj0Eh0vhNToMTebQQrt5O9fdPRDf4KtG8J22xupH7Pu49J1dP5UuhfCM6VmK2nIv5ECyQUpOT6+gZgGaQhJA==",
"engines": {
"node": ">=10"
},
"peerDependencies": {
"react": "^17.0.0"
}
},
"node_modules/react-is": { "node_modules/react-is": {
"version": "18.3.1", "version": "18.3.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
+1
View File
@@ -28,6 +28,7 @@
"npm": "^10.8.2", "npm": "^10.8.2",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18", "react-dom": "^18",
"react-google-map-picker": "^1.2.3",
"styled-components": "^6.1.11", "styled-components": "^6.1.11",
"stylis": "^4.3.4", "stylis": "^4.3.4",
"stylis-plugin-rtl": "^2.1.1", "stylis-plugin-rtl": "^2.1.1",