-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #80
- Loading branch information
Showing
14 changed files
with
122 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import React from 'react'; | ||
import { RouteComponentProps, useHistory } from 'react-router-dom'; | ||
import { useFindVolunteerActionsQuery } from '../dataFacade'; | ||
import { IonLoading, IonPage, IonContent, IonFooter } from '@ionic/react'; | ||
import { Header, Empty } from '../components'; | ||
import { Marker } from 'google-maps-react'; | ||
import { Map } from '../components/Map'; | ||
|
||
const RED_DOT = "http://maps.google.com/mapfiles/ms/icons/red-dot.png"; | ||
const YELLOW_DOT = "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png"; | ||
|
||
export const ActionsMapPage: React.FC<RouteComponentProps> = ({ match }) => { | ||
const history = useHistory(); | ||
const { data, loading, error } = useFindVolunteerActionsQuery(); | ||
|
||
if (error) { | ||
console.log(error); | ||
} | ||
|
||
if (loading) { | ||
return <IonLoading isOpen={loading} message={'Loading...'} /> | ||
}; | ||
|
||
const volunteerActions = data?.findVolunteerActions?.items || []; | ||
|
||
|
||
let mapContent = <Empty />; | ||
|
||
if (volunteerActions.length > 0) { | ||
const totalLatLong = { | ||
lat: 0, lng: 0 | ||
}; | ||
|
||
const markers: JSX.Element[] = []; | ||
|
||
const getDistributionCentreMarker = (distributionCentre: any, index: number): JSX.Element => { | ||
const lat = distributionCentre?.lat!; | ||
const lng = distributionCentre?.long!; | ||
|
||
totalLatLong.lat += lat; | ||
totalLatLong.lng += lng; | ||
|
||
const title = `${distributionCentre?.address1} ${distributionCentre?.address2} ${distributionCentre?.city}`; | ||
|
||
return <Marker | ||
key={index} | ||
title={title} | ||
label={distributionCentre?.name!} | ||
icon={{ | ||
url: YELLOW_DOT | ||
}} | ||
onClick={() => history.push(`/manageDistributionCentre/${distributionCentre?.id}`)} | ||
position={{ | ||
lat, | ||
lng | ||
}} /> | ||
|
||
} | ||
|
||
const getRecipientMarker = (recipient: any, index: number): JSX.Element => { | ||
const lat = recipient?.lat!; | ||
const lng = recipient?.long!; | ||
|
||
totalLatLong.lat += lat; | ||
totalLatLong.lng += lng; | ||
|
||
const title = `${recipient?.address1} ${recipient?.address2} ${recipient?.city}`; | ||
|
||
return <Marker | ||
key={index} | ||
title={title} | ||
label={recipient?.firstName! + " " + recipient?.lastName!} | ||
icon={{ | ||
url: RED_DOT | ||
}} | ||
onClick={() => history.push(`/manageRecipient/${recipient?.id}`)} | ||
position={{ | ||
lat, | ||
lng | ||
}} /> | ||
|
||
} | ||
|
||
let markersCounter = 0; | ||
for (const volunteerAction of volunteerActions) { | ||
const recipient = volunteerAction?.recipient; | ||
const distributionCentre = volunteerAction?.distributionCentre; | ||
markers.push(getRecipientMarker(recipient, markersCounter++)); | ||
markers.push(getDistributionCentreMarker(distributionCentre, markersCounter++)); | ||
} | ||
|
||
mapContent = <Map | ||
zoom={2} | ||
center={{ | ||
lat: totalLatLong.lat / markersCounter, | ||
lng: totalLatLong.lng / markersCounter | ||
}}> | ||
{markers} | ||
</Map> | ||
} | ||
|
||
return ( | ||
<IonPage> | ||
<Header title="Actions Map" match={match} /> | ||
<IonContent className="ion-padding" > | ||
{mapContent} | ||
</IonContent> | ||
<IonFooter> | ||
<div> | ||
OpenVolunteer Platform | ||
</div> | ||
</IonFooter> | ||
</IonPage > | ||
); | ||
|
||
}; |
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 was deleted.
Oops, something went wrong.
Binary file modified
BIN
+27 Bytes
(140%)
platform/server/mongodump/showcase/recipient/5e8f3e8a92787169c1e7cd84.bson
Binary file not shown.
Binary file modified
BIN
+27 Bytes
(110%)
platform/server/mongodump/showcase/recipient/5e8f3eca92787169c1e7cd85.bson
Binary file not shown.
Binary file modified
BIN
+27 Bytes
(120%)
platform/server/mongodump/showcase/recipient/5e8f3ed492787169c1e7cd86.bson
Binary file not shown.
Binary file modified
BIN
+27 Bytes
(120%)
platform/server/mongodump/showcase/recipient/5e8f3ee392787169c1e7cd88.bson
Binary file not shown.
Binary file modified
BIN
+27 Bytes
(120%)
platform/server/mongodump/showcase/recipient/5e8f3ef492787169c1e7cd89.bson
Binary file not shown.
Binary file modified
BIN
+27 Bytes
(110%)
platform/server/mongodump/showcase/recipient/5ec79237fe5b9f1db7aea0b6.bson
Binary file not shown.
Binary file modified
BIN
+27 Bytes
(110%)
platform/server/mongodump/showcase/recipient/5ec79943e72f861f0066b66e.bson
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(110%)
platform/server/mongodump/showcase/volunteeraction/5ec79271fe5b9f1db7aea0b7.bson
Binary file not shown.