Skip to content

Commit

Permalink
Merge pull request #73 from hybridx/chore/#72
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
hybridx authored Aug 20, 2023
2 parents 25817e2 + 5029fed commit 9d0f8ab
Show file tree
Hide file tree
Showing 24 changed files with 3,207 additions and 80 deletions.
19 changes: 11 additions & 8 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

projects: gamedoora/gamedoora-ui/projects/1
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +25,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/chore.md
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. -->
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation_proposal.md
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. -->
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
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. -->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
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 -->
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/regression_report.md
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?
-->
20 changes: 13 additions & 7 deletions .github/workflows/test.yml → .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Test & Build Gamedoora-UI

on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
build:
Expand All @@ -19,9 +17,17 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 20.x
- run: npm install
- run: |

- name: Install and copy env
run: |
npm install
env | grep "^(NEXT|GAMEDOORA)" | sed 's/\(.*\)=\(.*\)/\1="\2"/g' >> .env
cat .env
- name: Run lint
run: |
npm run lint
- name: Run build
run: |
npm run build
16 changes: 16 additions & 0 deletions config/config.ts
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;
});
111 changes: 111 additions & 0 deletions hooks/useAuth.ts
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;
Loading

0 comments on commit 9d0f8ab

Please sign in to comment.