Skip to content

Commit

Permalink
feat(pci-ai-notebooks): build fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Bullet <[email protected]>
  • Loading branch information
abullet33 committed Oct 10, 2024
1 parent 7bbf0df commit a0660ca
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
</strong>
</noscript>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
<script type="module" src="./src/main.tsx"></script>
</body>
</html>
52 changes: 52 additions & 0 deletions packages/manager/apps/pci-ai-notebooks/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import {
ShellProvider,
initShellContext,
} from '@ovh-ux/manager-react-shell-client';
import initI18n from './i18n';
import App from './App';

import '@/vite-hmr.ts';
import { LoadingIndicatorProvider } from './contexts/LoadingIndicator.context';

const init = async (
appName: string,
{ reloadOnLocaleChange } = { reloadOnLocaleChange: false },
) => {
const context = await initShellContext(appName);

const region = context.environment.getRegion();
try {
await import(`./config-${region}.js`);
} catch (error) {
// nothing to do
}

const locales = await context.shell.i18n.getAvailableLocales();

const i18n = initI18n(
context.environment.getUserLocale(),
locales.map(({ key }: { key: string }) => key),
);

context.shell.i18n.onLocaleChange(({ locale }: { locale: string }) => {
if (reloadOnLocaleChange) {
window.top?.location.reload();
} else {
i18n.changeLanguage(locale);
}
});

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<ShellProvider client={context}>
<LoadingIndicatorProvider>
<App />
</LoadingIndicatorProvider>
</ShellProvider>
</React.StrictMode>,
);
};

init('pci-ai-notebooks');

0 comments on commit a0660ca

Please sign in to comment.