authentification keyloack + début front
This commit is contained in:
14
front_end/src/context/LocalDataContext2.tsx
Normal file
14
front_end/src/context/LocalDataContext2.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createContext } from 'react'
|
||||
import { Session, User } from '../classes';
|
||||
|
||||
interface LocalDataContextType {
|
||||
user:User;
|
||||
setUser: React.Dispatch<React.SetStateAction<User>>
|
||||
sessions: Session[];
|
||||
setSessions: React.Dispatch<React.SetStateAction<Session[]>>
|
||||
users: User[];
|
||||
setUsers: React.Dispatch<React.SetStateAction<User[]>>
|
||||
|
||||
}
|
||||
|
||||
export const LocalDataContext = createContext<LocalDataContextType | undefined>(undefined)
|
||||
10
front_end/src/context/useLocalData.tsx
Normal file
10
front_end/src/context/useLocalData.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from 'react'
|
||||
import { LocalDataContext } from './LocalDataContext2'
|
||||
|
||||
export const useLocalData = () => {
|
||||
const context = useContext(LocalDataContext)
|
||||
if (!context) {
|
||||
throw new Error('useLocalData must be used within LocalDataProvider')
|
||||
}
|
||||
return context
|
||||
}
|
||||
Reference in New Issue
Block a user