-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Create a ephemeral (temp) backend to get started with profile page and sign-up page
- Loading branch information
Showing
24 changed files
with
3,207 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: "Chore \U0001F527" | ||
about: Internal things, technical debt, and to-do tasks to be performed. | ||
title: '' | ||
labels: chore | ||
assignees: '' | ||
projects: gamedoora/gamedoora-ui/projects/1 | ||
--- | ||
|
||
<!-- Separate suggestions for updates to configuration or build processes and libraries / Internal things, technical debt, and to-do tasks to be performed should be reported in separate issues.--> | ||
|
||
## Is your chore related to a problem? Please describe | ||
|
||
<!-- A clear and concise description of what the problem is.--> | ||
|
||
## Describe the solution you'd like | ||
|
||
<!-- A clear and concise description of what you want to happen. --> | ||
|
||
## Describe alternatives you've considered | ||
|
||
<!--A clear and concise description of any alternative solutions or features you've considered. --> | ||
|
||
## Additional context | ||
|
||
<!-- Add any other context or screenshots about the task here. --> |
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,32 @@ | ||
--- | ||
name: "Documentation proposal \U0001F4D6" | ||
about: Propose documentation improvements / additions | ||
title: '' | ||
labels: documentation | ||
assignees: '' | ||
projects: gamedoora/gamedoora-ui/projects/1 | ||
--- | ||
|
||
<!--For any improvements or additions to existing documentation please be as precise and concise as possible:--> | ||
|
||
## Is your suggestion related to code documentation or product documentation problem | ||
|
||
<!-- | ||
* Code / Product: [e.g. Code, Product] | ||
* File / Document Name: [e.g. README.md, package.json] | ||
--> | ||
|
||
## Describe your suggestion | ||
|
||
<!-- A clear and concise description of what changes you are proposing. In the case of multiple documents, please create separate issues. --> | ||
|
||
## Describe any reference material that might be helpful | ||
|
||
<!-- | ||
1. Name and description of reference material. | ||
2. Name and description of reference material. | ||
--> | ||
|
||
## Additional context | ||
|
||
<!-- Add any other context or screenshots about the proposal here. --> |
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,24 @@ | ||
--- | ||
name: "Feature request \U0001F4A1" | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
projects: gamedoora/gamedoora-ui/projects/1 | ||
--- | ||
|
||
## Is your feature request related to a problem? Please describe | ||
|
||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> | ||
|
||
## Describe the solution you'd like | ||
|
||
<!-- A clear and concise description of what you want to happen. --> | ||
|
||
## Describe alternatives you've considered | ||
|
||
<!--A clear and concise description of any alternative solutions or features you've considered. --> | ||
|
||
## Additional context | ||
|
||
<!-- Add any other context or screenshots about the enhancement here. --> |
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,22 @@ | ||
--- | ||
name: "Question \U0001F914" | ||
about: Usage question or discussion about anything related to the platform | ||
title: '' | ||
labels: question | ||
assignees: '' | ||
projects: gamedoora/gamedoora-ui/projects/1 | ||
--- | ||
|
||
<!-- | ||
To make it easier for us to help you, please include as much useful information as possible. | ||
Before opening a new issue, please search existing issues https://github.com/gamedoora/gamedoora-ui/issues | ||
--> | ||
|
||
## Summary | ||
|
||
<!-- Provide a short summary --> | ||
|
||
## Relevant information | ||
|
||
<!-- Provide as much useful information as you can --> |
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,49 @@ | ||
--- | ||
name: "Regression report \U0001F570" | ||
about: Tell us about something that worked at one point and now doesn't | ||
title: '' | ||
labels: regression | ||
assignees: '' | ||
projects: gamedoora/gamedoora-ui/projects/1 | ||
--- | ||
|
||
<!--For regression reports, please provide as much relevant info as possible.--> | ||
|
||
## Potential Commit/PR that introduced the regression | ||
|
||
<!-- If you have time to investigate, what PR/date introduced this issue. --> | ||
|
||
## Describe the regression | ||
|
||
<!-- A clear and concise description of what the regression is. --> | ||
|
||
## Steps to reproduce | ||
|
||
<!-- | ||
1. Do '...' | ||
2. Click on '....' | ||
3. See error | ||
For the fastest support, provide a working demo or minimal reproduction using tools such as [codepen](https://codepen.io/) or [jsfiddle](https://jsfiddle.net/) | ||
--> | ||
|
||
## Expected behavior | ||
|
||
<!-- A clear and concise description of what you expected to happen. --> | ||
|
||
## Screenshots | ||
|
||
<!-- If applicable, add screenshots to help explain your problem. --> | ||
|
||
## Environment | ||
|
||
- Operating System(s): Linux/macOS/Windows [Variant and Version] | ||
- Browser: Firefox/Chrome/Safari [Version] / Other (please specify) | ||
|
||
## Tell us more about your product/project and timeline to help prioritize this issue | ||
|
||
<!-- | ||
* What product/project does this impact? | ||
* List product/project release(s) and timelines. | ||
* Is this a customer reported blocking issue? | ||
--> |
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 axios from 'axios'; | ||
import { getCookie } from 'cookies-next'; | ||
|
||
export const axiosConfig = axios.create({ | ||
baseURL: '/api/', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
}); | ||
|
||
axiosConfig.interceptors.request.use((config) => { | ||
const jwt = getCookie('jwt'); | ||
config.headers.Authorization = `Bearer ${jwt}`; | ||
return config; | ||
}); |
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,111 @@ | ||
import { AuthenticationContext } from '@/app/context/AuthContext'; | ||
import axios from 'axios'; | ||
import { deleteCookie } from 'cookies-next'; | ||
import { useContext } from 'react'; | ||
|
||
const useAuth = () => { | ||
const { setAuthState } = useContext(AuthenticationContext); | ||
const signIn = async ( | ||
{ | ||
email, | ||
password, | ||
}: { | ||
email: string; | ||
password: string; | ||
}, | ||
handleClose: () => void | ||
) => { | ||
setAuthState({ | ||
data: null, | ||
error: null, | ||
loading: true, | ||
}); | ||
try { | ||
const response = await axios.post( | ||
'http://localhost:3000/api/auth/signin', | ||
{ | ||
email, | ||
password, | ||
} | ||
); | ||
setAuthState({ | ||
data: response.data, | ||
error: null, | ||
loading: false, | ||
}); | ||
handleClose(); | ||
} catch (error: any) { | ||
setAuthState({ | ||
data: null, | ||
error: error.response.data.errorMessage, | ||
loading: false, | ||
}); | ||
} | ||
}; | ||
const signUp = async ( | ||
{ | ||
email, | ||
password, | ||
firstName, | ||
lastName, | ||
city, | ||
phone, | ||
}: { | ||
email: string; | ||
password: string; | ||
firstName: string; | ||
lastName: string; | ||
city: string; | ||
phone: string; | ||
}, | ||
handleClose: () => void | ||
) => { | ||
setAuthState({ | ||
data: null, | ||
error: null, | ||
loading: true, | ||
}); | ||
try { | ||
const response = await axios.post( | ||
'http://localhost:3000/api/auth/signup', | ||
{ | ||
email, | ||
password, | ||
firstName, | ||
lastName, | ||
city, | ||
phone, | ||
} | ||
); | ||
setAuthState({ | ||
data: response.data, | ||
error: null, | ||
loading: false, | ||
}); | ||
handleClose(); | ||
} catch (error: any) { | ||
setAuthState({ | ||
data: null, | ||
error: error.response.data.errorMessage, | ||
loading: false, | ||
}); | ||
} | ||
}; | ||
|
||
const signOut = () => { | ||
deleteCookie('jwt'); | ||
setAuthState({ | ||
data: null, | ||
loading: false, | ||
error: null, | ||
}); | ||
}; | ||
|
||
return { | ||
signIn, | ||
signUp, | ||
signOut, | ||
}; | ||
}; | ||
|
||
export default useAuth; |
Oops, something went wrong.