Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
itsliterallymonique committed Nov 24, 2024
1 parent ae9fdba commit 12cae63
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 34 deletions.
6 changes: 5 additions & 1 deletion api/maps/AddMarkers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ import { MarkerInfoWindow } from './MarkerInfoWindow';

export default function AddMarker({
projects,
setMap,
map,
}: {
projects: Project[] | null;
setMap: React.Dispatch<React.SetStateAction<google.maps.Map | null>>;
map: google.maps.Map | null;
}) {
const [selectedProjectId, setSelectedProjectId] = useState<number | null>(
null,
); // track currently open modal

const map = useMap();
setMap(useMap());

const handleMarkerClick = (
projectId: number,
Expand Down
23 changes: 0 additions & 23 deletions app/testing/page.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions components/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const center = {

const mapId = '54eb1c7baba5a715'; // needed for AdvancedMarker

export default function Map(props: { projects: Project[] | null }) {
export default function Map(props: { projects: Project[] | null, setMap: React.Dispatch<React.SetStateAction<google.maps.Map | null>>, map: google.maps.Map | null}) {
return (
<APIProvider apiKey={process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY as string}>
<GoogleMap
Expand All @@ -34,7 +34,7 @@ export default function Map(props: { projects: Project[] | null }) {
mapTypeId={'roadmap'}
clickableIcons={false}
>
<AddMarkers projects={props.projects} />
<AddMarkers projects={props.projects} setMap={props.setMap} map={props.map} />
</GoogleMap>
</APIProvider>
);
Expand Down
8 changes: 4 additions & 4 deletions components/MapViewScreen/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { APIProvider } from '@vis.gl/react-google-maps';
import { APIProvider, useMap } from '@vis.gl/react-google-maps';
import {
LocationIcon,
ProjectSizeIcon,
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function MapViewScreen({
icon: <LocationIcon />,
},
];

const [map, setMap] = useState<google.maps.Map | null>(useMap());
const [searchTerm, setSearchTerm] = useState('');
const [selectedFilters, setSelectedFilters] = useState<Filters>({
status: [],
Expand Down Expand Up @@ -76,8 +76,8 @@ export default function MapViewScreen({
selectedFilters={selectedFilters}
setSelectedFilters={setSelectedFilters}
/>
<Map projects={projects} />
<ProjectsListingModal projects={filteredProjects} />
<Map projects={projects} setMap={setMap} map={map}/>
<ProjectsListingModal projects={filteredProjects} map={map}/>
</APIProvider>
);
}
4 changes: 1 addition & 3 deletions components/ProjectItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ import {
StyledProjectItem,
} from './styles';

export default function ProjectItem({ project_id }: { project_id: number }) {
export default function ProjectItem({ project_id, map }: { project_id: number , map: google.maps.Map | null}) {
const [project, setProject] = useState<Project | null>(null);
const [defaultImage, setDefaultImage] = useState<string | null>(null);
const [modalOpen, setModalOpen] = useState(false);

const map = useMap();

useEffect(() => {
queryProjectbyId(project_id).then(data => {
setProject(data);
Expand Down
4 changes: 3 additions & 1 deletion components/ProjectsListingModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import {

export default function ProjectsListingModal({
projects,
map,
}: {
projects: Project[] | null;
map: google.maps.Map | null;
}) {
const projectItems = projects?.map((project: Project) => {
return <ProjectItem key={project.id} project_id={project.id} />;
return <ProjectItem key={project.id} project_id={project.id} map={map}/>;
});

return (
Expand Down

0 comments on commit 12cae63

Please sign in to comment.