forked from OPEN-ENT-NG/magneto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc1c29d
commit 113e348
Showing
21 changed files
with
270 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ComponentPropsWithoutRef, type ReactNode } from "react"; | ||
|
||
interface LayoutProps extends ComponentPropsWithoutRef<any> { | ||
/** Main content of an application */ | ||
children: ReactNode; | ||
} | ||
|
||
const Layout = ({ children }: LayoutProps) => { | ||
return ( | ||
<div className="d-flex flex-column bg-white container-fluid"> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { createContext, useContext, useEffect, useMemo } from "react"; | ||
|
||
import { OdeClientProps, OdeContextProps } from "@edifice-ui/react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { confQuery, sessionQuery } from "./fakeData"; | ||
|
||
export const OdeClientContext = createContext<OdeContextProps | null>(null!); | ||
|
||
export function OdeClientProvider({ children, params }: OdeClientProps) { | ||
const appCode = params.app; | ||
|
||
const { t } = useTranslation(); | ||
const translatedAppCode = t(appCode); | ||
|
||
const init = confQuery?.isSuccess && sessionQuery?.isSuccess; | ||
|
||
useEffect(() => { | ||
const attributes = [ | ||
{ | ||
data: "html", | ||
value: sessionQuery?.data?.currentLanguage || "fr", | ||
}, | ||
// #WB-3137 Disable the translation of the content of the page which provoced issues | ||
{ | ||
data: "translate", | ||
value: "no", | ||
}, | ||
]; | ||
|
||
attributes.forEach((attribute) => { | ||
return document | ||
.querySelector("html") | ||
?.setAttribute(attribute.data, attribute.value as string); | ||
}); | ||
}, [sessionQuery?.data]); | ||
|
||
useEffect(() => { | ||
document.title = `${translatedAppCode}`; | ||
}, [appCode, sessionQuery.data, translatedAppCode]); | ||
|
||
const values = useMemo( | ||
() => ({ | ||
appCode, | ||
applications: confQuery?.data?.applications, | ||
confQuery, | ||
currentApp: confQuery?.data?.currentApp, | ||
currentLanguage: sessionQuery?.data?.currentLanguage, | ||
init, | ||
sessionQuery, | ||
user: sessionQuery?.data?.user, | ||
userDescription: sessionQuery?.data?.userDescription, | ||
userProfile: sessionQuery?.data?.userProfile, | ||
}), | ||
[appCode, confQuery, init, sessionQuery], | ||
); | ||
|
||
return ( | ||
<OdeClientContext.Provider value={values}> | ||
{children} | ||
</OdeClientContext.Provider> | ||
); | ||
} | ||
|
||
export function useOdeClient() { | ||
const context = useContext(OdeClientContext); | ||
|
||
if (!context) { | ||
throw new Error(`Cannot be used outside of OdeClientProvider`); | ||
} | ||
return context; | ||
} |
Oops, something went wrong.