@autobusal/providers 1.43.1 → 1.43.3
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/package.json +1 -1
- package/services.ts +42 -4
- package/types/settings.ts +12 -0
package/package.json
CHANGED
package/services.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
1
2
|
import { useSuspenseQuery, UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
2
3
|
import i18next from 'i18next';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
@@ -55,16 +56,53 @@ export const useGetMenu = (): UseSuspenseQueryResult<MenuData> => {
|
|
|
55
56
|
*/
|
|
56
57
|
const { i18n } = useTranslation();
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const language = i18n.resolvedLanguage ?? i18next.language;
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Claude - 2026-09-07 (Ferjolt: "when we switch to a language and
|
|
63
|
+
* immediately switch to another one, this does not work").
|
|
64
|
+
*
|
|
65
|
+
* A STABLE KEY, REFETCHED when the language changes - not a key that
|
|
66
|
+
* contains the language.
|
|
67
|
+
*
|
|
68
|
+
* With the language in the key, every switch handed this suspense query a
|
|
69
|
+
* key it had never loaded, and a suspense query with no data SUSPENDS.
|
|
70
|
+
* This one is mounted at the app's root (Setup), so the whole tree fell
|
|
71
|
+
* back to the loading screen - the "refresh" a visitor sees on every
|
|
72
|
+
* switch - and remounted when the labels arrived. Anything open at that
|
|
73
|
+
* moment was gone: measured on production, a language chosen while the
|
|
74
|
+
* previous switch's labels were still loading closed the picker and ran
|
|
75
|
+
* nothing, because the button it was clicked on no longer belonged to a
|
|
76
|
+
* mounted tree.
|
|
77
|
+
*
|
|
78
|
+
* Refetching an already-loaded key never suspends. The store keeps the
|
|
79
|
+
* previous language's labels for the few hundred milliseconds the new ones
|
|
80
|
+
* take, the page stays put, and a second choice lands on a live picker.
|
|
81
|
+
* `resolvedLanguage` for the reason the 2026-08-29 note gives.
|
|
82
|
+
*/
|
|
83
|
+
const query = useSuspenseQuery<MenuData>({
|
|
84
|
+
queryKey: ['get-menu'],
|
|
60
85
|
queryFn: async () => (
|
|
61
86
|
await apiClient
|
|
62
87
|
.get('/api/menus/get')
|
|
63
88
|
.then(response => {
|
|
64
89
|
menuStore.save(response.data);
|
|
65
90
|
|
|
66
|
-
|
|
91
|
+
// the store is the reader; the query's own data is a token (as before)
|
|
92
|
+
return {} as MenuData;
|
|
67
93
|
})
|
|
68
94
|
)
|
|
69
|
-
})
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const loaded = useRef<string>(language);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (loaded.current !== language) {
|
|
101
|
+
loaded.current = language;
|
|
102
|
+
|
|
103
|
+
query.refetch();
|
|
104
|
+
}
|
|
105
|
+
}, [ language, query ]);
|
|
106
|
+
|
|
107
|
+
return query;
|
|
70
108
|
};
|
package/types/settings.ts
CHANGED
|
@@ -199,6 +199,18 @@ export interface LabelSettings {
|
|
|
199
199
|
email: string
|
|
200
200
|
phone: string
|
|
201
201
|
currency: string
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Claude - 2026-08-31: how that currency is WRITTEN - the ISO code, or the
|
|
205
|
+
* symbol where one is unambiguous. "iso" for a brand that has never made
|
|
206
|
+
* the choice, which is what the platform did before the setting existed.
|
|
207
|
+
*
|
|
208
|
+
* The server decides what actually gets printed (Money\Symbols); this is
|
|
209
|
+
* here so the admin screen can show which option is selected and preview
|
|
210
|
+
* what each would produce.
|
|
211
|
+
*/
|
|
212
|
+
currency_display?: 'iso' | 'symbol' | null
|
|
213
|
+
|
|
202
214
|
affiliate_max_tickets: number
|
|
203
215
|
|
|
204
216
|
/**
|