Skip to content

Commit

Permalink
✨ feat : dev merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ewinkite committed Jan 19, 2024
2 parents 43a200e + 7f557d6 commit f0cc8e0
Show file tree
Hide file tree
Showing 91 changed files with 1,696 additions and 495 deletions.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ body:
attributes:
value: |
CATCHROOM ISSUE TEMPLATE입니다!
feat : ✨ 기능 추가
fix : 🐛 버그 수정
test : 🧪 테스트 코드 작성
docs : 📚 문서 추가 및 수정
refactor : ♻️ 코드 리팩토링
chore : 📦 기타 변경사항 (빌드 스크립트 수정 등)
style : 🎨 스타일 변경
- type: textarea
id: title
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "허스키가 돌아갑니다. 🐶"

npx lint-staged
6 changes: 6 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "허스키가 돌아갑니다. 🐶"

npm run lint
9 changes: 9 additions & 0 deletions api/admin/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 숙소 정보를 등록하는 API

import { getCurrentUrl } from '@/utils/get-current-url';

// eslint-disable-next-line
export const fetchMypageSelling = async (body: any) => {
const response = await fetch(`/api/v1/admin/product`, {
Expand Down Expand Up @@ -81,3 +83,10 @@ export const fetchEnrollSellingData = async (body: any) => {
const data = await response.json();
return data.data;
};

export const fetchEnrollSellingData2 = async () => {
const url = getCurrentUrl();
const data = await fetch(`${url}/api/v1/hello/name`);
const result = await data.json();
return result;
};
27 changes: 18 additions & 9 deletions api/mypage/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import nookies from 'nookies';
// import { apiClient } from '../user/apiClient';

const accessToken = nookies.get(null)['accessToken'];

//6. 로그아웃
export const logout = async (accessToken: string) => {
//이 요청 성공시, 쿠키의 access/refresh token 모두 삭제하기
// export const logout = async () => {
// try {
// const res = await apiClient.post(`/v1/mypage/logout`);
// return res;
// console.log('로그아웃 눌렀음(api호출)');
// } catch (error) {
// console.error(error);
// throw error;
// }
// };

export const logout = async () => {
console.log(accessToken);
const res = await fetch(
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/mypage/logout`,
{
Expand All @@ -13,16 +28,10 @@ export const logout = async (accessToken: string) => {
},
},
);

const data = await res.json();
if (data.code === 1012) {
//성공 -> alert띄워주기
return data;
} else if (data.code === 1005) {
//중복 -> 에러문구 띄워주기
console.log(data.message);
}
return data;
};
//응답코드 2000일때 쿠키 다 지우기

// 프로필 수정 put*
export const editProfile = async () => {
Expand Down
58 changes: 17 additions & 41 deletions api/user/api.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,31 @@
import nookies from 'nookies';

//NEXT_PUBLIC_LOCAL_URL -> NEXT_PUBLIC_SERVER_URL로 바꾸기

//1. 이메일 중복체크
export const emailCheck = async (email: string) => {
const res = await fetch(
`${process.env.NEXT_PUBLIC_LOCAL_URL}/v1/user/emailcheck?email=${email}`,
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/user/email/check?email=${email}`,
{
method: 'GET',
headers: { Accept: 'application/json' },
},
);

const data = await res.json();
if (data.code === 1012) {
return data;
} else if (data.code === 1005) {
console.log(data.message);
}
return data;
};

//2. 닉네임 중복체크
export const nicknameCheck = async (nickname: string) => {
const res = await fetch(
`${process.env.NEXT_PUBLIC_LOCAL_URL}/v1/user/nicknamecheck?nickname=${nickname}`,
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/user/nickname/check?nickname=${nickname}`,
{
method: 'GET',
headers: { Accept: 'application/json' },
},
);

const data = await res.json();
if (data.code === 1010) {
//성공 -> alert띄워주기
return data;
} else if (data.code === 1011) {
//중복 -> 에러문구 띄워주기
console.log(data.message);
}
return data;
};

//3. 회원가입
Expand All @@ -49,7 +37,7 @@ export const signUp = async (
name: string,
) => {
const res = await fetch(
`${process.env.NEXT_PUBLIC_LOCAL_URL}/user/register`,
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/user/register`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand All @@ -58,55 +46,43 @@ export const signUp = async (
);

const data = await res.json();
if (data.code === 1000) {
return data;
} else if (data.code === 1001 || 1002 || 1003 || 1004) {
console.log(data.message);
}
return data;
};

// 4. 로그인
export const login = async (email: string, password: string) => {
const res = await fetch(`${process.env.NEXT_PUBLIC_LOCAL_URL}/user/login`, {
return fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/user/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
}).then((data) => {
return data.json();
});

const data = await res.json();
if (data.code === 1006) {
return data;
} else if (data.code === 1007 || 1008) {
console.log(data.message);
}
};

// 5. 리프레쉬 토큰으로 액세스 토큰 요청
// 5. 액세스 토큰 재발급 -> apiClient 사용할거면 필요 x, 일단 테스트용
export const getNewToken = async () => {
const refreshToken = nookies.get(null)['refresh_token'];
const refreshToken = nookies.get(null)['refreshToken'];

const res = await fetch(
`${process.env.NEXT_PUBLIC_LOCAL_URL}/v1/user/accesstoken`,
`${process.env.NEXT_PUBLIC_SERVER_URL}/v1/user/accesstoken`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${refreshToken}`,
},
body: JSON.stringify({ refreshToken }),
},
);

const data = await res.json();
if (data.code === 1013) {
//성공
return data;
} else if (data.code === 5000) {
//에러
console.log(data.message);
if (data.accessToken) {
nookies.set(null, 'accessToken', data.accessToken, {
path: '/',
});
}
return data;
};

// etc) 소셜로그인 : 카카오 인증코드 받기-> .env.local다시 설정하기
// export const kakaoUrl = `https://kauth.kakao.com/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_KAKAO_KEY}\
// &redirect_uri=${process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URL}&response_type=code`;
55 changes: 55 additions & 0 deletions api/user/apiClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import axios from 'axios';
import nookies from 'nookies';

export const apiClient = axios.create({
baseURL: `${process.env.NEXT_PUBLIC_SERVER_URL}`,
});

apiClient.interceptors.request.use(
(config) => {
const accessToken = nookies.get(null)['accessToken'];
if (accessToken) {
config.headers['Authorization'] = `Bearer ${accessToken}`;
}
return config;
},
(error) => Promise.reject(error),
);

apiClient.interceptors.response.use(
(response) => {
return response;
},
async (error) => {
if (
error.response.status === 401 ||
error.response.status === 5000 ||
error.response.status === 5001
) {
const refreshToken = nookies.get(null)['refreshToken'];
const res = await apiClient.post(
'/v1/user/accesstoken',
{},
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${refreshToken}`,
},
},
);

const accessToken = res.data.accessToken;
if (accessToken) {
nookies.set(null, 'accessToken', accessToken, {
path: '/',
});

// 재시도
error.config.headers['Authorization'] = `Bearer ${accessToken}`;
return apiClient.request(error.config);
}
}

return Promise.reject(error);
},
);
12 changes: 12 additions & 0 deletions api/user/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useMutation } from '@tanstack/react-query';
import { nicknameCheck } from './api';

// 닉네임 중복 체크하는 커스텀 훅
export const useCheckNickname = () => {
const mutation = useMutation({
mutationKey: ['nicknameCheck'],
mutationFn: (nickname: string) => nicknameCheck(nickname),
});

return mutation;
};
42 changes: 22 additions & 20 deletions app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,28 @@ const page = async () => {
<ReviewContainer />
<Footer />

<div className="fixed bottom-24 left-2/3 z-30">
<BottomSheets
buttonSelect="sale"
title="숙박권 판매"
innerTitle="판매할 숙박권을 선택해주세요."
>
{isSuccess ? (
<SaleItems />
) : (
<div className="flex flex-col items-center gap-2 max-w-[271px]">
<p className="text-t2 font-semibold">
판매 가능한 숙박권이 없습니다
</p>
<p className="text-t3 text-text-sub text-center">
오늘 체크인이 가능하고 무료 취소가 불가한 숙박권만 판매할 수
있어요.
</p>
</div>
)}
</BottomSheets>
<div className="fixed bottom-16 z-30 max-w-[480px] w-full">
<div className="absolute right-8 bottom-8">
<BottomSheets
buttonSelect="sale"
title="숙박권 판매"
innerTitle="판매할 숙박권을 선택해주세요."
>
{isSuccess ? (
<SaleItems />
) : (
<div className="flex flex-col items-center gap-2 max-w-[271px]">
<p className="text-t2 font-semibold">
판매 가능한 숙박권이 없습니다
</p>
<p className="text-t3 text-text-sub text-center">
오늘 체크인이 가능하고 무료 취소가 불가한 숙박권만 판매할 수
있어요.
</p>
</div>
)}
</BottomSheets>
</div>
</div>

<BottomNav />
Expand Down
2 changes: 2 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import RootTemplate from '@/components/common/layoutTemplate/RootTemplate';
import Script from 'next/script';
import ToastAlertComponent from '@/components/common/toastAlert';

// import { LocalizationProvider } from '@mui/x-date-pickers';
// import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
Expand Down
5 changes: 0 additions & 5 deletions app/mypage/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import MyPageHeader from '@/components/mypage/header';
import React, { ReactNode } from 'react';

// showBackButton = false,
// showCloseButton = false,
// showMoreButton = false,
// showBorder = false,

const MypageLayout = ({ children }: { children: ReactNode }) => {
return (
<div className="w-full">
Expand Down
7 changes: 3 additions & 4 deletions app/mypage/dashboard/privacy/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React from 'react';

const page = () => {
return (
<div className="w-full px-5 flex flex-col gap-5 h-[calc(100vh-100px)] overflow-x-scroll">
{/* 추후 변경 예정 */}
<div className="w-full p-5 flex flex-col gap-5 h-[calc(100vh-100px)] overflow-x-scroll">
<p>
주식회사 캐치룸(이하 ‘회사’)은 고객의 개인정보보호를 위해 최선의 노력을
주식회사 캐치룸이하 ‘회사’은 고객의 개인정보보호를 위해 최선의 노력을
다하고 있으며, 「개인정보보호법」 관련조항과 「정보통신망 이용촉진 및
정보보호에 관한 법률」의 기준에 따라 ‘개인정보처리방침’을 수립하여 이를
준수하고 있습니다. 회사는 개인정보 처리방침을 통해 고객이 제공한
Expand All @@ -17,7 +16,7 @@ const page = () => {
및 관련 서비스 제공 등의 업무처리를 위하여 최소한의 필수정보를 수집하고
있으며, 수집한 모든 개인정보는 별도의 동의가 없는 한 개인정보의 수집 및
이용 목적에서 고지한 이외의 다른 목적으로 사용되지 않습니다. 회사는
수집한 개인정보를 다음의 목적을 위해 활용합니다. 1) 회원 서비스 제공 :
수집한 개인정보를 다음의 목적을 위해 활용합니다. 1 회원 서비스 제공 :
회원 가입, 본인 인증, 개인 식별, 연령 제한 서비스의 제공, 본인 의사
확인, 가입 여부 확인, 재가입 제한, 문의사항 및 분쟁 조정기록, 회원 탈퇴
대해 ‘동의함’ 또는 ‘동의하지 않음’을 클릭할 수 있는 절차를 마련하여
Expand Down
Loading

0 comments on commit f0cc8e0

Please sign in to comment.