update bugs fix medicine, user record update-delete, user login
This commit is contained in:
@@ -81,17 +81,19 @@ type AuthProviderProps = {
|
||||
function AuthProvider({ children }: AuthProviderProps) {
|
||||
const [state, dispatch] = useReducer(JWTReducer, initialState);
|
||||
let location = useLocation();
|
||||
const accessToken = getSession();
|
||||
|
||||
useEffect(() => {
|
||||
const initialize = async () => {
|
||||
(async () => {
|
||||
try {
|
||||
const accessToken = getSession();
|
||||
// const accessToken = getSession();
|
||||
|
||||
if (accessToken) {
|
||||
setSession(accessToken);
|
||||
|
||||
const response = await axios.get('/user');
|
||||
const user = response.data;
|
||||
|
||||
|
||||
dispatch({
|
||||
type: Types.Initial,
|
||||
payload: {
|
||||
@@ -117,11 +119,10 @@ function AuthProvider({ children }: AuthProviderProps) {
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
initialize();
|
||||
}, []);
|
||||
})();
|
||||
}, [accessToken]);
|
||||
|
||||
|
||||
const login = async (email: string, password: string) => axios
|
||||
.post('/login', { email, password })
|
||||
.then((response) => {
|
||||
|
||||
Reference in New Issue
Block a user