Skip to content

Commit

Permalink
fix(frontend): resolve merge conflicts with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
royallsilwallz committed Jan 28, 2025
2 parents a076ed6 + 2f67b8c commit f082d5d
Show file tree
Hide file tree
Showing 9 changed files with 462 additions and 31 deletions.
3 changes: 2 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ OSM_REGISTER_URL=https://www.openstreetmap.org/user/new

# API base URL and token(used to retrieve user stats only) for ohsomeNow Stats
#
OHSOME_STATS_BASE_URL=https://stats.now.ohsome.org/api
OHSOME_STATS_BASE_URL=https://stats.now.ohsome.org
OHSOME_STATS_API_URL=https://stats.now.ohsome.org/api
OHSOME_STATS_TOKEN=testSuperSecretTestToken

# Secret (required)
Expand Down
26 changes: 9 additions & 17 deletions frontend/src/api/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';

import { fetchExternalJSONAPI } from '../network/genericJSONRequest';
import api from './apiClient';
import { OHSOME_STATS_BASE_URL, defaultChangesetComment } from '../config';
import { OHSOME_STATS_API_URL, defaultChangesetComment } from '../config';

const ohsomeProxyAPI = (url: string) => {
const token = localStorage.getItem('token');
Expand All @@ -11,9 +11,7 @@ const ohsomeProxyAPI = (url: string) => {
};

export const useSystemStatisticsQuery = () => {
const fetchSystemStats = ({ signal }: {
signal: AbortSignal;
}) => {
const fetchSystemStats = ({ signal }: { signal: AbortSignal }) => {
return api().get(`system/statistics/`, {
signal,
});
Expand All @@ -27,9 +25,7 @@ export const useSystemStatisticsQuery = () => {
};

export const useProjectStatisticsQuery = (projectId: string) => {
const fetchProjectStats = ({ signal }: {
signal: AbortSignal;
}) => {
const fetchProjectStats = ({ signal }: { signal: AbortSignal }) => {
return api().get(`projects/${projectId}/statistics/`, {
signal,
});
Expand All @@ -43,10 +39,8 @@ export const useProjectStatisticsQuery = (projectId: string) => {
};

export const useOsmStatsQuery = () => {
const fetchOsmStats = ({ signal }: {
signal: AbortSignal;
}) => {
return api().get(`${OHSOME_STATS_BASE_URL}/stats/${defaultChangesetComment}-%2A`, {
const fetchOsmStats = ({ signal }: { signal: AbortSignal }) => {
return api().get(`${OHSOME_STATS_API_URL}/stats/${defaultChangesetComment}-%2A`, {
signal,
});
};
Expand All @@ -60,10 +54,8 @@ export const useOsmStatsQuery = () => {
};

export const useOsmHashtagStatsQuery = (defaultComment: string) => {
const fetchOsmStats = ({ signal }: {
signal: AbortSignal;
}) => {
return api().get(`${OHSOME_STATS_BASE_URL}/stats/${defaultComment[0].replace('#', '')}`, {
const fetchOsmStats = ({ signal }: { signal: AbortSignal }) => {
return api().get(`${OHSOME_STATS_API_URL}/stats/${defaultComment[0].replace('#', '')}`, {
signal,
});
};
Expand All @@ -80,7 +72,7 @@ export const useOsmHashtagStatsQuery = (defaultComment: string) => {
export const useUserOsmStatsQuery = (id: string) => {
const fetchUserOsmStats = () => {
return ohsomeProxyAPI(
`${OHSOME_STATS_BASE_URL}/topic/poi,highway,building,waterway/user?userId=${id}`,
`${OHSOME_STATS_API_URL}/topic/poi,highway,building,waterway/user?userId=${id}`,
);
};

Expand All @@ -96,7 +88,7 @@ export const useUserOsmStatsQuery = (id: string) => {

export const useOsmStatsMetadataQuery = () => {
const fetchOsmStatsMetadata = () => {
return fetchExternalJSONAPI(`${OHSOME_STATS_BASE_URL}/metadata`);
return fetchExternalJSONAPI(`${OHSOME_STATS_API_URL}/metadata`);
};

return useQuery({
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/partners/partnersActivity.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactPlaceholder from 'react-placeholder';

import PartnersProgresBar from './partnersProgresBar';
import messages from './messages';
import { OHSOME_STATS_BASE_URL } from '../../config';
import { OHSOME_STATS_API_URL } from '../../config';

export const Activity = ({ partner }) => {
const [data, setData] = useState(null);
Expand All @@ -22,7 +22,7 @@ export const Activity = ({ partner }) => {
?.map((tag) => tag.trim().replace('#', '').toLowerCase())
?.join(',');
const response = await fetch(
OHSOME_STATS_BASE_URL + `/stats/hashtags/${primaryHashtag},${secondaryHashtags}`,
OHSOME_STATS_API_URL + `/stats/hashtags/${primaryHashtag},${secondaryHashtags}`,
);

if (response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/partners/partnersProgresBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ProgressBar = ({ className, firstBarValue, secondBarValue = 0, data }) =>
target={'_blank'}
rel="noreferrer"
className="white no-underline"
href={OHSOME_STATS_BASE_URL + '/dashboard#hashtags=' + data.primary}
href={OHSOME_STATS_BASE_URL + '/dashboard#hashtag=' + data.primary}
>
{'#' + data.primary}{' '}
</a>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/teamsAndOrgs/featureStats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl';

import messages from './messages';
import userDetailMessages from '../userDetail/messages';
import { OHSOME_STATS_BASE_URL, defaultChangesetComment } from '../../config';
import { OHSOME_STATS_API_URL, defaultChangesetComment } from '../../config';
import { RoadIcon, HomeIcon, WavesIcon, MarkerIcon } from '../svgIcons';
import { StatsCard } from '../statsCard';
import StatsInfoFooter from '../statsInfoFooter';
Expand All @@ -14,7 +14,7 @@ export const FeatureStats = () => {
const getStats = async () => {
try {
const response = await axios.get(
`${OHSOME_STATS_BASE_URL}/stats/${defaultChangesetComment}-%2A`,
`${OHSOME_STATS_API_URL}/stats/${defaultChangesetComment}-%2A`,
);
const { edits, buildings, roads } = response.data.result;
setStats({
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ export const API_URL = import.meta.env.REACT_APP_API_URL
? new URL('/api/' + API_VERSION + '/', import.meta.env.REACT_APP_API_URL)
: 'http://127.0.0.1:5000/api/' + API_VERSION + '/';
export const OHSOME_STATS_BASE_URL =
import.meta.env.REACT_APP_OHSOME_STATS_BASE_URL || 'https://stats.now.ohsome.org/api';
import.meta.env.REACT_APP_OHSOME_STATS_BASE_URL || 'https://stats.now.ohsome.org';
export const OHSOME_STATS_API_URL =
import.meta.env.REACT_APP_OHSOME_STATS_API_URL || 'https://stats.now.ohsome.org/api';
// APPLICATION SETTINGS
export const DEFAULT_LOCALE = import.meta.env.REACT_APP_DEFAULT_LOCALE || 'en';
export const ENVIRONMENT = import.meta.env.REACT_APP_ENVIRONMENT || '';
export const PROJECTCARD_CONTRIBUTION_SHOWN_THRESHOLD =
import.meta.env.REACT_APP_PROJECTCARD_CONTRIBUTION_SHOWN_THRESHOLD || 5;
export const INTERMEDIATE_LEVEL_COUNT =
Number(import.meta.env.REACT_APP_TM_MAPPER_LEVEL_INTERMEDIATE) || 250;
export const ADVANCED_LEVEL_COUNT = Number(import.meta.env.REACT_APP_TM_MAPPER_LEVEL_ADVANCED) || 500;
export const ADVANCED_LEVEL_COUNT =
Number(import.meta.env.REACT_APP_TM_MAPPER_LEVEL_ADVANCED) || 500;
export const MAPBOX_TOKEN = import.meta.env.REACT_APP_MAPBOX_TOKEN || '';
export const ENABLE_SERVICEWORKER = import.meta.env.REACT_APP_ENABLE_SERVICEWORKER || 0;
export const MAX_AOI_AREA = Number(import.meta.env.REACT_APP_MAX_AOI_AREA) || 5000;
Expand Down Expand Up @@ -57,7 +60,8 @@ export const ID_EDITOR_URL =
export const POTLATCH2_EDITOR_URL =
import.meta.env.REACT_APP_POTLATCH2_EDITOR_URL ||
'https://www.openstreetmap.org/edit?editor=potlatch2';
export const RAPID_EDITOR_URL = import.meta.env.REACT_APP_RAPID_EDITOR_URL || 'https://mapwith.ai/rapid';
export const RAPID_EDITOR_URL =
import.meta.env.REACT_APP_RAPID_EDITOR_URL || 'https://mapwith.ai/rapid';
export const EXPORT_TOOL_S3_URL = import.meta.env.REACT_APP_EXPORT_TOOL_S3_URL || '';
export const ENABLE_EXPORT_TOOL = import.meta.env.REACT_APP_ENABLE_EXPORT_TOOL || '';

Expand Down Expand Up @@ -173,7 +177,8 @@ export const MAP_STYLE = MAPBOX_TOKEN
export const MAPBOX_RTL_PLUGIN_URL =
'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js';

export const UNDERPASS_URL = import.meta.env.REACT_APP_UNDERPASS_URL || 'https://underpass.hotosm.org';
export const UNDERPASS_URL =
import.meta.env.REACT_APP_UNDERPASS_URL || 'https://underpass.hotosm.org';

export const DROPZONE_SETTINGS = {
accept: {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/config/tests/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ it('exports API_URL', () => {
it('exports API_VERSION', () => {
expect(['object', 'string']).toContain(typeof config.API_VERSION);
});
it('exports OHSOME_STATS_BASE_URL', () => {
expect(typeof config.OHSOME_STATS_BASE_URL).toBe('string');
it('exports OHSOME_STATS_API_URL', () => {
expect(typeof config.OHSOME_STATS_API_URL).toBe('string');
});
it('exports ORG_URL', () => {
expect(typeof config.ORG_URL).toBe('string');
Expand Down
Loading

0 comments on commit f082d5d

Please sign in to comment.