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

[build] main update #80

Merged
merged 42 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1b54d7e
feat : 채팅방 닫기 기능 뼈대 구현
jinoo0306 Jun 16, 2024
da01438
feat : 채팅방 삭제 기능 구현
jinoo0306 Jun 16, 2024
6f451bb
Merge pull request #64 from 2024-Team-Techeer-Salon/feat/#63
jinoo0306 Jun 16, 2024
87df02d
feat : 새로고침 기능 임시로 해제
jinoo0306 Jun 18, 2024
eeae2e0
feat : 카테고리 페이지 이동 수정
jinoo0306 Jun 18, 2024
8dbf29f
design : 프로필 페이지 모임 정렬 수정
jinoo0306 Jun 18, 2024
d1e3beb
design : 사용자가 상태메세지에 아무것도 입력하지 않았을 때 멘트 출력 디자인
jinoo0306 Jun 18, 2024
757f9ce
design : 프로필 사진과 장소화 상태메세지 간격 맞춤
jinoo0306 Jun 18, 2024
e3d940b
design : 검색 결과 사진 미출력 오류 해결
jinoo0306 Jun 18, 2024
9741389
design : 검색 결과 배열 수정
jinoo0306 Jun 18, 2024
4f32bbb
feat : 검색결과가 없을 때 검색 결과가 없다는 문구 출력
jinoo0306 Jun 18, 2024
8197229
design : 검색 페이지 일부 수정
jinoo0306 Jun 18, 2024
7e2fa4c
Merge pull request #68 from 2024-Team-Techeer-Salon/design/#67
jinoo0306 Jun 19, 2024
a57c9ab
feat : 지도 렌더링 문제 해결
jinoo0306 Jun 19, 2024
ed816f1
chore: ci완성 및 로컬 테스트 완료
YunJuwon0825 Jun 20, 2024
cdc7254
Merge pull request #71 from 2024-Team-Techeer-Salon/chore/#70
YunJuwon0825 Jun 21, 2024
fb3eeb8
design : 모임 생성 페이지 컴포넌트 배치 수정
jinoo0306 Jun 22, 2024
e036c17
design : 메뉴 로그인 버튼 크기 조절
jinoo0306 Jun 22, 2024
dfe6ca3
feat : 토큰 재발급 로직 formApi 함수에도 적용
jinoo0306 Jun 22, 2024
79082c0
refactor : 필요 없는 코드 제거
jinoo0306 Jun 23, 2024
2d78f19
Merge pull request #72 from 2024-Team-Techeer-Salon/feat/#69
jinoo0306 Jun 24, 2024
25c616d
hotfix : CI 브래치에서 develop 브랜치 삭제
jinoo0306 Jun 24, 2024
632e0f1
refactor : any 타입 수정
Ahnnakyung Jun 25, 2024
b2dbe17
Merge branch 'develop' into feat/#66
jinoo0306 Jun 25, 2024
5767332
comment : api 함수들 console.error문 모두 삭제 후 throw error 방식으로 변경
jinoo0306 Jun 25, 2024
0dc42c9
chore : universal-cookie 패키지 설치
jinoo0306 Jun 26, 2024
acb0f3e
type : 타입 지정
jinoo0306 Jun 26, 2024
95d5d9c
refactor : any 타입 모두 제거 후 타입 지정
jinoo0306 Jun 26, 2024
559aaa3
refactor : 타입 분리
jinoo0306 Jun 26, 2024
d9afaf1
feat : 쿠키에서 options 속성 제거
jinoo0306 Jun 26, 2024
e2001db
chore : universal-cookie 패키지 삭제
jinoo0306 Jun 26, 2024
29206e1
Merge pull request #73 from 2024-Team-Techeer-Salon/feat/#66
jinoo0306 Jun 26, 2024
3a89ee1
design : 404 페이지 디자인 수정
jinoo0306 Jul 6, 2024
e77fa96
file : 실수로 서브모듈 추가한거 삭제
jinoo0306 Jul 6, 2024
1d3414f
feat : 로그인이 되어있지 않으면 로그인 페이지로 넘어가도록 기능 구현
jinoo0306 Jul 6, 2024
126103e
fix : 지도를 불러오지 못하는 버그 수정
jinoo0306 Jul 6, 2024
3a5e84c
feat : Loading이 나오는 문제 해결 및 stores에러 제거
jinoo0306 Jul 6, 2024
44e0898
feat : 로그인 후 바로 다시 로그인 페이지로 넘어가는 현상 방지
jinoo0306 Jul 7, 2024
3a98c56
feat : axios.interceptors를 이용해서 헤더에 토큰을 요청하는 방식으로 기능 수정
jinoo0306 Jul 7, 2024
0cbdd2f
feat : 토큰 재발급 기능 수정
jinoo0306 Jul 7, 2024
4a7bc36
comment : 쿼리키 수정
jinoo0306 Jul 7, 2024
b067874
Merge pull request #79 from 2024-Team-Techeer-Salon/feat/#78
YunJuwon0825 Jul 7, 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
47 changes: 47 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Frontend CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:

build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.14.0'

- name: Install yarn
run: npm install -g yarn

- name: Cache yarn dependencies
uses: actions/cache@v3
with:
path: |
~/.yarn/cache
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn install

- name: Build project
run: yarn build


# - name: Trigger Docker CI/CD
# run: |
# curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
# -H "Accept: application/vnd.github.v3+json" \
# https://api.github.com/repos/your-org/docker-repo/dispatches \
# -d '{"event_type":"frontend_updated"}'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

.idea
9 changes: 3 additions & 6 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
/* eslint-disable import/prefer-default-export */
/* eslint-disable no-console */

export function GoogleLogin() {
try {
window.location.href = `${process.env.NEXT_PUBLIC_BASE_URL}/oauth2/authorization/google`;
} catch (error) {
console.error('구글 로그인 에러 : ', error);
throw new Error('구글 로그인 에러 : ', error || '');
}
}

export function KakaoLogin() {
try {
window.location.href = `${process.env.NEXT_PUBLIC_BASE_URL}/oauth2/authorization/kakao`;
} catch (error) {
console.error('카카오 로그인 에러 : ', error);
throw new Error('카카오 로그인 에러 : ', error || '');
}
}

export function NaverLogin() {
try {
window.location.href = `${process.env.NEXT_PUBLIC_BASE_URL}/oauth2/authorization/naver`;
} catch (error) {
console.error('네이버 로그인 에러 : ', error);
throw new Error('네이버 로그인 에러 : ', error || '');
}
}
92 changes: 64 additions & 28 deletions src/api/axios.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-param-reassign */
/* eslint-disable consistent-return */
/* eslint-disable no-underscore-dangle */
import axios from 'axios';
import { getCookie, setCookie } from '@/app/cookies.tsx';

Expand All @@ -11,12 +12,12 @@ const reIssuedToken = async () => {
const response = await axios.post(
`${BASE_URL}/reissue`,
{
access_token: getCookie('accessToken'), // 액세스 토큰을 사용하고 있으나, 일반적으로는 사용하지 않습니다.
refresh_token: getCookie('refreshToken'), // 리프레시 토큰
access_token: getCookie('accessToken'),
refresh_token: getCookie('refreshToken'),
},
{
headers: {
'Content-Type': 'application/json', // 요청의 본문 타입을 지정
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
withCredentials: true, // CORS 요청 시 쿠키를 포함
Expand All @@ -30,40 +31,48 @@ const reIssuedToken = async () => {
}
return response.data;
} catch (error) {
console.error('Token reissue error:', error);
throw error; // 오류를 상위로 전파하여 호출자가 이를 처리할 수 있도록 합니다.
setCookie('accessToken', '');
setCookie('refreshToken', '');
}
};

const api = axios.create({
withCredentials: true,
baseURL: BASE_URL, // 기본 URL 설정
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
});

// 요청 인터셉터를 추가하여 모든 요청에 최신 토큰을 포함시킵니다.
api.interceptors.request.use(
(config) => {
const token = getCookie('accessToken'); // 요청 직전에 액세스 토큰을 쿠키에서 가져옵니다.
config.headers.Authorization = `Bearer ${token}`;
config.headers['Content-Type'] = 'application/json';
return config;
},
(error) => Promise.reject(error),
);

api.interceptors.response.use(
(response) => response, // 성공 응답은 그대로 반환
async (error) => {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true; // 재요청 플래그를 설정하여 무한 루프 방지
try {
const data = await reIssuedToken(); // 토큰 재발급 함수 호출
// 재발급 받은 토큰으로 요청 헤더 설정
api.defaults.headers.common.Authorization = `Bearer ${data.data.access_token}`;
originalRequest.headers.Authorization = `Bearer ${data.data.access_token}`;
if (accessToken !== undefined) {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true; // 재요청 플래그를 설정하여 무한 루프 방지
try {
const data = await reIssuedToken(); // 토큰 재발급 함수 호출
// 재발급 받은 토큰으로 요청 헤더 설정
api.defaults.headers.common.Authorization = `Bearer ${data.data.access_token}`;
originalRequest.headers.Authorization = `Bearer ${data.data.access_token}`;

return api(originalRequest); // 원래 요청 재시도
} catch (refreshError) {
console.error('Failed to refresh token:', refreshError);
return Promise.reject(refreshError);
return api(originalRequest); // 원래 요청 재시도
} catch (refreshError) {
return Promise.reject(refreshError);
}
}
}

return Promise.reject(error);
return Promise.reject(error);
}
},
);

Expand All @@ -72,8 +81,35 @@ export { api };
export const formApi = axios.create({
withCredentials: true,
baseURL: BASE_URL,
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `Bearer ${accessToken}`,
},
});

formApi.interceptors.request.use(
(config) => {
const token = getCookie('accessToken');
config.headers.Authorization = `Bearer ${token}`;
return config;
},
(error) => Promise.reject(error),
);

formApi.interceptors.response.use(
(response) => response,
async (error) => {
if (accessToken !== undefined) {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true;
try {
const data = await reIssuedToken();
formApi.defaults.headers.common.Authorization = `Bearer ${data.data.access_token}`;
originalRequest.headers.Authorization = `Bearer ${data.data.access_token}`;

return formApi(originalRequest);
} catch (refreshError) {
return Promise.reject(refreshError);
}
}
return Promise.reject(error);
}
},
);
19 changes: 19 additions & 0 deletions src/api/chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { api } from './axios.config.ts';

export const deleteChat = async (chatId: number) => {
try {
const response = await api.delete(`chattings/rooms/${chatId}`);
return response.data;
} catch (error) {
throw new Error('chat delete api request error : ', error || '');
}
};

export const getChats = async (meetingId: number) => {
try {
const response = await api.get(`/chats/${meetingId}`);
return response.data.data;
} catch (error) {
throw new Error('chat get api request error : ', error || '');
}
};
23 changes: 0 additions & 23 deletions src/api/check.ts

This file was deleted.

10 changes: 3 additions & 7 deletions src/api/kakao.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/* eslint-disable import/prefer-default-export */
/* eslint-disable consistent-return */
/* eslint-disable no-console */
import axios from 'axios';

export async function searchAddress(
export default async function searchAddress(
keyword: string,
lat: number,
lng: number,
page: number,
size: number,
) {
if (!keyword) {
return;
return null;
}
try {
const response = await axios.get(
Expand All @@ -30,9 +27,8 @@ export async function searchAddress(
},
},
);
console.log('searchAddress response : ', response.data);
return response.data;
} catch (error) {
console.error('searchAddress error : ', error);
throw new Error('kakao search address api request error : ', error || '');
}
}
Loading
Loading