@autobusal/providers 1.0.12 → 1.0.13
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/Setup/Preload.tsx +0 -11
- package/Setup/Setup.tsx +3 -1
- package/package.json +1 -1
- package/services.ts +11 -6
package/Setup/Preload.tsx
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
1
|
import { Helmet } from 'react-helmet';
|
|
3
2
|
import { SettingsData } from '../types';
|
|
4
|
-
import { GetMenu } from '../services';
|
|
5
|
-
import { useMenuStore } from '../stores/menu';
|
|
6
3
|
|
|
7
4
|
interface Props {
|
|
8
5
|
data: SettingsData
|
|
@@ -11,14 +8,6 @@ interface Props {
|
|
|
11
8
|
|
|
12
9
|
// @todo: De adaugat din tema Favicons
|
|
13
10
|
const Preload = ({ data, children }: Props): JSX.Element => {
|
|
14
|
-
const { data: MenuData } = GetMenu();
|
|
15
|
-
|
|
16
|
-
const menuStore = useMenuStore();
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
menuStore.save(MenuData);
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
11
|
// we arrange the font family names before inserting them
|
|
23
12
|
const fontTitle = data.theme.fontFamily.title.replace(/\ /g, '+');
|
|
24
13
|
const fontContent = data.theme.fontFamily.content.replace(/\ /g, '+');
|
package/Setup/Setup.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Preload from './Preload';
|
|
2
2
|
import languages from './utilities/languages';
|
|
3
3
|
import analytics from './utilities/analytics';
|
|
4
|
-
import { GetSettings } from '../services';
|
|
4
|
+
import { GetSettings, GetMenu } from '../services';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
type: 'normal' | 'whitelabel'
|
|
@@ -11,6 +11,8 @@ interface Props {
|
|
|
11
11
|
const Setup = ({ type, children }: Props): JSX.Element => {
|
|
12
12
|
const { data } = GetSettings();
|
|
13
13
|
|
|
14
|
+
GetMenu();
|
|
15
|
+
|
|
14
16
|
languages(type, data.preferences.languages.default);
|
|
15
17
|
|
|
16
18
|
analytics(data.preferences.googleAnalyticsID);
|
package/package.json
CHANGED
package/services.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useSuspenseQuery, UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import apiClient from './Queries/apiClient';
|
|
3
3
|
import { SettingsData, MenuData } from './types';
|
|
4
|
+
import { useMenuStore } from './stores/menu';
|
|
4
5
|
|
|
5
6
|
export const GetSettings = (): UseSuspenseQueryResult<SettingsData> => (
|
|
6
7
|
useSuspenseQuery({
|
|
@@ -17,16 +18,20 @@ export const GetSettings = (): UseSuspenseQueryResult<SettingsData> => (
|
|
|
17
18
|
})
|
|
18
19
|
);
|
|
19
20
|
|
|
20
|
-
export const GetMenu = (): UseSuspenseQueryResult<MenuData> =>
|
|
21
|
-
|
|
21
|
+
export const GetMenu = (): UseSuspenseQueryResult<MenuData> => {
|
|
22
|
+
const menuStore = useMenuStore();
|
|
23
|
+
|
|
24
|
+
return useSuspenseQuery({
|
|
22
25
|
queryKey: ['get-menu'],
|
|
23
26
|
queryFn: async () => (
|
|
24
27
|
await apiClient
|
|
25
28
|
.get('/api/menus/get')
|
|
26
|
-
.then(response =>
|
|
27
|
-
response.data
|
|
28
|
-
|
|
29
|
+
.then(response => {
|
|
30
|
+
menuStore.save(response.data);
|
|
31
|
+
|
|
32
|
+
return {};
|
|
33
|
+
})
|
|
29
34
|
.catch(() => {})
|
|
30
35
|
)
|
|
31
36
|
})
|
|
32
|
-
|
|
37
|
+
};
|