@wasto/cms-components 1.5.10 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -47
- package/dist/index.d.mts +181 -51
- package/dist/index.d.ts +181 -51
- package/dist/index.js +3614 -3015
- package/dist/index.mjs +3021 -2418
- package/package.json +12 -2
- package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
- package/src/components/article/Article.tsx +21 -21
- package/src/components/article/ArticleCard.tsx +81 -81
- package/src/components/article/ArticleExcerpts.tsx +80 -80
- package/src/components/article/ArticleList.tsx +114 -114
- package/src/components/article/ArticleMarkdown.tsx +170 -170
- package/src/components/article/ArticleReaderModal.tsx +93 -93
- package/src/components/article/ArticleSingle.tsx +57 -57
- package/src/components/bottom-tab/BottomTab.tsx +392 -392
- package/src/components/button/Button.tsx +154 -154
- package/src/components/challenge/Badges.tsx +84 -84
- package/src/components/challenge/BadgesModal.tsx +166 -166
- package/src/components/challenge/Challenge.tsx +380 -380
- package/src/components/challenge/ChallengeModal.tsx +231 -231
- package/src/components/challenge/ChallengeVignette.tsx +249 -249
- package/src/components/challenge/ChallengesModal.tsx +243 -243
- package/src/components/challenge/QuizModal.tsx +381 -381
- package/src/components/challenge/ResultModal.tsx +144 -144
- package/src/components/chat/Chat.tsx +928 -928
- package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
- package/src/components/columns/Columns.tsx +33 -33
- package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
- package/src/components/content-inset/ContentInset.tsx +33 -33
- package/src/components/header/Header.tsx +415 -391
- package/src/components/image/Image.tsx +15 -15
- package/src/components/image/ImageFrame.tsx +102 -102
- package/src/components/image/ImageMedia.tsx +31 -31
- package/src/components/image/ImageUrl.tsx +30 -30
- package/src/components/locations-map/LocationSheet.tsx +417 -417
- package/src/components/locations-map/LocationsMap.native.tsx +260 -260
- package/src/components/locations-map/LocationsMap.tsx +13 -13
- package/src/components/locations-map/LocationsMap.web.tsx +10 -10
- package/src/components/locations-map/LocationsMapShell.tsx +546 -527
- package/src/components/locations-map/LocationsMapView.tsx +108 -108
- package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
- package/src/components/nav-button/NavButton.tsx +59 -59
- package/src/components/next-collection/NextCollection.tsx +636 -621
- package/src/components/notifications/NotificationsScreen.tsx +247 -247
- package/src/components/page/Page.tsx +102 -64
- package/src/components/parapraph/Paragraph.tsx +67 -67
- package/src/components/profile/ProfileScreen.tsx +236 -236
- package/src/components/push/PushTokenRegistrar.tsx +47 -0
- package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
- package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
- package/src/components/search/Search.tsx +320 -320
- package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
- package/src/components/title/Title.tsx +100 -100
- package/src/components/vision/Vision.tsx +447 -447
- package/src/components/vision/VisionActionCard.tsx +117 -117
- package/src/components/vision/VisionCapture.tsx +30 -30
- package/src/components/vision/VisionTapOverlay.tsx +122 -122
- package/src/contexts/AnnouncementsContext.tsx +171 -171
- package/src/contexts/AppDataContext.tsx +458 -0
- package/src/contexts/ChallengesContext.tsx +182 -182
- package/src/contexts/HeaderConfigContext.tsx +29 -0
- package/src/contexts/LocalContext.tsx +227 -227
- package/src/contexts/ThemeContext.tsx +37 -37
- package/src/contexts/WastoContext.tsx +132 -127
- package/src/helpers/blogPost.ts +72 -72
- package/src/helpers/generateQuizQuestions.ts +247 -247
- package/src/helpers/getContrastColor.ts +18 -18
- package/src/helpers/haptics.ts +20 -20
- package/src/helpers/hoursSchedule.ts +230 -230
- package/src/helpers/htmlContentToMarkdown.ts +114 -114
- package/src/helpers/layout.ts +54 -54
- package/src/helpers/loadLinearGradient.ts +22 -22
- package/src/helpers/mapLocations.ts +170 -0
- package/src/helpers/maquetteTheme.ts +76 -76
- package/src/helpers/markdownUnderlinePlugin.ts +32 -32
- package/src/helpers/nextCollection.ts +122 -0
- package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
- package/src/helpers/publicMediaUrl.ts +8 -8
- package/src/helpers/resolveApiAssetUrl.ts +21 -21
- package/src/helpers/systemRoutes.ts +7 -7
- package/src/helpers/themeStyles.ts +114 -114
- package/src/helpers/ttlCache.ts +41 -0
- package/src/helpers/useSafeAreaPadding.ts +14 -14
- package/src/hooks/useBadges.ts +100 -100
- package/src/hooks/useBlogPosts.ts +109 -105
- package/src/hooks/useChallenges.ts +110 -110
- package/src/hooks/useCities.ts +56 -56
- package/src/hooks/useCityAnnouncements.ts +118 -118
- package/src/hooks/useCollectionCalendar.ts +421 -421
- package/src/hooks/useColumns.ts +19 -19
- package/src/hooks/useConsignes.ts +62 -62
- package/src/hooks/useLocations.ts +120 -248
- package/src/hooks/useNextCollection.ts +163 -238
- package/src/hooks/useRecyclingInfo.ts +90 -90
- package/src/hooks/useWastoClient.ts +16 -16
- package/src/index.ts +161 -142
- package/src/navigation/NavigationContext.tsx +56 -56
- package/src/push/registerExpoPushToken.ts +133 -0
- package/src/sentry/initSentry.ts +120 -120
- package/src/types/Theme.ts +72 -72
- package/src/types/css-modules.d.ts +1 -1
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import type { Theme } from "../types/Theme";
|
|
2
|
-
import { MAQUETTE_COLORS, MAQUETTE_RADII } from "./layout";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Default theme aligned with `.idea/maquette` tokens.
|
|
6
|
-
* Runtime apps override via CMS `config.theme` (console).
|
|
7
|
-
*/
|
|
8
|
-
export function createMaquetteTheme(overrides?: Partial<Theme>): Theme {
|
|
9
|
-
const base: Theme = {
|
|
10
|
-
colors: {
|
|
11
|
-
primary: MAQUETTE_COLORS.primary,
|
|
12
|
-
onPrimary: MAQUETTE_COLORS.onPrimary,
|
|
13
|
-
surface: MAQUETTE_COLORS.surface,
|
|
14
|
-
onSurface: MAQUETTE_COLORS.onSurface,
|
|
15
|
-
background: MAQUETTE_COLORS.background,
|
|
16
|
-
onBackground: MAQUETTE_COLORS.onBackground,
|
|
17
|
-
success: MAQUETTE_COLORS.success,
|
|
18
|
-
onSuccess: MAQUETTE_COLORS.onSuccess,
|
|
19
|
-
error: MAQUETTE_COLORS.error,
|
|
20
|
-
onError: MAQUETTE_COLORS.onError,
|
|
21
|
-
border: MAQUETTE_COLORS.border,
|
|
22
|
-
primarySoft: MAQUETTE_COLORS.primarySoft,
|
|
23
|
-
surfaceElevated: MAQUETTE_COLORS.surfaceElevated,
|
|
24
|
-
muted: MAQUETTE_COLORS.muted,
|
|
25
|
-
gradient: {
|
|
26
|
-
from: MAQUETTE_COLORS.primary,
|
|
27
|
-
to: MAQUETTE_COLORS.primarySoft,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
radius: MAQUETTE_RADII.radius,
|
|
31
|
-
radii: {
|
|
32
|
-
sm: MAQUETTE_RADII.sm,
|
|
33
|
-
md: MAQUETTE_RADII.md,
|
|
34
|
-
lg: MAQUETTE_RADII.lg,
|
|
35
|
-
pill: MAQUETTE_RADII.pill,
|
|
36
|
-
},
|
|
37
|
-
shadow: {
|
|
38
|
-
card: {
|
|
39
|
-
shadowColor: "#0F172A",
|
|
40
|
-
shadowOffset: { width: 0, height: 1 },
|
|
41
|
-
shadowOpacity: 0.06,
|
|
42
|
-
shadowRadius: 3,
|
|
43
|
-
elevation: 1,
|
|
44
|
-
},
|
|
45
|
-
soft: {
|
|
46
|
-
shadowColor: "#0F172A",
|
|
47
|
-
shadowOffset: { width: 0, height: 1 },
|
|
48
|
-
shadowOpacity: 0.04,
|
|
49
|
-
shadowRadius: 2,
|
|
50
|
-
elevation: 1,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
if (!overrides) return base;
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
...base,
|
|
59
|
-
...overrides,
|
|
60
|
-
colors: {
|
|
61
|
-
...base.colors,
|
|
62
|
-
...overrides.colors,
|
|
63
|
-
gradient: {
|
|
64
|
-
...base.colors.gradient,
|
|
65
|
-
...overrides.colors?.gradient,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
radii: overrides.radii ? { ...base.radii!, ...overrides.radii } : base.radii,
|
|
69
|
-
shadow: overrides.shadow
|
|
70
|
-
? {
|
|
71
|
-
card: { ...base.shadow!.card, ...overrides.shadow.card },
|
|
72
|
-
soft: { ...base.shadow!.soft, ...overrides.shadow.soft },
|
|
73
|
-
}
|
|
74
|
-
: base.shadow,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
1
|
+
import type { Theme } from "../types/Theme";
|
|
2
|
+
import { MAQUETTE_COLORS, MAQUETTE_RADII } from "./layout";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Default theme aligned with `.idea/maquette` tokens.
|
|
6
|
+
* Runtime apps override via CMS `config.theme` (console).
|
|
7
|
+
*/
|
|
8
|
+
export function createMaquetteTheme(overrides?: Partial<Theme>): Theme {
|
|
9
|
+
const base: Theme = {
|
|
10
|
+
colors: {
|
|
11
|
+
primary: MAQUETTE_COLORS.primary,
|
|
12
|
+
onPrimary: MAQUETTE_COLORS.onPrimary,
|
|
13
|
+
surface: MAQUETTE_COLORS.surface,
|
|
14
|
+
onSurface: MAQUETTE_COLORS.onSurface,
|
|
15
|
+
background: MAQUETTE_COLORS.background,
|
|
16
|
+
onBackground: MAQUETTE_COLORS.onBackground,
|
|
17
|
+
success: MAQUETTE_COLORS.success,
|
|
18
|
+
onSuccess: MAQUETTE_COLORS.onSuccess,
|
|
19
|
+
error: MAQUETTE_COLORS.error,
|
|
20
|
+
onError: MAQUETTE_COLORS.onError,
|
|
21
|
+
border: MAQUETTE_COLORS.border,
|
|
22
|
+
primarySoft: MAQUETTE_COLORS.primarySoft,
|
|
23
|
+
surfaceElevated: MAQUETTE_COLORS.surfaceElevated,
|
|
24
|
+
muted: MAQUETTE_COLORS.muted,
|
|
25
|
+
gradient: {
|
|
26
|
+
from: MAQUETTE_COLORS.primary,
|
|
27
|
+
to: MAQUETTE_COLORS.primarySoft,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
radius: MAQUETTE_RADII.radius,
|
|
31
|
+
radii: {
|
|
32
|
+
sm: MAQUETTE_RADII.sm,
|
|
33
|
+
md: MAQUETTE_RADII.md,
|
|
34
|
+
lg: MAQUETTE_RADII.lg,
|
|
35
|
+
pill: MAQUETTE_RADII.pill,
|
|
36
|
+
},
|
|
37
|
+
shadow: {
|
|
38
|
+
card: {
|
|
39
|
+
shadowColor: "#0F172A",
|
|
40
|
+
shadowOffset: { width: 0, height: 1 },
|
|
41
|
+
shadowOpacity: 0.06,
|
|
42
|
+
shadowRadius: 3,
|
|
43
|
+
elevation: 1,
|
|
44
|
+
},
|
|
45
|
+
soft: {
|
|
46
|
+
shadowColor: "#0F172A",
|
|
47
|
+
shadowOffset: { width: 0, height: 1 },
|
|
48
|
+
shadowOpacity: 0.04,
|
|
49
|
+
shadowRadius: 2,
|
|
50
|
+
elevation: 1,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (!overrides) return base;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
...base,
|
|
59
|
+
...overrides,
|
|
60
|
+
colors: {
|
|
61
|
+
...base.colors,
|
|
62
|
+
...overrides.colors,
|
|
63
|
+
gradient: {
|
|
64
|
+
...base.colors.gradient,
|
|
65
|
+
...overrides.colors?.gradient,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
radii: overrides.radii ? { ...base.radii!, ...overrides.radii } : base.radii,
|
|
69
|
+
shadow: overrides.shadow
|
|
70
|
+
? {
|
|
71
|
+
card: { ...base.shadow!.card, ...overrides.shadow.card },
|
|
72
|
+
soft: { ...base.shadow!.soft, ...overrides.shadow.soft },
|
|
73
|
+
}
|
|
74
|
+
: base.shadow,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses `++text++` as underline (`ins`), matching Console Turndown output.
|
|
3
|
-
*/
|
|
4
|
-
export function markdownUnderlinePlugin(md: {
|
|
5
|
-
inline: {
|
|
6
|
-
ruler: {
|
|
7
|
-
after: (name: string, ruleName: string, fn: (state: any, silent: boolean) => boolean) => void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
}): void {
|
|
11
|
-
md.inline.ruler.after("emphasis", "underline", (state: any, silent: boolean) => {
|
|
12
|
-
if (
|
|
13
|
-
state.src.charCodeAt(state.pos) !== 0x2b ||
|
|
14
|
-
state.src.charCodeAt(state.pos + 1) !== 0x2b
|
|
15
|
-
) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const close = state.src.indexOf("++", state.pos + 2);
|
|
19
|
-
if (close < state.pos + 2) return false;
|
|
20
|
-
if (silent) return true;
|
|
21
|
-
|
|
22
|
-
const content = state.src.slice(state.pos + 2, close);
|
|
23
|
-
const open = state.push("ins_open", "ins", 1);
|
|
24
|
-
open.markup = "++";
|
|
25
|
-
const text = state.push("text", "", 0);
|
|
26
|
-
text.content = content;
|
|
27
|
-
const end = state.push("ins_close", "ins", -1);
|
|
28
|
-
end.markup = "++";
|
|
29
|
-
state.pos = close + 2;
|
|
30
|
-
return true;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Parses `++text++` as underline (`ins`), matching Console Turndown output.
|
|
3
|
+
*/
|
|
4
|
+
export function markdownUnderlinePlugin(md: {
|
|
5
|
+
inline: {
|
|
6
|
+
ruler: {
|
|
7
|
+
after: (name: string, ruleName: string, fn: (state: any, silent: boolean) => boolean) => void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}): void {
|
|
11
|
+
md.inline.ruler.after("emphasis", "underline", (state: any, silent: boolean) => {
|
|
12
|
+
if (
|
|
13
|
+
state.src.charCodeAt(state.pos) !== 0x2b ||
|
|
14
|
+
state.src.charCodeAt(state.pos + 1) !== 0x2b
|
|
15
|
+
) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const close = state.src.indexOf("++", state.pos + 2);
|
|
19
|
+
if (close < state.pos + 2) return false;
|
|
20
|
+
if (silent) return true;
|
|
21
|
+
|
|
22
|
+
const content = state.src.slice(state.pos + 2, close);
|
|
23
|
+
const open = state.push("ins_open", "ins", 1);
|
|
24
|
+
open.markup = "++";
|
|
25
|
+
const text = state.push("text", "", 0);
|
|
26
|
+
text.content = content;
|
|
27
|
+
const end = state.push("ins_close", "ins", -1);
|
|
28
|
+
end.markup = "++";
|
|
29
|
+
state.pos = close + 2;
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { getContrastColor } from "./getContrastColor";
|
|
2
|
+
|
|
3
|
+
export type City = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
status?: "NON_ACTIF" | "INCOMPLET" | "ACTIF" | "MAINTENANCE";
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type WasteType = {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
icon?: string;
|
|
14
|
+
imageUrl?: string | null;
|
|
15
|
+
color?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type WasteCollectionPlace = {
|
|
20
|
+
id: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
collectionDays?: Array<{
|
|
23
|
+
/** Ex: "Lundi", "Mardi", ... (mapping lundi=0 … dimanche=6) */
|
|
24
|
+
name: string;
|
|
25
|
+
wasteTypeId: string;
|
|
26
|
+
biweekly?: boolean;
|
|
27
|
+
startDate?: string;
|
|
28
|
+
}>;
|
|
29
|
+
/** Périodes d’exception (pas de collecte) */
|
|
30
|
+
exceptions?: Array<{ dateFrom: string; dateTo: string }>;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type CollectionForDay = {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
icon?: string;
|
|
38
|
+
imageUrl?: string | null;
|
|
39
|
+
color?: string;
|
|
40
|
+
contrastColor?: "#000000" | "#FFFFFF";
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const DAY_MAPPING: Record<string, number> = {
|
|
44
|
+
Dimanche: 6,
|
|
45
|
+
Lundi: 0,
|
|
46
|
+
Mardi: 1,
|
|
47
|
+
Mercredi: 2,
|
|
48
|
+
Jeudi: 3,
|
|
49
|
+
Vendredi: 4,
|
|
50
|
+
Samedi: 5,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function getDateLabel(offset: number): string {
|
|
54
|
+
if (offset === -1) return "hier";
|
|
55
|
+
if (offset === 0) return "Aujourd'hui";
|
|
56
|
+
if (offset === 1) return "Demain";
|
|
57
|
+
return offset < 0 ? `Il y a ${Math.abs(offset)} jours` : `Dans ${offset} jours`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getCollectionsForDay(
|
|
61
|
+
wasteTypes: WasteType[],
|
|
62
|
+
wasteCollectionPlaces: WasteCollectionPlace[],
|
|
63
|
+
dateOffset: number,
|
|
64
|
+
selectedPlaceId?: string | null,
|
|
65
|
+
): CollectionForDay[] {
|
|
66
|
+
if (!wasteCollectionPlaces?.length) return [];
|
|
67
|
+
|
|
68
|
+
const place = selectedPlaceId
|
|
69
|
+
? wasteCollectionPlaces.find((p) => p.id === selectedPlaceId) ?? wasteCollectionPlaces[0]
|
|
70
|
+
: wasteCollectionPlaces[0];
|
|
71
|
+
|
|
72
|
+
const schedule = place?.collectionDays ?? [];
|
|
73
|
+
const exceptions = place?.exceptions ?? [];
|
|
74
|
+
|
|
75
|
+
const targetDate = new Date();
|
|
76
|
+
targetDate.setDate(targetDate.getDate() + dateOffset);
|
|
77
|
+
const dayOfWeek = targetDate.getDay();
|
|
78
|
+
const mondayBasedDay = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
|
|
79
|
+
|
|
80
|
+
const results: CollectionForDay[] = [];
|
|
81
|
+
const seen = new Set<string>();
|
|
82
|
+
|
|
83
|
+
for (const day of schedule) {
|
|
84
|
+
if (DAY_MAPPING[day.name] !== mondayBasedDay) continue;
|
|
85
|
+
|
|
86
|
+
const hasException = exceptions.some((exc) => {
|
|
87
|
+
const from = new Date(exc.dateFrom + "T00:00:00");
|
|
88
|
+
const to = new Date(exc.dateTo + "T00:00:00");
|
|
89
|
+
return targetDate.getTime() >= from.getTime() && targetDate.getTime() < to.getTime();
|
|
90
|
+
});
|
|
91
|
+
if (hasException) continue;
|
|
92
|
+
|
|
93
|
+
if (day.biweekly && day.startDate) {
|
|
94
|
+
const start = new Date(day.startDate);
|
|
95
|
+
const diffDays = Math.floor(
|
|
96
|
+
(targetDate.getTime() - start.getTime()) / (1000 * 60 * 60 * 24),
|
|
97
|
+
);
|
|
98
|
+
const weeks = Math.floor(diffDays / 7);
|
|
99
|
+
if (weeks < 0 || weeks % 2 !== 0) continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const wt = wasteTypes.find((w) => w.id === day.wasteTypeId);
|
|
103
|
+
if (!wt) continue;
|
|
104
|
+
|
|
105
|
+
if (seen.has(wt.id)) continue;
|
|
106
|
+
seen.add(wt.id);
|
|
107
|
+
|
|
108
|
+
results.push({
|
|
109
|
+
id: wt.id,
|
|
110
|
+
name: wt.name ?? "",
|
|
111
|
+
icon: typeof wt.icon === "string" ? wt.icon : undefined,
|
|
112
|
+
imageUrl: typeof wt.imageUrl === "string" ? wt.imageUrl : undefined,
|
|
113
|
+
color: typeof wt.color === "string" ? wt.color : undefined,
|
|
114
|
+
contrastColor:
|
|
115
|
+
typeof wt.color === "string" && wt.color.trim()
|
|
116
|
+
? getContrastColor(wt.color.trim())
|
|
117
|
+
: undefined,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return results;
|
|
122
|
+
}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import type { WasteType } from "../hooks/useNextCollection";
|
|
2
|
-
|
|
3
|
-
export type RecyclingInfoDetail = {
|
|
4
|
-
id: string | number;
|
|
5
|
-
material?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
imageUrl?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type RecyclingInfoItem = {
|
|
11
|
-
id: string;
|
|
12
|
-
/** Alias explicite de `id` (utile côté UI/props). */
|
|
13
|
-
wasteTypeId: string;
|
|
14
|
-
name: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
icon?: string;
|
|
17
|
-
imageUrl?: string;
|
|
18
|
-
color?: string;
|
|
19
|
-
colorLight?: string;
|
|
20
|
-
rules?: string[];
|
|
21
|
-
details?: RecyclingInfoDetail[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function normalizeWasteTypeToRecyclingInfo(wt: WasteType): RecyclingInfoItem | null {
|
|
25
|
-
const id = typeof wt?.id === "string" ? wt.id : null;
|
|
26
|
-
if (!id) return null;
|
|
27
|
-
|
|
28
|
-
const extended = wt as WasteType & {
|
|
29
|
-
description?: unknown;
|
|
30
|
-
colorLight?: unknown;
|
|
31
|
-
details?: unknown;
|
|
32
|
-
rules?: unknown;
|
|
33
|
-
imageUrl?: unknown;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const detailsRaw = extended.details;
|
|
37
|
-
const details = Array.isArray(detailsRaw)
|
|
38
|
-
? detailsRaw
|
|
39
|
-
.map((raw: unknown, idx: number) => {
|
|
40
|
-
const d = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
|
|
41
|
-
const rid = d.id;
|
|
42
|
-
const detailId =
|
|
43
|
-
typeof rid === "string" || typeof rid === "number" ? rid : `${id}-${idx}`;
|
|
44
|
-
const imageUrl =
|
|
45
|
-
typeof d.imageUrl === "string" && d.imageUrl.trim()
|
|
46
|
-
? d.imageUrl.trim()
|
|
47
|
-
: undefined;
|
|
48
|
-
return {
|
|
49
|
-
id: detailId,
|
|
50
|
-
material: typeof d.material === "string" ? d.material : undefined,
|
|
51
|
-
description: typeof d.description === "string" ? d.description : undefined,
|
|
52
|
-
imageUrl,
|
|
53
|
-
};
|
|
54
|
-
})
|
|
55
|
-
.filter((d) => d.material || d.description || d.imageUrl)
|
|
56
|
-
: undefined;
|
|
57
|
-
|
|
58
|
-
const rulesRaw = extended.rules;
|
|
59
|
-
const rules = Array.isArray(rulesRaw)
|
|
60
|
-
? rulesRaw.filter((r): r is string => typeof r === "string" && r.trim().length > 0)
|
|
61
|
-
: undefined;
|
|
62
|
-
|
|
63
|
-
const imageUrl =
|
|
64
|
-
typeof extended.imageUrl === "string" && extended.imageUrl.trim()
|
|
65
|
-
? extended.imageUrl.trim()
|
|
66
|
-
: undefined;
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
id,
|
|
70
|
-
wasteTypeId: id,
|
|
71
|
-
name: typeof wt.name === "string" ? wt.name : "",
|
|
72
|
-
description: typeof extended.description === "string" ? extended.description : undefined,
|
|
73
|
-
icon: typeof wt.icon === "string" ? wt.icon : undefined,
|
|
74
|
-
imageUrl,
|
|
75
|
-
color: typeof wt.color === "string" ? wt.color : undefined,
|
|
76
|
-
colorLight: typeof extended.colorLight === "string" ? extended.colorLight : undefined,
|
|
77
|
-
rules,
|
|
78
|
-
details,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
1
|
+
import type { WasteType } from "../hooks/useNextCollection";
|
|
2
|
+
|
|
3
|
+
export type RecyclingInfoDetail = {
|
|
4
|
+
id: string | number;
|
|
5
|
+
material?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
imageUrl?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type RecyclingInfoItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
/** Alias explicite de `id` (utile côté UI/props). */
|
|
13
|
+
wasteTypeId: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
icon?: string;
|
|
17
|
+
imageUrl?: string;
|
|
18
|
+
color?: string;
|
|
19
|
+
colorLight?: string;
|
|
20
|
+
rules?: string[];
|
|
21
|
+
details?: RecyclingInfoDetail[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function normalizeWasteTypeToRecyclingInfo(wt: WasteType): RecyclingInfoItem | null {
|
|
25
|
+
const id = typeof wt?.id === "string" ? wt.id : null;
|
|
26
|
+
if (!id) return null;
|
|
27
|
+
|
|
28
|
+
const extended = wt as WasteType & {
|
|
29
|
+
description?: unknown;
|
|
30
|
+
colorLight?: unknown;
|
|
31
|
+
details?: unknown;
|
|
32
|
+
rules?: unknown;
|
|
33
|
+
imageUrl?: unknown;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const detailsRaw = extended.details;
|
|
37
|
+
const details = Array.isArray(detailsRaw)
|
|
38
|
+
? detailsRaw
|
|
39
|
+
.map((raw: unknown, idx: number) => {
|
|
40
|
+
const d = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
|
|
41
|
+
const rid = d.id;
|
|
42
|
+
const detailId =
|
|
43
|
+
typeof rid === "string" || typeof rid === "number" ? rid : `${id}-${idx}`;
|
|
44
|
+
const imageUrl =
|
|
45
|
+
typeof d.imageUrl === "string" && d.imageUrl.trim()
|
|
46
|
+
? d.imageUrl.trim()
|
|
47
|
+
: undefined;
|
|
48
|
+
return {
|
|
49
|
+
id: detailId,
|
|
50
|
+
material: typeof d.material === "string" ? d.material : undefined,
|
|
51
|
+
description: typeof d.description === "string" ? d.description : undefined,
|
|
52
|
+
imageUrl,
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
.filter((d) => d.material || d.description || d.imageUrl)
|
|
56
|
+
: undefined;
|
|
57
|
+
|
|
58
|
+
const rulesRaw = extended.rules;
|
|
59
|
+
const rules = Array.isArray(rulesRaw)
|
|
60
|
+
? rulesRaw.filter((r): r is string => typeof r === "string" && r.trim().length > 0)
|
|
61
|
+
: undefined;
|
|
62
|
+
|
|
63
|
+
const imageUrl =
|
|
64
|
+
typeof extended.imageUrl === "string" && extended.imageUrl.trim()
|
|
65
|
+
? extended.imageUrl.trim()
|
|
66
|
+
: undefined;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
id,
|
|
70
|
+
wasteTypeId: id,
|
|
71
|
+
name: typeof wt.name === "string" ? wt.name : "",
|
|
72
|
+
description: typeof extended.description === "string" ? extended.description : undefined,
|
|
73
|
+
icon: typeof wt.icon === "string" ? wt.icon : undefined,
|
|
74
|
+
imageUrl,
|
|
75
|
+
color: typeof wt.color === "string" ? wt.color : undefined,
|
|
76
|
+
colorLight: typeof extended.colorLight === "string" ? extended.colorLight : undefined,
|
|
77
|
+
rules,
|
|
78
|
+
details,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function publicMediaUrl(
|
|
2
|
-
apiUrl: string,
|
|
3
|
-
mediaId: string | null | undefined
|
|
4
|
-
): string | null {
|
|
5
|
-
const id = (mediaId ?? "").trim();
|
|
6
|
-
if (!id) return null;
|
|
7
|
-
return `${apiUrl.replace(/\/$/, "")}/public/cms/media/${encodeURIComponent(id)}/file`;
|
|
8
|
-
}
|
|
1
|
+
export function publicMediaUrl(
|
|
2
|
+
apiUrl: string,
|
|
3
|
+
mediaId: string | null | undefined
|
|
4
|
+
): string | null {
|
|
5
|
+
const id = (mediaId ?? "").trim();
|
|
6
|
+
if (!id) return null;
|
|
7
|
+
return `${apiUrl.replace(/\/$/, "")}/public/cms/media/${encodeURIComponent(id)}/file`;
|
|
8
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/** Résout une URL d’asset API (chemin `/public/...` ou URL absolue / data:). */
|
|
2
|
-
export function resolveApiAssetUrl(
|
|
3
|
-
apiUrl: string,
|
|
4
|
-
url: string | null | undefined,
|
|
5
|
-
): string | null {
|
|
6
|
-
const v = (url ?? "").trim();
|
|
7
|
-
if (!v) return null;
|
|
8
|
-
if (
|
|
9
|
-
v.startsWith("data:") ||
|
|
10
|
-
v.startsWith("http://") ||
|
|
11
|
-
v.startsWith("https://") ||
|
|
12
|
-
v.startsWith("file:") ||
|
|
13
|
-
v.startsWith("blob:")
|
|
14
|
-
) {
|
|
15
|
-
return v;
|
|
16
|
-
}
|
|
17
|
-
if (v.startsWith("/")) {
|
|
18
|
-
return `${apiUrl.replace(/\/$/, "")}${v}`;
|
|
19
|
-
}
|
|
20
|
-
return v;
|
|
21
|
-
}
|
|
1
|
+
/** Résout une URL d’asset API (chemin `/public/...` ou URL absolue / data:). */
|
|
2
|
+
export function resolveApiAssetUrl(
|
|
3
|
+
apiUrl: string,
|
|
4
|
+
url: string | null | undefined,
|
|
5
|
+
): string | null {
|
|
6
|
+
const v = (url ?? "").trim();
|
|
7
|
+
if (!v) return null;
|
|
8
|
+
if (
|
|
9
|
+
v.startsWith("data:") ||
|
|
10
|
+
v.startsWith("http://") ||
|
|
11
|
+
v.startsWith("https://") ||
|
|
12
|
+
v.startsWith("file:") ||
|
|
13
|
+
v.startsWith("blob:")
|
|
14
|
+
) {
|
|
15
|
+
return v;
|
|
16
|
+
}
|
|
17
|
+
if (v.startsWith("/")) {
|
|
18
|
+
return `${apiUrl.replace(/\/$/, "")}${v}`;
|
|
19
|
+
}
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** Fixed Expo Router paths for shell screens (apps générées + playground). */
|
|
2
|
-
export const SYSTEM_ROUTES = {
|
|
3
|
-
notifications: "/(system)/notifications",
|
|
4
|
-
profile: "/(system)/profile",
|
|
5
|
-
} as const;
|
|
6
|
-
|
|
7
|
-
export type SystemRouteKey = keyof typeof SYSTEM_ROUTES;
|
|
1
|
+
/** Fixed Expo Router paths for shell screens (apps générées + playground). */
|
|
2
|
+
export const SYSTEM_ROUTES = {
|
|
3
|
+
notifications: "/(system)/notifications",
|
|
4
|
+
profile: "/(system)/profile",
|
|
5
|
+
} as const;
|
|
6
|
+
|
|
7
|
+
export type SystemRouteKey = keyof typeof SYSTEM_ROUTES;
|