@applica-software-guru/react-admin 1.5.267 → 1.5.268

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 CHANGED
@@ -106,5 +106,5 @@
106
106
  "type": "module",
107
107
  "types": "dist/index.d.ts",
108
108
  "typings": "dist/index.d.ts",
109
- "version": "1.5.267"
109
+ "version": "1.5.268"
110
110
  }
@@ -18,10 +18,11 @@ type ILayoutProps = React.PropsWithChildren<{
18
18
  copy?: string;
19
19
  error?: React.ComponentType<ErrorProps>;
20
20
  enableThemeToggler: boolean;
21
+ enableNotification: boolean;
21
22
  }>;
22
23
 
23
24
  const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
24
- const { name, version, enableThemeToggler } = props;
25
+ const { name, version, enableThemeToggler, enableNotification } = props;
25
26
  const { isLoading, navigation, breadcrumbs } = useBreadcrumbs();
26
27
 
27
28
  return (
@@ -32,7 +33,7 @@ const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
32
33
  {enableThemeToggler ? <ThemeToggler /> : null}
33
34
  <ThemeColor />
34
35
  <LoadingIndicator />
35
- <HeaderNotification />
36
+ {enableNotification ? <HeaderNotification /> : null}
36
37
  <ResponsiveSection>
37
38
  <HeaderProfile />
38
39
  </ResponsiveSection>
@@ -18,6 +18,10 @@ type ICreateI18nProviderData = {
18
18
  createMissing?: boolean;
19
19
  customProvider?: Promise<I18nProvider>;
20
20
  };
21
+ type ICreateJsonI18nProviderData = {
22
+ path: string;
23
+ defaultLocale: string;
24
+ };
21
25
  type IPolyglotOptions = {
22
26
  phrases?: IDictionary;
23
27
  locale?: string;
@@ -88,19 +92,26 @@ function createI18nProvider(data: ICreateI18nProviderData): Promise<any> {
88
92
  });
89
93
  });
90
94
  }
91
- function createJsonI18nProvider(data: ICreateI18nProviderData): Promise<I18nProvider> {
92
- const { defaultLocale, apiUrl } = data;
95
+
96
+ /**
97
+ * Create an I18nProvider that fetches translations from JSON files.
98
+ *
99
+ * @param data {ICreateI18nProviderData} - The data to create the I18nProvider
100
+ * @returns {Promise<I18nProvider>} - The I18nProvider
101
+ */
102
+ function createJsonI18nProvider(data: ICreateJsonI18nProviderData): Promise<I18nProvider> {
103
+ const { defaultLocale, path } = data;
93
104
  const defaultLanguages: Array<Locale> = [{ locale: defaultLocale, name: defaultLocale }];
94
105
  const headers = new Headers({ Accept: 'application/json', 'Content-Type': 'application/json' });
95
106
  function getLanguages(): Promise<Locale> {
96
- return fetch(`${apiUrl}/i18n/languages.json`, { headers: headers, method: 'get' })
107
+ return fetch(`${path}/languages.json`, { headers: headers, method: 'get' })
97
108
  .then((response) => response.json())
98
109
  .catch(() => {
99
110
  return Promise.resolve(defaultLanguages);
100
111
  });
101
112
  }
102
113
  function getMessages(): Promise<ITranslations> {
103
- return fetch(`${apiUrl}/i18n/messages.json`, { headers: headers, method: 'get' })
114
+ return fetch(`${path}/messages.json`, { headers: headers, method: 'get' })
104
115
  .then((response) => response.json())
105
116
  .then((response: Array<IMessage>): ITranslations => {
106
117
  return response.reduce(
@@ -9,7 +9,7 @@ import { ApplicaDataProvider, createAttachmentsParser } from '@applica-software-
9
9
  import { ApplicaAuthProvider, LocalStorage } from '@applica-software-guru/iam-client';
10
10
  import { CustomRoutes } from 'ra-core';
11
11
  import { Route } from 'react-router-dom';
12
- // import { createJsonI18nProvider } from '@/i18n';
12
+ import { createJsonI18nProvider } from '@/i18n';
13
13
 
14
14
  const authProvider = new ApplicaAuthProvider(API_URL, new LocalStorage());
15
15
  const dataProvider = new ApplicaDataProvider({
@@ -20,7 +20,7 @@ const dataProvider = new ApplicaDataProvider({
20
20
  attachmentsParser: createAttachmentsParser(),
21
21
  HttpErrorClass: HttpError
22
22
  });
23
- // const i18nProvider = createJsonI18nProvider({ apiUrl: `//${document.location.host}`, defaultLocale: 'it' });
23
+ const i18nProvider = createJsonI18nProvider({ path: `//${document.location.host}/i18n`, defaultLocale: 'en' });
24
24
  function App() {
25
25
  return (
26
26
  <ApplicaAdmin
@@ -31,7 +31,7 @@ function App() {
31
31
  apiUrl={API_URL}
32
32
  authProvider={authProvider}
33
33
  dataProvider={dataProvider}
34
- // i18nProvider={i18nProvider}
34
+ i18nProvider={i18nProvider}
35
35
  defaultLocale="it"
36
36
  menu={menu}
37
37
  name={APP_NAME}