Skip to content

Commit

Permalink
(Team-Coverflow#285)bugfix: 약관 동의 페이지 코드 받는 로직 수정중입니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJayleee committed May 11, 2024
1 parent 06086b7 commit 973a416
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/pages/termsPage/termsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { showErrorToast, showSuccessToast } from '../../ui/toast/toast.tsx';
import { initializeSSE } from '../../global/utils/eventApiUtils.js';
import { useQueryClient } from '@tanstack/react-query';
import { useDispatch } from 'react-redux';
import {setTokens} from '../../../store/actions/authActions';

interface LocationState {
code?: string;
code: string;
}

interface TermsAgreement {
Expand All @@ -35,8 +36,8 @@ export default function TermsPage() {
const location = useLocation();
const queryClient = useQueryClient();
const dispatch = useDispatch();
const { code } = (location.state || {}) as LocationState;

const { code } = location.state as LocationState;
console.log("코드",code)
// =========================================================== 약관 동의 확인을 위한 부분
const [allAgreed, setAllAgreed] = useState<boolean>(false);
const [termsAgreement, setTermsAgreement] = useState<TermsAgreement>({
Expand Down Expand Up @@ -105,7 +106,7 @@ export default function TermsPage() {

// =========================================================== 토큰 발급을 위한 부분

const fetchToken = async (code?: string): Promise<Headers> => {
const fetchToken = async (code: string): Promise<Headers> => {
if (!code) throw new Error('Code is required');
const response = await fetch(`${BASE_URL}/api/auth/token?code=${code}`, {
method: 'GET',
Expand Down Expand Up @@ -139,6 +140,7 @@ export default function TermsPage() {

localStorage.setItem(ACCESS_TOKEN, accessToken);
localStorage.setItem(REFRESH_TOKEN, refreshToken);
dispatch(setTokens(accessToken, refreshToken));
navigate('/login/member-info');
showSuccessToast('회원 가입을 축하드립니다!');
initializeSSE(queryClient, dispatch);
Expand Down

0 comments on commit 973a416

Please sign in to comment.