Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

QMAPS-3065 - Add ecoresponsible source on poi #1428

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/components/Contribution.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import React from 'react';
import Telemetry from 'src/libs/telemetry';
import { Flex } from '@qwant/qwant-ponents';
import { isFromOSM, isFromPagesJaunes, isFromTripAdvisor } from 'src/libs/pois';
import {
isFromCircuitsCourts,
isFromEcotables,
isFromOSM,
isFromPagesJaunes,
isFromTripAdvisor,
isFromVrac,
} from 'src/libs/pois';
import classnames from 'classnames';
import { useI18n } from 'src/hooks';

const eventName = (poi, suffix) => {
if (isFromEcotables(poi)) return `ecotables_${suffix}`;
if (isFromCircuitsCourts(poi)) return `circuitscourts_${suffix}`;
if (isFromVrac(poi)) return `vrac_${suffix}`;
if (isFromOSM(poi)) return `osm_${suffix}`;
if (isFromTripAdvisor(poi)) return `ta_${suffix}`;
if (isFromPagesJaunes(poi)) return `pj_${suffix}`;
};

const sentenceFor = (poi, _) => {
if (isFromVrac(poi)) return `${_('In partnership with')} Réseau vrac`;
if (isFromCircuitsCourts(poi)) return `${_('In partnership with')} ObSat`;
if (isFromOSM(poi)) return _('Qwant Maps uses OpenStreetMap data.');
if (isFromTripAdvisor(poi)) return `${_('In partnership with')} TripAdvisor.`;
if (isFromPagesJaunes(poi)) return `${_('In partnership with')} PagesJaunes.`;
Expand All @@ -33,7 +45,8 @@ const Contribution = ({ poi }) => {
'contribute',
isFromOSM(poi) && 'contribute--osm',
isFromPagesJaunes(poi) && 'contribute--pj',
isFromTripAdvisor(poi) && 'contribute--ta'
isFromTripAdvisor(poi) && 'contribute--ta',
(isFromEcotables(poi) || isFromCircuitsCourts(poi) || isFromVrac(poi)) && 'contribute--eco'
)}
>
<div className="contribute__logo" />
Expand Down
8 changes: 8 additions & 0 deletions src/libs/pois.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export const isPoiCompliantKey = key => key.indexOf(prefix) === 0;

export const isFromPagesJaunes = poi => poi.meta && poi.meta.source === sources.pagesjaunes;
export const isFromOSM = poi => poi.meta && poi.meta.source === sources.osm;
export const isFromEcotables = poi =>
poi.blocks &&
!!poi.blocks?.find(b => b.type === 'ecoresponsible' && b.source === sources.ecotables);
export const isFromVrac = poi =>
poi.blocks && !!poi.blocks?.find(b => b.type === 'ecoresponsible' && b.source === sources.vrac);
export const isFromCircuitsCourts = poi =>
poi.blocks &&
!!poi.blocks?.find(b => b.type === 'ecoresponsible' && b.source === sources.circuitscourts);
export const isFromTripAdvisor = poi => poi.meta && poi.meta.source === sources.tripadvisor;

// POI map util functions
Expand Down
5 changes: 5 additions & 0 deletions src/scss/includes/contribute.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@
.contribute--ta & {
background-image: url('../../images/tripadvisor.svg');
}

.contribute--eco & {
background: var(--grey-100);
border-radius: 12px;
}
}