-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from bounswe/74-connect-mobile-apps-functions-…
…to-backend 74 connect mobile apps functions to backend
- Loading branch information
Showing
10 changed files
with
295 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import axios from "axios"; | ||
|
||
// const baseURL = import.meta.env.VITE_API_URL | ||
// todo: would be the best case scenario but we are in a hurry | ||
|
||
const baseURL = "http://localhost:8080" | ||
|
||
function apiInstance() { | ||
return axios.create({ | ||
baseURL | ||
}); | ||
} | ||
|
||
export default apiInstance; |
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,28 @@ | ||
import React, { createContext, useContext, useState } from 'react'; | ||
|
||
const AuthContext = createContext(null); | ||
|
||
export const AuthProvider = ({ children }) => { | ||
const [authState, setAuthState] = useState({ | ||
isLoggedIn: false, | ||
user: null | ||
}); | ||
|
||
// Function to log in the user and store user data | ||
const login = (userData) => { | ||
setAuthState({ isLoggedIn: true, user: userData }); | ||
}; | ||
|
||
// Function to log out the user | ||
const logout = () => { | ||
setAuthState({ isLoggedIn: false, user: null }); | ||
}; | ||
|
||
return ( | ||
<AuthContext.Provider value={{ ...authState, login, logout }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
}; | ||
|
||
export const useAuth = () => useContext(AuthContext); |
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
Oops, something went wrong.