Skip to content

Commit

Permalink
factorisation des label de qualityNames
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul LOPEZ committed Nov 10, 2024
1 parent 0fe122c commit d0a9ae2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
13 changes: 7 additions & 6 deletions components/content/QualityText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import type { LaneQuality } from '~/types';
const { displayQuality } = useConfig();
const { qualityNames } = useStats();
const { type } = defineProps<{
type: LaneQuality
Expand All @@ -22,37 +23,37 @@ type QualityText = {
}
const qualities: QualityText = {
dangerous: {
title: 'Dangereux',
title: qualityNames.dangerous,
color: {
text: 'text-[#FF0000]'
}
},
bad: {
title: 'Non satisfaisant',
title: qualityNames.bad,
color: {
text: 'text-[#770000]'
}
},
fair: {
title: 'À améliorer',
title: qualityNames.fair,
color: {
text: 'text-[#ff9c9c]'
}
},
good: {
title: 'Satisfaisant',
title: qualityNames.good,
color: {
text: 'text-[#007700]'
}
},
perfect: {
title: 'Parfait',
title: qualityNames.perfect,
color: {
text: 'text-[#00FF00]'
}
},
unknown: {
title: 'Inconnue',
title: qualityNames.unknown,
color: {
text: 'text-[#000000]'
}
Expand Down
10 changes: 1 addition & 9 deletions components/tooltips/LineTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import type { LaneQuality, LineStringFeature } from '~/types';
const { getLineColor } = useColors();
const { getRevName, displayQuality } = useConfig();
const { getDistance, typologyNames } = useStats();
const { getDistance, typologyNames, qualityNames } = useStats();
const { getVoieCyclablePath } = useUrl();
const { feature, lines } = defineProps<{
Expand Down Expand Up @@ -145,12 +145,4 @@ function getStatus(properties: LineStringFeature['properties']): { label: string
return statusMapping[properties.status];
}
const qualityNames: Record<LaneQuality, string> = {
dangerous: 'Dangereuse',
bad: 'Non satisfaisante',
fair: 'Globalement ',
good: 'Satisfaisante',
perfect: 'Parfaite',
unknown: 'Inconnue'
};
</script>
14 changes: 12 additions & 2 deletions composables/useStats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { groupBy } from '../helpers/helpers';
import { isLineStringFeature, type Feature, type Geojson, type LaneType, type LineStringFeature } from '../types';
import { isLineStringFeature, type Feature, type Geojson, type LaneType, type LineStringFeature, type LaneQuality } from '../types';

export const useStats = () => {
function getAllUniqLineStrings(voies: Geojson[]) {
Expand Down Expand Up @@ -150,6 +150,15 @@ export const useStats = () => {
inconnu: 'Inconnu'
};

const qualityNames: Record<LaneQuality, string> = {
dangerous: 'Dangereuse',
bad: 'Non satisfaisante',
fair: 'Globalement ',
good: 'Satisfaisante',
perfect: 'Parfaite',
unknown: 'Inconnue'
};

function getStatsByTypology(voies: Geojson[]) {
const lineStringFeatures = getAllUniqLineStrings(voies);
const totalDistance = getDistance({ features: lineStringFeatures });
Expand Down Expand Up @@ -180,6 +189,7 @@ export const useStats = () => {
getStatsByTypology,
displayDistanceInKm,
displayPercent,
typologyNames
typologyNames,
qualityNames
};
};

0 comments on commit d0a9ae2

Please sign in to comment.