-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #575 from bounswe/frontend/responder_task_map
Responder Specific Map Implementation Changed with The Purpose of Showing Responders Their Tasks Only
- Loading branch information
Showing
2 changed files
with
104 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,50 @@ | ||
import MapPage from "./MapPage"; | ||
import {useQuery} from "@tanstack/react-query"; | ||
import {getAllResources} from "../AppService"; | ||
import {mock_markers} from "./Mock_markers"; | ||
import {Fab} from "@mui/material"; | ||
import {useNavigate} from "react-router-dom"; | ||
import {Add} from "@mui/icons-material"; | ||
|
||
import { useQuery } from "@tanstack/react-query"; | ||
import { viewAllTasks } from "../AppService"; | ||
import { Fab } from "@mui/material"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { Add } from "@mui/icons-material"; | ||
|
||
export default function ResponderMapPage() { | ||
const navigate = useNavigate(); | ||
|
||
const userId = parseInt(localStorage.getItem('userId')); | ||
|
||
const { data, isError, isLoading, error } = useQuery({ | ||
queryKey: ['viewAllTasks', userId], | ||
queryFn: () => viewAllTasks(userId), | ||
}); | ||
|
||
if (isLoading) { | ||
return <div>Loading tasks...</div>; | ||
} | ||
|
||
if (isError) { | ||
console.error('Error fetching tasks:', error); | ||
return <div>Error fetching tasks.</div>; | ||
} | ||
|
||
console.log('Tasks data:', data); | ||
|
||
const taskMarkers = data?.map(task => ({ | ||
lat: task.startLatitude, | ||
lng: task.startLongitude, | ||
title: task.description, | ||
dueDate: task.dueDate, | ||
isCompleted: task.completed, | ||
})); | ||
|
||
|
||
} | ||
return ( | ||
<> | ||
<MapPage allMarkers={taskMarkers || []} /> | ||
<Fab color="primary" variant="extended" onClick={() => navigate("/account")} sx={{ | ||
position: 'absolute', | ||
bottom: 32, | ||
right: 32, | ||
}}> | ||
<Add sx={{ mr: 1 }} /> | ||
My Tasks | ||
</Fab> | ||
</> | ||
); | ||
} |