@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.
Files changed (101) hide show
  1. package/README.md +47 -47
  2. package/dist/index.d.mts +181 -51
  3. package/dist/index.d.ts +181 -51
  4. package/dist/index.js +3614 -3015
  5. package/dist/index.mjs +3021 -2418
  6. package/package.json +12 -2
  7. package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
  8. package/src/components/article/Article.tsx +21 -21
  9. package/src/components/article/ArticleCard.tsx +81 -81
  10. package/src/components/article/ArticleExcerpts.tsx +80 -80
  11. package/src/components/article/ArticleList.tsx +114 -114
  12. package/src/components/article/ArticleMarkdown.tsx +170 -170
  13. package/src/components/article/ArticleReaderModal.tsx +93 -93
  14. package/src/components/article/ArticleSingle.tsx +57 -57
  15. package/src/components/bottom-tab/BottomTab.tsx +392 -392
  16. package/src/components/button/Button.tsx +154 -154
  17. package/src/components/challenge/Badges.tsx +84 -84
  18. package/src/components/challenge/BadgesModal.tsx +166 -166
  19. package/src/components/challenge/Challenge.tsx +380 -380
  20. package/src/components/challenge/ChallengeModal.tsx +231 -231
  21. package/src/components/challenge/ChallengeVignette.tsx +249 -249
  22. package/src/components/challenge/ChallengesModal.tsx +243 -243
  23. package/src/components/challenge/QuizModal.tsx +381 -381
  24. package/src/components/challenge/ResultModal.tsx +144 -144
  25. package/src/components/chat/Chat.tsx +928 -928
  26. package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
  27. package/src/components/columns/Columns.tsx +33 -33
  28. package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
  29. package/src/components/content-inset/ContentInset.tsx +33 -33
  30. package/src/components/header/Header.tsx +415 -391
  31. package/src/components/image/Image.tsx +15 -15
  32. package/src/components/image/ImageFrame.tsx +102 -102
  33. package/src/components/image/ImageMedia.tsx +31 -31
  34. package/src/components/image/ImageUrl.tsx +30 -30
  35. package/src/components/locations-map/LocationSheet.tsx +417 -417
  36. package/src/components/locations-map/LocationsMap.native.tsx +260 -260
  37. package/src/components/locations-map/LocationsMap.tsx +13 -13
  38. package/src/components/locations-map/LocationsMap.web.tsx +10 -10
  39. package/src/components/locations-map/LocationsMapShell.tsx +546 -527
  40. package/src/components/locations-map/LocationsMapView.tsx +108 -108
  41. package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
  42. package/src/components/nav-button/NavButton.tsx +59 -59
  43. package/src/components/next-collection/NextCollection.tsx +636 -621
  44. package/src/components/notifications/NotificationsScreen.tsx +247 -247
  45. package/src/components/page/Page.tsx +102 -64
  46. package/src/components/parapraph/Paragraph.tsx +67 -67
  47. package/src/components/profile/ProfileScreen.tsx +236 -236
  48. package/src/components/push/PushTokenRegistrar.tsx +47 -0
  49. package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
  50. package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
  51. package/src/components/search/Search.tsx +320 -320
  52. package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
  53. package/src/components/title/Title.tsx +100 -100
  54. package/src/components/vision/Vision.tsx +447 -447
  55. package/src/components/vision/VisionActionCard.tsx +117 -117
  56. package/src/components/vision/VisionCapture.tsx +30 -30
  57. package/src/components/vision/VisionTapOverlay.tsx +122 -122
  58. package/src/contexts/AnnouncementsContext.tsx +171 -171
  59. package/src/contexts/AppDataContext.tsx +458 -0
  60. package/src/contexts/ChallengesContext.tsx +182 -182
  61. package/src/contexts/HeaderConfigContext.tsx +29 -0
  62. package/src/contexts/LocalContext.tsx +227 -227
  63. package/src/contexts/ThemeContext.tsx +37 -37
  64. package/src/contexts/WastoContext.tsx +132 -127
  65. package/src/helpers/blogPost.ts +72 -72
  66. package/src/helpers/generateQuizQuestions.ts +247 -247
  67. package/src/helpers/getContrastColor.ts +18 -18
  68. package/src/helpers/haptics.ts +20 -20
  69. package/src/helpers/hoursSchedule.ts +230 -230
  70. package/src/helpers/htmlContentToMarkdown.ts +114 -114
  71. package/src/helpers/layout.ts +54 -54
  72. package/src/helpers/loadLinearGradient.ts +22 -22
  73. package/src/helpers/mapLocations.ts +170 -0
  74. package/src/helpers/maquetteTheme.ts +76 -76
  75. package/src/helpers/markdownUnderlinePlugin.ts +32 -32
  76. package/src/helpers/nextCollection.ts +122 -0
  77. package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
  78. package/src/helpers/publicMediaUrl.ts +8 -8
  79. package/src/helpers/resolveApiAssetUrl.ts +21 -21
  80. package/src/helpers/systemRoutes.ts +7 -7
  81. package/src/helpers/themeStyles.ts +114 -114
  82. package/src/helpers/ttlCache.ts +41 -0
  83. package/src/helpers/useSafeAreaPadding.ts +14 -14
  84. package/src/hooks/useBadges.ts +100 -100
  85. package/src/hooks/useBlogPosts.ts +109 -105
  86. package/src/hooks/useChallenges.ts +110 -110
  87. package/src/hooks/useCities.ts +56 -56
  88. package/src/hooks/useCityAnnouncements.ts +118 -118
  89. package/src/hooks/useCollectionCalendar.ts +421 -421
  90. package/src/hooks/useColumns.ts +19 -19
  91. package/src/hooks/useConsignes.ts +62 -62
  92. package/src/hooks/useLocations.ts +120 -248
  93. package/src/hooks/useNextCollection.ts +163 -238
  94. package/src/hooks/useRecyclingInfo.ts +90 -90
  95. package/src/hooks/useWastoClient.ts +16 -16
  96. package/src/index.ts +161 -142
  97. package/src/navigation/NavigationContext.tsx +56 -56
  98. package/src/push/registerExpoPushToken.ts +133 -0
  99. package/src/sentry/initSentry.ts +120 -120
  100. package/src/types/Theme.ts +72 -72
  101. package/src/types/css-modules.d.ts +1 -1
@@ -1,67 +1,67 @@
1
- import type { ReactNode } from "react";
2
- import { StyleProp, StyleSheet, Text, TextStyle, View } from "react-native";
3
- import { Theme } from "../../types/Theme";
4
- import { useTheme } from "../../contexts/ThemeContext";
5
- import type { TextAlignHorizontal, TextAlignVertical } from "../title/Title";
6
-
7
- export type PararaphProps = {
8
- text: string;
9
- style?: StyleProp<TextStyle>;
10
- alignHorizontal?: TextAlignHorizontal;
11
- alignVertical?: TextAlignVertical;
12
- };
13
-
14
- function justifyForVertical(align: TextAlignVertical | undefined): "flex-start" | "center" | "flex-end" {
15
- if (align === "middle") return "center";
16
- if (align === "bottom") return "flex-end";
17
- return "flex-start";
18
- }
19
-
20
- function textAlignFor(align: TextAlignHorizontal | undefined): "left" | "center" | "right" {
21
- if (align === "center" || align === "right") return align;
22
- return "left";
23
- }
24
-
25
- export function Paragraph({
26
- text,
27
- style,
28
- alignHorizontal,
29
- alignVertical,
30
- }: PararaphProps): ReactNode {
31
- const { theme } = useTheme();
32
- const themedStyles = createThemedStyles(theme);
33
- const textAlign = textAlignFor(alignHorizontal);
34
-
35
- const content = (
36
- <Text style={[styles.text, themedStyles.text, { textAlign }, style]}>
37
- {text}
38
- </Text>
39
- );
40
-
41
- if (!alignVertical || alignVertical === "top") {
42
- return content;
43
- }
44
-
45
- return (
46
- <View style={[styles.alignWrap, { justifyContent: justifyForVertical(alignVertical) }]}>
47
- {content}
48
- </View>
49
- );
50
- }
51
-
52
- const createThemedStyles = (theme: Theme) => StyleSheet.create({
53
- text: {
54
- color: theme.colors.onSurface,
55
- }
56
- });
57
-
58
- const styles = StyleSheet.create({
59
- text: {
60
- fontSize: 15,
61
- lineHeight: 22,
62
- },
63
- alignWrap: {
64
- minHeight: 22,
65
- width: "100%",
66
- },
67
- });
1
+ import type { ReactNode } from "react";
2
+ import { StyleProp, StyleSheet, Text, TextStyle, View } from "react-native";
3
+ import { Theme } from "../../types/Theme";
4
+ import { useTheme } from "../../contexts/ThemeContext";
5
+ import type { TextAlignHorizontal, TextAlignVertical } from "../title/Title";
6
+
7
+ export type PararaphProps = {
8
+ text: string;
9
+ style?: StyleProp<TextStyle>;
10
+ alignHorizontal?: TextAlignHorizontal;
11
+ alignVertical?: TextAlignVertical;
12
+ };
13
+
14
+ function justifyForVertical(align: TextAlignVertical | undefined): "flex-start" | "center" | "flex-end" {
15
+ if (align === "middle") return "center";
16
+ if (align === "bottom") return "flex-end";
17
+ return "flex-start";
18
+ }
19
+
20
+ function textAlignFor(align: TextAlignHorizontal | undefined): "left" | "center" | "right" {
21
+ if (align === "center" || align === "right") return align;
22
+ return "left";
23
+ }
24
+
25
+ export function Paragraph({
26
+ text,
27
+ style,
28
+ alignHorizontal,
29
+ alignVertical,
30
+ }: PararaphProps): ReactNode {
31
+ const { theme } = useTheme();
32
+ const themedStyles = createThemedStyles(theme);
33
+ const textAlign = textAlignFor(alignHorizontal);
34
+
35
+ const content = (
36
+ <Text style={[styles.text, themedStyles.text, { textAlign }, style]}>
37
+ {text}
38
+ </Text>
39
+ );
40
+
41
+ if (!alignVertical || alignVertical === "top") {
42
+ return content;
43
+ }
44
+
45
+ return (
46
+ <View style={[styles.alignWrap, { justifyContent: justifyForVertical(alignVertical) }]}>
47
+ {content}
48
+ </View>
49
+ );
50
+ }
51
+
52
+ const createThemedStyles = (theme: Theme) => StyleSheet.create({
53
+ text: {
54
+ color: theme.colors.onSurface,
55
+ }
56
+ });
57
+
58
+ const styles = StyleSheet.create({
59
+ text: {
60
+ fontSize: 15,
61
+ lineHeight: 22,
62
+ },
63
+ alignWrap: {
64
+ minHeight: 22,
65
+ width: "100%",
66
+ },
67
+ });
@@ -1,236 +1,236 @@
1
- import type { ReactNode } from "react";
2
- import { Alert, StyleSheet, Text, View } from "react-native";
3
- import { MapPin, Trash2 } from "lucide-react-native";
4
- import { useTheme } from "../../contexts/ThemeContext";
5
- import { useLocal } from "../../contexts/LocalContext";
6
- import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
7
- import { SPACE } from "../../helpers/layout";
8
- import { hapticSelection } from "../../helpers/haptics";
9
- import { Button } from "../button/Button";
10
-
11
- function RecapRow({
12
- label,
13
- value,
14
- muted,
15
- onSurface,
16
- }: {
17
- label: string;
18
- value: string;
19
- muted: string;
20
- onSurface: string;
21
- }) {
22
- return (
23
- <View style={styles.recapRow}>
24
- <Text style={[styles.recapLabel, { color: muted }]}>{label}</Text>
25
- <Text style={[styles.recapValue, { color: onSurface }]} numberOfLines={2}>
26
- {value}
27
- </Text>
28
- </View>
29
- );
30
- }
31
-
32
- /** Profil local : récap secteur + actions changer / supprimer. */
33
- export function ProfileScreen(): ReactNode {
34
- const { theme } = useTheme();
35
- const t = resolveTheme(theme);
36
- const {
37
- hasPlaceSelected,
38
- placeMeta,
39
- clearPlaceSelection,
40
- clearLocalData,
41
- isLoading,
42
- } = useLocal();
43
-
44
- const cityName = placeMeta?.cityName?.trim() || "—";
45
- const streetName = placeMeta?.streetName?.trim() || "—";
46
- const sectorName = placeMeta?.sectorName?.trim() || "—";
47
-
48
- const onChangeSector = async () => {
49
- await hapticSelection();
50
- await clearPlaceSelection();
51
- };
52
-
53
- const onDeleteData = () => {
54
- Alert.alert(
55
- "Supprimer mes données",
56
- "Cela efface votre secteur, l’identifiant de cet appareil et les préférences locales. Les quiz déjà enregistrés côté serveur ne sont pas retirés ici.",
57
- [
58
- { text: "Annuler", style: "cancel" },
59
- {
60
- text: "Supprimer",
61
- style: "destructive",
62
- onPress: () => {
63
- void (async () => {
64
- await hapticSelection();
65
- await clearLocalData();
66
- })();
67
- },
68
- },
69
- ],
70
- );
71
- };
72
-
73
- return (
74
- <View style={styles.screen}>
75
- <View style={styles.section}>
76
- <Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
77
- MON SECTEUR
78
- </Text>
79
- <View
80
- style={[
81
- styles.recapCard,
82
- cardStyle(theme),
83
- { borderRadius: t.radii.lg },
84
- ]}
85
- >
86
- <View style={styles.recapHead}>
87
- <View
88
- style={[
89
- styles.recapIcon,
90
- {
91
- backgroundColor: theme.colors.primary,
92
- borderRadius: t.radii.pill,
93
- },
94
- ]}
95
- >
96
- <MapPin size={18} color={theme.colors.onPrimary} />
97
- </View>
98
- <Text
99
- style={[styles.recapTitle, { color: theme.colors.onSurface }]}
100
- >
101
- {hasPlaceSelected ? "Zone de collecte" : "Aucune zone"}
102
- </Text>
103
- </View>
104
-
105
- {hasPlaceSelected ? (
106
- <View style={styles.recapList}>
107
- <RecapRow
108
- label="Ville"
109
- value={cityName}
110
- muted={t.colors.muted}
111
- onSurface={theme.colors.onSurface}
112
- />
113
- <View
114
- style={[
115
- styles.divider,
116
- { backgroundColor: theme.colors.border },
117
- ]}
118
- />
119
- <RecapRow
120
- label="Adresse"
121
- value={streetName}
122
- muted={t.colors.muted}
123
- onSurface={theme.colors.onSurface}
124
- />
125
- <View
126
- style={[
127
- styles.divider,
128
- { backgroundColor: theme.colors.border },
129
- ]}
130
- />
131
- <RecapRow
132
- label="Secteur"
133
- value={sectorName}
134
- muted={t.colors.muted}
135
- onSurface={theme.colors.onSurface}
136
- />
137
- </View>
138
- ) : (
139
- <Text style={[styles.emptyHint, { color: t.colors.muted }]}>
140
- Choisissez votre rue pour personnaliser les collectes et
141
- notifications.
142
- </Text>
143
- )}
144
- </View>
145
- </View>
146
-
147
- <View style={styles.section}>
148
- <Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
149
- ACTIONS
150
- </Text>
151
- <View style={styles.actions}>
152
- <Button
153
- variant="secondary"
154
- leftIcon={MapPin}
155
- loading={isLoading}
156
- onPress={() => void onChangeSector()}
157
- >
158
- Changer de secteur
159
- </Button>
160
- <Button
161
- variant="ghost"
162
- leftIcon={Trash2}
163
- loading={isLoading}
164
- onPress={onDeleteData}
165
- textStyle={{ color: theme.colors.error }}
166
- >
167
- Supprimer mes données
168
- </Button>
169
- </View>
170
- </View>
171
- </View>
172
- );
173
- }
174
-
175
- const styles = StyleSheet.create({
176
- screen: {
177
- flex: 1,
178
- paddingHorizontal: SPACE.pageX,
179
- paddingVertical: SPACE.sectionY,
180
- gap: SPACE.sectionY,
181
- },
182
- section: {
183
- gap: 10,
184
- },
185
- sectionLabel: {
186
- fontSize: 12,
187
- fontWeight: "700",
188
- letterSpacing: 0.6,
189
- },
190
- recapCard: {
191
- padding: SPACE.cardPad,
192
- gap: 16,
193
- },
194
- recapHead: {
195
- flexDirection: "row",
196
- alignItems: "center",
197
- gap: 12,
198
- },
199
- recapIcon: {
200
- width: SPACE.iconHit,
201
- height: SPACE.iconHit,
202
- alignItems: "center",
203
- justifyContent: "center",
204
- },
205
- recapTitle: {
206
- flex: 1,
207
- fontSize: 17,
208
- fontWeight: "700",
209
- },
210
- recapList: {
211
- gap: 0,
212
- },
213
- recapRow: {
214
- gap: 4,
215
- paddingVertical: 10,
216
- },
217
- recapLabel: {
218
- fontSize: 12,
219
- fontWeight: "600",
220
- },
221
- recapValue: {
222
- fontSize: 16,
223
- fontWeight: "700",
224
- },
225
- divider: {
226
- height: StyleSheet.hairlineWidth,
227
- width: "100%",
228
- },
229
- emptyHint: {
230
- fontSize: 14,
231
- lineHeight: 20,
232
- },
233
- actions: {
234
- gap: SPACE.stack,
235
- },
236
- });
1
+ import type { ReactNode } from "react";
2
+ import { Alert, StyleSheet, Text, View } from "react-native";
3
+ import { MapPin, Trash2 } from "lucide-react-native";
4
+ import { useTheme } from "../../contexts/ThemeContext";
5
+ import { useLocal } from "../../contexts/LocalContext";
6
+ import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
7
+ import { SPACE } from "../../helpers/layout";
8
+ import { hapticSelection } from "../../helpers/haptics";
9
+ import { Button } from "../button/Button";
10
+
11
+ function RecapRow({
12
+ label,
13
+ value,
14
+ muted,
15
+ onSurface,
16
+ }: {
17
+ label: string;
18
+ value: string;
19
+ muted: string;
20
+ onSurface: string;
21
+ }) {
22
+ return (
23
+ <View style={styles.recapRow}>
24
+ <Text style={[styles.recapLabel, { color: muted }]}>{label}</Text>
25
+ <Text style={[styles.recapValue, { color: onSurface }]} numberOfLines={2}>
26
+ {value}
27
+ </Text>
28
+ </View>
29
+ );
30
+ }
31
+
32
+ /** Profil local : récap secteur + actions changer / supprimer. */
33
+ export function ProfileScreen(): ReactNode {
34
+ const { theme } = useTheme();
35
+ const t = resolveTheme(theme);
36
+ const {
37
+ hasPlaceSelected,
38
+ placeMeta,
39
+ clearPlaceSelection,
40
+ clearLocalData,
41
+ isLoading,
42
+ } = useLocal();
43
+
44
+ const cityName = placeMeta?.cityName?.trim() || "—";
45
+ const streetName = placeMeta?.streetName?.trim() || "—";
46
+ const sectorName = placeMeta?.sectorName?.trim() || "—";
47
+
48
+ const onChangeSector = async () => {
49
+ await hapticSelection();
50
+ await clearPlaceSelection();
51
+ };
52
+
53
+ const onDeleteData = () => {
54
+ Alert.alert(
55
+ "Supprimer mes données",
56
+ "Cela efface votre secteur, l’identifiant de cet appareil et les préférences locales. Les quiz déjà enregistrés côté serveur ne sont pas retirés ici.",
57
+ [
58
+ { text: "Annuler", style: "cancel" },
59
+ {
60
+ text: "Supprimer",
61
+ style: "destructive",
62
+ onPress: () => {
63
+ void (async () => {
64
+ await hapticSelection();
65
+ await clearLocalData();
66
+ })();
67
+ },
68
+ },
69
+ ],
70
+ );
71
+ };
72
+
73
+ return (
74
+ <View style={styles.screen}>
75
+ <View style={styles.section}>
76
+ <Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
77
+ MON SECTEUR
78
+ </Text>
79
+ <View
80
+ style={[
81
+ styles.recapCard,
82
+ cardStyle(theme),
83
+ { borderRadius: t.radii.lg },
84
+ ]}
85
+ >
86
+ <View style={styles.recapHead}>
87
+ <View
88
+ style={[
89
+ styles.recapIcon,
90
+ {
91
+ backgroundColor: theme.colors.primary,
92
+ borderRadius: t.radii.pill,
93
+ },
94
+ ]}
95
+ >
96
+ <MapPin size={18} color={theme.colors.onPrimary} />
97
+ </View>
98
+ <Text
99
+ style={[styles.recapTitle, { color: theme.colors.onSurface }]}
100
+ >
101
+ {hasPlaceSelected ? "Zone de collecte" : "Aucune zone"}
102
+ </Text>
103
+ </View>
104
+
105
+ {hasPlaceSelected ? (
106
+ <View style={styles.recapList}>
107
+ <RecapRow
108
+ label="Ville"
109
+ value={cityName}
110
+ muted={t.colors.muted}
111
+ onSurface={theme.colors.onSurface}
112
+ />
113
+ <View
114
+ style={[
115
+ styles.divider,
116
+ { backgroundColor: theme.colors.border },
117
+ ]}
118
+ />
119
+ <RecapRow
120
+ label="Adresse"
121
+ value={streetName}
122
+ muted={t.colors.muted}
123
+ onSurface={theme.colors.onSurface}
124
+ />
125
+ <View
126
+ style={[
127
+ styles.divider,
128
+ { backgroundColor: theme.colors.border },
129
+ ]}
130
+ />
131
+ <RecapRow
132
+ label="Secteur"
133
+ value={sectorName}
134
+ muted={t.colors.muted}
135
+ onSurface={theme.colors.onSurface}
136
+ />
137
+ </View>
138
+ ) : (
139
+ <Text style={[styles.emptyHint, { color: t.colors.muted }]}>
140
+ Choisissez votre rue pour personnaliser les collectes et
141
+ notifications.
142
+ </Text>
143
+ )}
144
+ </View>
145
+ </View>
146
+
147
+ <View style={styles.section}>
148
+ <Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
149
+ ACTIONS
150
+ </Text>
151
+ <View style={styles.actions}>
152
+ <Button
153
+ variant="secondary"
154
+ leftIcon={MapPin}
155
+ loading={isLoading}
156
+ onPress={() => void onChangeSector()}
157
+ >
158
+ Changer de secteur
159
+ </Button>
160
+ <Button
161
+ variant="ghost"
162
+ leftIcon={Trash2}
163
+ loading={isLoading}
164
+ onPress={onDeleteData}
165
+ textStyle={{ color: theme.colors.error }}
166
+ >
167
+ Supprimer mes données
168
+ </Button>
169
+ </View>
170
+ </View>
171
+ </View>
172
+ );
173
+ }
174
+
175
+ const styles = StyleSheet.create({
176
+ screen: {
177
+ flex: 1,
178
+ paddingHorizontal: SPACE.pageX,
179
+ paddingVertical: SPACE.sectionY,
180
+ gap: SPACE.sectionY,
181
+ },
182
+ section: {
183
+ gap: 10,
184
+ },
185
+ sectionLabel: {
186
+ fontSize: 12,
187
+ fontWeight: "700",
188
+ letterSpacing: 0.6,
189
+ },
190
+ recapCard: {
191
+ padding: SPACE.cardPad,
192
+ gap: 16,
193
+ },
194
+ recapHead: {
195
+ flexDirection: "row",
196
+ alignItems: "center",
197
+ gap: 12,
198
+ },
199
+ recapIcon: {
200
+ width: SPACE.iconHit,
201
+ height: SPACE.iconHit,
202
+ alignItems: "center",
203
+ justifyContent: "center",
204
+ },
205
+ recapTitle: {
206
+ flex: 1,
207
+ fontSize: 17,
208
+ fontWeight: "700",
209
+ },
210
+ recapList: {
211
+ gap: 0,
212
+ },
213
+ recapRow: {
214
+ gap: 4,
215
+ paddingVertical: 10,
216
+ },
217
+ recapLabel: {
218
+ fontSize: 12,
219
+ fontWeight: "600",
220
+ },
221
+ recapValue: {
222
+ fontSize: 16,
223
+ fontWeight: "700",
224
+ },
225
+ divider: {
226
+ height: StyleSheet.hairlineWidth,
227
+ width: "100%",
228
+ },
229
+ emptyHint: {
230
+ fontSize: 14,
231
+ lineHeight: 20,
232
+ },
233
+ actions: {
234
+ gap: SPACE.stack,
235
+ },
236
+ });
@@ -0,0 +1,47 @@
1
+ import { useEffect, useRef, type ReactNode } from "react";
2
+ import { Platform } from "react-native";
3
+ import { useLocal } from "../../contexts/LocalContext";
4
+ import { useWasto } from "../../contexts/WastoContext";
5
+ import { useWastoClient } from "../../hooks/useWastoClient";
6
+ import { registerExpoPushToken } from "../../push/registerExpoPushToken";
7
+
8
+ /**
9
+ * Registers the Expo push token once a deviceId exists.
10
+ * Renders nothing — mount inside LocalProvider.
11
+ */
12
+ export function PushTokenRegistrar(): ReactNode {
13
+ const { deviceId } = useLocal();
14
+ const { previewMode, reportError } = useWasto();
15
+ const client = useWastoClient();
16
+ const lastRegistered = useRef<string | null>(null);
17
+
18
+ useEffect(() => {
19
+ if (previewMode || Platform.OS === "web" || !deviceId) return;
20
+ if (lastRegistered.current === deviceId) return;
21
+
22
+ let cancelled = false;
23
+
24
+ void (async () => {
25
+ try {
26
+ const token = await registerExpoPushToken({
27
+ deviceId,
28
+ registerPushToken: (id: string, pushToken: string) =>
29
+ client.public.devices.registerPushToken(id, { token: pushToken }),
30
+ });
31
+ if (!cancelled && token) {
32
+ lastRegistered.current = deviceId;
33
+ }
34
+ } catch (error) {
35
+ if (!cancelled) {
36
+ reportError(error, { source: "push", deviceId });
37
+ }
38
+ }
39
+ })();
40
+
41
+ return () => {
42
+ cancelled = true;
43
+ };
44
+ }, [client.public.devices, deviceId, previewMode, reportError]);
45
+
46
+ return null;
47
+ }