-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show only BPI links to BPI users
- Loading branch information
1 parent
37c3149
commit bd5eefb
Showing
4 changed files
with
93 additions
and
16 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
20 changes: 20 additions & 0 deletions
20
site/source/pages/assistants/choix-du-statut/_components/useIsEmbededBPI.tsx
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,20 @@ | ||
import { createContext, PropsWithChildren, useContext, useState } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
|
||
const BPIContext = createContext(false) | ||
|
||
export const IsBPIProvider = ({ children }: PropsWithChildren) => { | ||
const [isBPI, setIsBPI] = useState(false) | ||
const BPIInSearchParams = useLocation().search.includes('bpifrance-creation') | ||
const BPIInReferer = | ||
!import.meta.env.SSR && document.referrer?.includes('bpifrance-creation') | ||
if (!isBPI && (BPIInSearchParams || BPIInReferer)) { | ||
setIsBPI(true) | ||
} | ||
|
||
return <BPIContext.Provider value={isBPI}>{children}</BPIContext.Provider> | ||
} | ||
|
||
export default function useIsEmbededOnBPISite() { | ||
return useContext(BPIContext) | ||
} |
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