Skip to content

Commit

Permalink
Merge pull request #1503 from OneCommunityGlobal/leon_add_interactive…
Browse files Browse the repository at this point in the history
…_map

Leon and Oleksandr add interactive map
  • Loading branch information
one-community authored Nov 25, 2023
2 parents df93e43 + 2dec5eb commit a1ba8ab
Show file tree
Hide file tree
Showing 23 changed files with 912 additions and 52 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ src/components/SummaryManagement/**
src/components/TaskEditSuggestions/**
src/components/TeamMemberTasks/**
src/components/Teams/**
src/components/TeamLocations/**
src/components/Timelog/**
src/components/UpdatePassword/**
src/components/UserManagement/**
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ src/components/SetupProfile/**
src/components/SummaryBar/**
src/components/SummaryManagement/**
src/components/TaskEditSuggestions/**
src/components/TeamLocations/**
src/components/TeamMemberTasks/**
src/components/Teams/**
src/components/Timelog/**
Expand Down
Binary file modified images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = {
// Bundle mapper for d3 import
moduleNameMapper: {
d3: '<rootDir>/node_modules/d3/dist/d3.min.js',
'react-leaflet': '<rootDir>/src/_tests_/__mocks__/react-leaflet.js',
'marker-cluster-group': '<rootDir>/src/_tests_/__mocks__/react-leaflet-cluster.js',
},

// The paths to modules that run some code to configure or set up the testing environment before each test
Expand Down
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"joi": "^14.0.6",
"js-levenshtein": "^1.1.6",
"jwt-decode": "^2.2.0",
"leaflet": "^1.9.4",
"lodash": "^4.17.21",
"moment": "^2.29.2",
"moment-timezone": "^0.5.33",
Expand All @@ -49,6 +50,8 @@
"react-icons": "^4.3.1",
"react-image": "^2.4.0",
"react-input-range": "^1.3.0",
"react-leaflet": "^4.2.1",
"react-leaflet-cluster": "^2.1.0",
"react-moment": "^1.1.1",
"react-multi-select-component": "^4.0.2",
"react-phone-input-2": "^2.14.0",
Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/__mocks__/react-leaflet-cluster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test('it should pass', () => {
expect(true).toBe(true);
});
3 changes: 3 additions & 0 deletions src/__tests__/__mocks__/react-leaflet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test('it should pass', () => {
expect(true).toBe(true);
});
14 changes: 12 additions & 2 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TIMELOG,
REPORTS,
WEEKLY_SUMMARIES_REPORT,
TEAM_LOCATIONS,
OTHER_LINKS,
USER_MANAGEMENT,
BADGE_MANAGEMENT,
Expand Down Expand Up @@ -148,9 +149,18 @@ export const Header = props => {
<DropdownItem tag={Link} to="/weeklysummariesreport">
{WEEKLY_SUMMARIES_REPORT}
</DropdownItem>
<DropdownItem tag={Link} to="/teamlocations">
{TEAM_LOCATIONS}
</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>
) : null}
</UncontrolledDropdown>
) :
<NavItem>
<NavLink tag={Link} to="/teamlocations">
{TEAM_LOCATIONS}
</NavLink>
</NavItem>
}
<NavItem>
<NavLink tag={Link} to={`/timelog/${user.userid}`}>
<i className="fa fa-bell i-large">
Expand Down
51 changes: 41 additions & 10 deletions src/components/SetupProfile/SetupProfileUserEntry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ const SetupProfileUserEntry = ({ token, userEmail }) => {
collaborationPreference: 'Zoom',
jobTitle: '',
timeZone: '',
location: '',
location: {
userProvided: '',
coords: { lat: '', lng: '' },
country: '',
city: '',
},
timeZoneFilter: '',
token,
});
Expand Down Expand Up @@ -90,6 +95,24 @@ const SetupProfileUserEntry = ({ token, userEmail }) => {
[id]: value,
}));
};
const handleLocation = event => {
const { id, value } = event.target;
setUserProfile(prevProfile => ({
...prevProfile,
[id]: {
...prevProfile.location,
userProvided: value
},
}));
}
const handleToggle = event => {
const { id } = event.target;
const key = id === 'emailPubliclyAccessible' ? 'email' : 'phoneNumber';
setUserProfile(prevProfile => ({
...prevProfile,
privacySettings: { ...prevProfile.privacySettings, [key]: !prevProfile.privacySettings[key] },
}));
};

const phoneChange = phone => {
setUserProfile(prevProfile => ({
Expand All @@ -103,29 +126,37 @@ const SetupProfileUserEntry = ({ token, userEmail }) => {
...prevErrors,
timeZoneFilterClicked: '',
}));

if (!userProfile.location) {
const location = userProfile.location.userProvided;
if (!location) {
alert('Please enter valid location');
return;
}
if (!APIkey) {
console.log('Geocoding API key missing');
return;
}

getUserTimeZone(userProfile.location, APIkey)
getUserTimeZone(location, APIkey)
.then(response => {
if (
response.data.status.code === 200 &&
response.data.results &&
response.data.results.length
) {
let timezone = response.data.results[0].annotations.timezone.name;

let currentLocation = {
userProvided: location,
coords: {
lat: response.data.results[0].geometry.lat,
lng: response.data.results[0].geometry.lng,
},
country: response.data.results[0].components.country,
city: response.data.results[0].components.city,
};
setUserProfile(prevProfile => ({
...prevProfile,
timeZoneFilter: timezone,
timeZone: timezone,
location: currentLocation
}));
} else {
alert('Invalid location or ' + response.data.status.message);
Expand Down Expand Up @@ -271,7 +302,7 @@ const SetupProfileUserEntry = ({ token, userEmail }) => {

// Validate Location

if (userProfile.location.trim() === '') {
if (userProfile.location.userProvided.trim() === '') {
setFormErrors(prevErrors => ({
...prevErrors,
location: 'Location is required',
Expand Down Expand Up @@ -322,7 +353,7 @@ const SetupProfileUserEntry = ({ token, userEmail }) => {
},
jobTitle: userProfile.jobTitle.trim(),
timeZone: userProfile.timeZone.trim(),
location: userProfile.location.trim(),
location: userProfile.location,
token,
};

Expand Down Expand Up @@ -558,9 +589,9 @@ const SetupProfileUserEntry = ({ token, userEmail }) => {
name="location"
id="location"
placeholder="Location"
value={userProfile.location}
value={userProfile.location.userProvided}
onChange={e => {
handleChange(e);
handleLocation(e);
}}
invalid={formErrors.location !== ''}
/>
Expand Down
Binary file modified src/components/SummaryBar/suggestions_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a1ba8ab

Please sign in to comment.