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
31 changes: 19 additions & 12 deletions src/app/modules/_noAuth/Property/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import PropertyDetails from './PropertyDetails';
import PropertyAgent from './PropertyAgent';
import PropertyImages from './PropertyImages';
import PropertyDetailsDesktop from './PropertyDetailsDesktop';
import MapButton from '../../__modules__/MapButton/index';

const PropertyContainer = () => {
const [property, setProperty] = useState<IProperty | null>(null);
Expand Down Expand Up @@ -117,14 +116,14 @@ const PropertyContainer = () => {
setReadMore(!readMore);
};

const openMapBox = () => {
setOpenMap(true);
setShowMapButtom(false);
};

const closeMapBox = () => {
setOpenMap(false);
setShowMapButtom(true);
const toggleMap = () => {
if (!openMap && showMapButton) {
setOpenMap(true);
setShowMapButtom(false);
} else {
setOpenMap(false);
setShowMapButtom(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 for the if statement here either.

You can also rename the function to onClick

};

return (
Expand Down Expand Up @@ -152,7 +151,7 @@ const PropertyContainer = () => {
<MapBox
property={property}
isLoading={isLoading}
closeMap={closeMapBox}
onClick={toggleMap}
/>
</>
)}
Expand Down Expand Up @@ -181,7 +180,7 @@ const PropertyContainer = () => {
isLoading={isLoading}
property={property}
agent={agent}
openMap={openMapBox}
onClick={toggleMap}
showMapButton={showMapButton}
/>
)}
Expand Down Expand Up @@ -234,7 +233,15 @@ const PropertyContainer = () => {
>
Contacter l&apos;agent
</button>
{showMapButton && <MapButton onClick={openMapBox} />}
{showMapButton && (
<button
type="submit"
onClick={toggleMap}
className="w-full p-3 bg-brand-bold text-white rounded-lg md:mx-auto md:px-16 mt-4"
>
Voir sur map
</button>
)}
</ShowWidget>
</div>
)}
Expand Down