Skip to content
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

Map feature #40

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions src/app/modules/__modules__/MapBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@ interface ICoordinates {
interface Props {
property: IProperty | null;
isLoading: boolean;
closeMap: () => void;
onClick: () => void;
}

const MapBox = ({
property,
isLoading,
closeMap,
onClick,
}: Props): ReactElement => {
const [lng] = useState(32.58252);
const [lat] = useState(0.347596);
const [coordinates] = useState({
lng: 32.58252,
lat: 0.347596,
});
const [displayPupUp, setDisplayPopUp] = useState(true);

const [viewport, setViewport] = useState<ICoordinates>({
longitude: lng,
latitude: lat,
longitude: coordinates.lng,
latitude: coordinates.lat,
zoom: 12,
});

const showPopUp = () => {
setDisplayPopUp(true);
};
const closePopUp = () => {
setDisplayPopUp(false);
const togglePopUp = () => {
if (displayPupUp) setDisplayPopUp(false);
else {
setDisplayPopUp(true);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to make use of if statement here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can i use switch ? cause i don't understand why the is should be removed !

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. I was meaning I have to use it like the following:
setDisplayPopup(!displayPopup)
Which will be toggling the value of displayPopup

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean why the if statement should be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh okey ! i get it ! thanks

};

return (
Expand All @@ -62,20 +64,20 @@ const MapBox = ({
}}
>
<NavigationControl className="right-4 top-4" />
<div onClick={closeMap} aria-hidden>
<div onClick={onClick} aria-hidden>
<CloseVector className="text-black bg-white shadow-xl rounded-lg mt-4 ml-4 cursor-pointer" />
</div>
<MapBoxMarker
latitude={lat}
longitude={lng}
showPopUp={showPopUp}
latitude={coordinates.lat}
longitude={coordinates.lng}
onClick={togglePopUp}
/>
{displayPupUp && (
<MapBoxPopUp
property={property}
latitude={lat}
longitude={lng}
closePopUp={closePopUp}
latitude={coordinates.lat}
longitude={coordinates.lng}
onClose={togglePopUp}
/>
)}
</ReactMapGL>
Expand Down