Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7주차] 댄서포트(Dan-support) 미션 제출합니다. #5

Open
wants to merge 114 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
78290a7
init: 초기 세팅
May 26, 2023
1ee0155
init: prettier,라이브러리 추가
May 26, 2023
654ce0a
init: 폴더 정리
May 26, 2023
8ddefa3
feat: LoginPage,RegisterPage 추가
May 26, 2023
e50e979
feat: RegisterPage,LoginPage UI
Jun 4, 2023
e506fb4
feat: loginpage (api, data..)
sujinRo Jun 5, 2023
08e95e6
fix: login 했을 때, 가는 페이지 변경
sujinRo Jun 7, 2023
11eae95
feat: login page css
sujinRo Jun 7, 2023
c06cc39
feat: Header 추가
sujinRo Jun 7, 2023
0f37172
feat: css 조금 추가
sujinRo Jun 7, 2023
e70555a
feat: logo 누르면 home화면에 가도록
sujinRo Jun 7, 2023
5360568
feat: 회원가입 버튼 누르면 이동
sujinRo Jun 7, 2023
31c6479
feat: main page css까지 완료
sujinRo Jun 7, 2023
33484f3
fix: css 변경
sujinRo Jun 8, 2023
4e05d5b
feat: data 임의로 만들고, vote 페이지에 불러옴
sujinRo Jun 10, 2023
60e1bc9
feat: 위commit과 내용 일치
sujinRo Jun 10, 2023
9092e5e
feat: 투표box 부분 위치 정렬 완
sujinRo Jun 10, 2023
95694a7
feat: 짜잘한 css
sujinRo Jun 10, 2023
396b36f
feat: demoResult 페이지에서 score이 높은 순으로 정렬 완, css
sujinRo Jun 11, 2023
03f7998
feat: demoResult 페이지 결과 순서 번호 나오게
sujinRo Jun 11, 2023
2d8bf54
feat: demoResult 페이지 1등 팀 css 추가
sujinRo Jun 11, 2023
aab5273
feat: axios instance 및 회원가입,로그인 api 로직 작성
Jun 11, 2023
2e70166
feat: 같은 score일 경우 rank가 같도록
sujinRo Jun 11, 2023
4a5a887
feat: RegisterPage 상태 관리,에러/확인 메시지,유효성 검사(team,part 제외)
Jun 11, 2023
e3eefa0
feat: demoVote 선택한 data 표시
sujinRo Jun 13, 2023
75484dc
feat: demoVote 선택한 data 표시 + box위치 정렬
sujinRo Jun 14, 2023
8e93d79
feat: 투표 후, alert 창
sujinRo Jun 14, 2023
cdd5046
feat: function 통해 code 줄임
sujinRo Jun 15, 2023
3336f4b
feat: LoginPage 상태관리
Jun 16, 2023
5070cba
feat: user interface 정의, user 전역 상태 생성
Jun 16, 2023
f51e1ba
회원가입,로그인,id와 email 중복 확인 api 로직들 작성
Jun 16, 2023
6e382b9
feat: RegisterPage,LoginPage에 api 로직들 가져와서 연결
Jun 16, 2023
79d5aee
fix: RegisterPage에서, register 함수에 전달할 인자 수정
Jun 16, 2023
1082ef3
feat: RegisterPage에서, 회원가입 form submit시에 유효성 검사 하나라도 통과 못하면 subit 못하도…
Jun 16, 2023
d9c50d1
fix: uid의 type에 null 추가
Jun 16, 2023
195981b
feat: QueryClient 추가
Jun 16, 2023
2f0177e
feat: RecoilRoot 추가
Jun 16, 2023
ee7b5c8
feat: team,part 부분 리팩토링,상태 관리
Jun 17, 2023
ece0b1d
feat: 파트장 투표,데모데이 투표 라우팅
Jun 18, 2023
12c002b
feat: 충돌 방지 제거
sujinRo Jun 19, 2023
8af5e29
fix: RegisterPage에서 part의 state를 'frontend'/'backend'->'fe'/'be'로 변경
Jun 19, 2023
3849b9c
실수 어쩌고
Jun 19, 2023
ac80e66
feat: merge전, url경로 변경
sujinRo Jun 19, 2023
bb34645
feat: 충돌 때문에,,
sujinRo Jun 19, 2023
0e26c65
feat: 충돌하는 거 다 제거,,
sujinRo Jun 19, 2023
12d81a9
feat: 충돌 해결중,,
sujinRo Jun 19, 2023
aa5cfe2
Merge branch 'develop' into feature/login2/Sujin
sujinRo Jun 19, 2023
0fbe54f
Merge pull request #3 from Dan-support-CEOS/feature/login2/Sujin
sujinRo Jun 19, 2023
923ccf2
feat: 충돌 때문에 삭제했던것 추가
sujinRo Jun 19, 2023
600bb1b
feat: PartLeaderVotePage(FE/BE) UI 구현
Jun 21, 2023
8dec885
feat: PartLeaderVotePage에, 선택한 후보 state 관리
Jun 21, 2023
a798a22
feat: 파트장 투표 api 로직 작성,PartLeaderVotePage에 api 로직 가져와서 사용
Jun 21, 2023
d36a325
feat: PartLeaderResultPage UI,state 관리,파트장 투표결과 api 로직 작성 및 사용
Jun 22, 2023
14f749e
fix: RegisterPage에서 team 이름 목록 수정
Jun 22, 2023
90b6341
develop 브랜치 pull해오고, 수정할 부분 수정
Jun 24, 2023
a5a4f55
Merge pull request #4 from Dan-support-CEOS/feature/partleader-vote
paya17 Jun 24, 2023
cb0579e
fix: 세오스 로고 이름 더 명확하게 수정
Jun 24, 2023
44b78d9
style: 글로벌 스타일 수정
Jun 24, 2023
5e7c8f1
feat: Layout 생성해서 Header 컴포넌트 여기로 이동, 회원가입 페이지/파트장 투표 페이지 조금 스타일링
Jun 24, 2023
d42aba8
style: 스타일링 수정
Jun 25, 2023
bc33a33
별 거 아님
Jun 25, 2023
e77a64f
feat: 백엔드에서 받은 거랑 맞춰서, api 수정 및 추가, 전역상태 userState 수정, interface 수정
Jun 26, 2023
4f9da3f
로그인한 후 백으로부터 받은 응답으로, LoginPage에서 전역상태 userState를 업데이트하는 로직 수정
Jun 26, 2023
145c96a
feat: LoginPage에서, 로그인 성공하면 홈페이지로 navigate되도록 + 로그인 실패하면 아이디,비번 초기화되도록
Jun 26, 2023
c0ee4ea
feat: Header 컴포넌트에, 로그아웃 로직 작성, 로그아웃 상태면 회원가입,로그인 버튼 보이게/로그인 상태면 유저 정…
Jun 26, 2023
fd6dcc5
feat: 로그아웃하면, 홈페이지로 navigate되도록
Jun 26, 2023
ee3868e
fix: 로그아웃 로직 수정(로그아웃 api 다시 사용)
Jun 26, 2023
52f92c2
feat: 파트 선택하는 PartSelectPage 생성, 본인 파트의 파트장 투표만 가능하게 하는 로직 작성
Jun 26, 2023
f0b4242
feat: Home페이지에서, 로그인 여부/재투표 여부로 파트장 투표 가능 여부 판별하는 로직 작성, 파트장 투표 권한 확인…
Jun 26, 2023
c802036
Merge pull request #5 from Dan-support-CEOS/feature/api-연결(yoojin)
paya17 Jun 26, 2023
24a6a57
feat: demoVote, demoResult api 추가
sujinRo Jun 27, 2023
e7e838d
feat: DemoVote 클릭 수가 백으로 넘어가도록
sujinRo Jun 27, 2023
7c81619
feat: Header css 추가
sujinRo Jun 27, 2023
73c4d0f
feat: demoResult 백에서 값을 받아와서 보여줌
sujinRo Jun 27, 2023
5a59aea
feat: demoDay authority code 추가 (token 안 넘어가지는 상태)
sujinRo Jun 27, 2023
65152e8
feat: global style과 겹치는 css 제거
sujinRo Jun 27, 2023
8285257
feat: 짜잘한 수정
sujinRo Jun 27, 2023
db9996f
chore: 자잘한 수정
Jun 27, 2023
a283877
feat: logout, authority 기능 api 연결
sujinRo Jun 27, 2023
a89af29
style: RegisterPage 스타일링(ing)
Jun 27, 2023
c51cbc6
style
Jun 27, 2023
9ebcf4b
feat: 로그아웃하면 user 정보,accessToken 초기화되도록, 로그아웃 로직 수정
Jun 28, 2023
1b2a7fa
feat: tokenRefresh 메소드 변경
sujinRo Jun 28, 2023
884f5ee
style: partSelectPage css
sujinRo Jun 28, 2023
24dcc92
feat: router 추가/ alert 내용 추가
sujinRo Jun 28, 2023
f02b69c
style: 파트장 투표 결과보기 페이지 스타일링 추가
Jun 28, 2023
a77b996
Merge pull request #9 from Dan-support-CEOS/feature/api-연결(sujin)
sujinRo Jun 28, 2023
9764cbd
fix: 회원가입 페이지 로직,스타일 수정
Jun 28, 2023
e888339
fix: 회원가입 유효성 검사 로직 수정
Jun 28, 2023
c437da0
style : 파트장 투표 페이지에서, 클릭한 후보 버튼에 검정색 border가 생기도록
Jun 28, 2023
deda3bc
style: 파트장 투표 결과 페이지 파트 선택 스타일링,회원가입 버튼 가운데로
Jun 28, 2023
78888e2
chore
Jun 28, 2023
081b32b
Merge branch 'develop' of https://github.com/Dan-support-CEOS/react-v…
paya17 Jun 28, 2023
1daca47
style: 글로벌 스타일에서 border:none; 다시 추가
paya17 Jun 28, 2023
951f5f7
Merge pull request #10 from Dan-support-CEOS/feature/api-연결(yoojin)
paya17 Jun 28, 2023
3be8cc0
에러 해결
paya17 Jun 28, 2023
a289f3d
feat: title 추가
sujinRo Jun 28, 2023
6ebb2bd
feat: 필요없는 것 정리
sujinRo Jun 28, 2023
e86d29a
feat: env 추가
sujinRo Jun 28, 2023
aa457d4
어쩌구
paya17 Jun 28, 2023
0883292
.env를 gitignore에 추가
paya17 Jun 28, 2023
46a900e
style: css 전체적으로 수정
sujinRo Jun 28, 2023
6713e17
feat: 로그인/회원가입 글씨 추가
sujinRo Jun 28, 2023
497c186
style: register, login styling 맞춤
sujinRo Jun 28, 2023
2275acb
fix: title 위치 수정
paya17 Jun 29, 2023
85b31de
style: 투표 페이지의 후보 버튼들에 hover시 transition 적용
paya17 Jun 29, 2023
0be3f74
style: transition 적용
paya17 Jun 29, 2023
9d40e0d
style: 파트장 투표결과 박스 크기 고정
paya17 Jun 29, 2023
4f92497
style: 파트장 투표 1등만 스타일 다르게 주기
paya17 Jun 29, 2023
e428429
style: 로그인,회원가입 타이틀 스타일 수정
paya17 Jun 29, 2023
7d3ac75
feat: json삭제
sujinRo Jun 29, 2023
ddf2ab8
style: 회원가입 페이지에 사용 가능 버튼 추가
paya17 Jun 29, 2023
fcaeba6
Update README.md
paya17 Apr 22, 2024
e2f0196
Update README.md
paya17 Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem
.env

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"bracketSpacing": true,
"endOfLine": "auto",
"useTabs": false,
"arrowParens": "avoid"
}
103 changes: 58 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
# **마지막 미션: React-Vote! 🗳**

## **서론**

안녕하세요! 프론트 파트장 오지은입니다🙌 어느덧 마지막 스터디네요. 그동안 과제하시면서 힘들고 어려우셨겠지만, 성장했다는 보람이 더 컸으면하는 바람입니다.

이번 스터디는 각 팀의 백엔드와 함께 진행하는 **합동 과제**입니다. 모던 웹에서 REST API가 주류로 떠오름에 따라 프론트엔드와 백엔드의 구분이 이전보다 명확해졌습니다. 주로 백엔드는 API 서버의 역할을, 프론트엔드는 이를 이용해 사용자에게 UI를 제공하는 역할로 웹이 분화되었습니다. 그 말은 곧, API 없이는 사용자에게 의미있는 서비스를 제공하기 힘들어진다는 것이겠죠. 여러분께서도 차후 팀 프로젝트를 진행하시면서 백엔드 개발자들과 API에 대해 소통할 일이 많아질 것입니다.

따라서 이번 과제는 백엔드 개발자들이 전달해준 `API`를 사용해서 구현해보는 미션입니다. 투표 서비스를 개발해 보는 것인데요. 백엔드 개발자와 함께 클라이언트 사이드에서 API를 조금 더 효율적으로 사용할 수 있는 방법에 대해 고민해 보고, 논의해 보는 시간을 가져 보시기 바랍니다.

이번 미션도 화이팅입니다🔥

## **미션**

### **미션 목표**

- REST API를 통한 서버와의 통신 방법을 이해합니다.
- async/await, Promise등 JavaScript의 비동기 처리를 이해합니다.
- API document를 통해 백엔드 개발자와 소통하는 방법을 익힙니다.
- 팀 내의 프론트엔드 개발자와 적절한 역할 분담을 통해 개발 효율을 높이는 방법에 대해 고민합니다.


### **기한**

2023년 6월 28일

### **필수 요건**

- UI/UX에 대한 감각을 최대한 발휘해 디자인을 적용해 봅니다.
- `HTTPS`를 통해 서버와 통신합니다.
- 외의 사항은 [가이드 문서](https://delirious-sociology-a85.notion.site/FE-BE-416499e4b09e4f44b64a3951b3817f94)를 참고하세요.

### **선택 사항**

- API Fetch는 어떤 방식을 사용하든 무방합니다 (axios, Fetch API)
- `Promise.then()` 보단 `async/await`를 사용해 보세요. 더 최신 스펙이랍니다.

## **링크 및 참고자료**

- [리액트 API 연동의 기본](https://react.vlpt.us/integrate-api/01-basic.html)
- [자바스크립트 - 동기(Synchronous)? 비동기(asynchronous)?](https://ljtaek2.tistory.com/142)
- [async와 await, 비동기를 동기코드 처럼](https://kamang-it.tistory.com/entry/JavaScript11async%EC%99%80-await-%EB%B9%84%EB%8F%99%EA%B8%B0%EB%A5%BC-%EB%8F%99%EA%B8%B0%EC%BD%94%EB%93%9C-%EC%B2%98%EB%9F%BC)
- [REST API 제대로 알고 사용하기](https://meetup.toast.com/posts/92)
- [axios란? (feat. Fetch API)](https://velog.io/@shin6403/React-axios%EB%9E%80-feat.-Fetch-API)
- [Postman, 어렵지 않게 사용하기](https://gngsn.tistory.com/26)
## CEOS 파트장/데모데이 투표 서비스 🗳️
각 파트장 선정과 데모데이 우수팀 선정에 대한 투표 진행 서비스입니다.

<a href="https://react-vote-17th-ashen.vercel.app" target="_blank">🌐 배포 사이트</a>

<br />

### 🛠️ 기술 스택
<img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=TypeScript&logoColor=white" align="center"/></a> <img src="https://img.shields.io/badge/Next.js-000000?style=flat-square&logo=Next.js&logoColor=white" align="center"/> <img src="https://img.shields.io/badge/Recoil-3578E5?style=flat-square&logo=recoil&logoColor=white" align="center"/> <img src="https://img.shields.io/badge/React Query-FF4154?style=flat-square&logo=reactquery&logoColor=white" align="center"> <img src="https://img.shields.io/badge/Axios-5A29E4?style=flat-square&logo=Axios&logoColor=white" align="center"> <img src="https://img.shields.io/badge/CSS Modules-000000?style=flat-square&logo=cssmodules&logoColor=white" align="center">

<br />

### 🚀 주요 기능
#### 1. 회원 가입
<img width="1110" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/6108e057-c44d-4040-9e0a-5564d98ced8d"> <br>
- 회원가입 과정에서 이름, 아이디, 비밀번호, 이메일에 대한 유효성 검사를 진행합니다.

#### 2. 로그인
<img width="831" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/d296f0fc-c7f5-4a5b-ae4d-02a0025beb7e"> <br>
- 비밀번호가 잘못되었거나 존재하지 않는 사용자인 경우 에러 메세지를 보여줍니다.

#### 3. 메인 페이지
<img width="887" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/7af994a6-7e32-43b2-8ac7-13a2c250bbd5"> <br>
- 투표에 참여하기 위해서는 회원가입 및 로그인이 필요합니다. 로그인하지 않은 사용자는 투표 페이지에 접근 불가능합니다.
- 투표는 한번만 가능합니다. 재투표는 불가능합니다.

#### 4. 파트장 투표 및 결과 페이지
<img width="721" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/0469a360-e42a-4cd8-bb17-7a9d1728eb51"> <br>
- 본인의 파트에 해당하는 파트장 투표만 참여 가능합니다.
<img width="682" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/7894d793-8843-4328-a9c9-d42d962de5cd">
<img width="860" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/97c1db90-abfb-42df-8190-2cd99bdd74b0"> <br>
- 득표 순으로 내림차순 정렬되어 보여집니다.

#### 5. 데모데이 투표 및 결과 페이지
<img width="856" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/83d97903-84f2-4b2d-8f0b-e3375650baed"> <br>
- 본인이 속한 팀을 제외한 팀에 대한 투표만 가능합니다.
<img width="914" alt="image" src="https://github.com/Dan-support-CEOS/react-vote-17th/assets/88028826/76cd5a28-a9f8-48e1-9608-135e28eb14ba"> <br>
- 득표 순으로 내림차순 정렬되어 보여집니다.



<br />

### 🧑‍💻 팀원 소개
<table>
<tr>
<td align="center"><img src="https://github.com/Dan-sup/Dansup-Frontend/assets/88028826/9c1f109c-4995-4c19-b184-de388718bd99" width="160"></td>
<td align="center"><img src="https://github.com/Dan-sup/Dansup-Frontend/assets/88028826/f327b639-ca1a-45ee-8089-5f3e315d4e03" width="160"></td>
</tr>
<tr>
<td align="center">신유진</td>
<td align="center">노수진</td>
</tr>
<tr>
<td align="center"><a href="https://github.com/paya17" target="_blank">paya17</a></td>
<td align="center"><a href="https://github.com/sujinRo" target="_blank" width="160">sujinRo</a></td>
</tr>
</table>
13 changes: 13 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
webpack: config => {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
});
return config;
},
};
module.exports = nextConfig;
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "react-vote-17th",
"version": "0.1.0",
"private": true,
"proxy": "https://takgyun.shop",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api 주소는 배포시에는 가려주시는게 좋을 것 같아요~!

"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@svgr/webpack": "^8.0.1",
"@tanstack/react-query": "^4.29.7",
"@types/node": "20.2.5",
"@types/react": "18.2.7",
"@types/react-dom": "18.2.4",
"axios": "^1.4.0",
"eslint": "8.41.0",
"eslint-config-next": "13.4.4",
"http-proxy-middleware": "^2.0.6",
"next": "13.4.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"recoil": "^0.7.7",
"typescript": "5.0.4"
}
}
Binary file added public/favicon.ico
Binary file not shown.
29 changes: 29 additions & 0 deletions public/img/ceos-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions src/apis/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import client from './client';

export const register = async (input: any) => {
const response = await client.post('/auth/signup/', {
name: input.name,
login_id: input.id,
password: input.password,
email: input.email,
part: input.part,
team: input.team,
});
return response.data;
};

export const login = async (input: any) => {
const response = await client.post('/auth/signin/', {
login_id: input.id,
password: input.password,
});
return response.data;
};

//id,email 중복 확인
export const checkId = async (id: string) => {
const response = await client.post('/auth/id/check/', {
login_id: id,
});
return response.data;
};

export const checkEmail = async (email: string) => {
const response = await client.post('/auth/email/check/', {
email: email,
});
return response.data;
};

export const logout = async (accessToken: string) => {
const response = await client.get('/auth/signout/', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return response.data;
};

export const tokenRefresh = async () => {
const response = await client.get('/auth/token/refresh/');
return response.data;
};
8 changes: 8 additions & 0 deletions src/apis/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import axios from 'axios';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만들어주신 axios 모듈에 토큰을 싣는 코드를 작성해주시면,
나머지 api 요청들을 서비스화 한 코드들에서 중복된 코드를 훨씬 줄일 수 있을 것 같아요!

headers: {
      Authorization: `Bearer ${accessToken}`,
    },
    


const client = axios.create({
baseURL: 'https://takgyun.shop',
withCredentials: true,
});

export default client;
54 changes: 54 additions & 0 deletions src/apis/vote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import client from './client';

//파트장 투표
export const votePartLeader = async (info: any) => {
const response = await client.post(
'/votes/candidates/',
{
cname: info.name,
part: info.part,
},
{
headers: {
Authorization: `Bearer ${info.accessToken}`,
},
},
);
return response.data;
};

//파트장 투표 중복 제한(권한 확인)
export const checkPartLeaderVoteAuthority = async (accessToken: string) => {
const response = await client.get('/votes/candidates/authority/', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return response.data;
};
Comment on lines +20 to +28

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파트장 투표 중복을 제한하는 기능은
파트장 투표 시에 응답 값으로 분별해주는 방식 (투표 성공, 중복으로 인해 투표 실패)으로
한번에 처리해볼 수도 있을 것 같아요!🤩


//데모데이 투표
export const demoDayVote = async (info: any) => {
const response = await client.post(
'/votes/teams/',
{
tname: info.tname,
},
{
headers: {
Authorization: `Bearer ${info.accessToken}`,
},
},
);
return response.data;
};

//데모데이 투표 중복 제한(권한 확인)
export const demoDayAuthority = async (info: any) => {
const response = await client.get('/votes/teams/authority/', {
headers: {
Authorization: `Bearer ${info.accessToken}`,
},
});
return response.data;
};
Comment on lines +1 to +54

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오옴.. 각 API 요청을 깔끔하게 잘 분리해서 서비스화해주신 것 같아요 👍
매 api 요청마다 유저 정보를 매개변수로 넘겨주도록 되어있는데,
앞선 코멘트처럼 모듈 자체에 토큰을 싣거나,

유저 정보를 본 파일에서 공통으로 불러온다면, 매번 번거롭게 매 api 요청마다 유저 정보를
파라미터로 넘겨주지 않을 수도 있을 것 같습니다!

13 changes: 13 additions & 0 deletions src/apis/voteResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import client from './client';

//파트장 투표 결과
export const getPartLeaderResult = async (part: string) => {
const response = await client.get(`/votes/candidates/${part}/`);
return response.data;
};

//데모데이 투표 결과
export const getDemoDayResult = async () => {
const response = await client.get('/votes/teams/result/');
return response.data;
};
Loading