Skip to content

Commit

Permalink
Merge pull request #1563 from 42organization/Bug/#1551-bug-agenda
Browse files Browse the repository at this point in the history
[Fix] accessToken api 호출 url 변경 #1551
  • Loading branch information
irenee-14 authored Sep 9, 2024
2 parents ab746a4 + ee371ed commit fddd491
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion hooks/agenda/useFetchGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const useFetchGet = <T>({ url, isReady = true, params }: FetchGetProps) => {
}, [url, isReady, params]);

useEffect(() => {
if (url) {
if (url && isReady) {
getData(); // 조건에 맞을 때만 getData 호출
}
}, [url, isReady, JSON.stringify(params)]);
Expand Down
6 changes: 3 additions & 3 deletions hooks/useAxiosAgendaError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AxiosError, AxiosResponse } from 'axios';
import Cookies from 'js-cookie';
import { useEffect, useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { instanceInAgenda } from 'utils/axios';
import { instanceInAgenda, instance } from 'utils/axios';
import { agendaErrorState } from 'utils/recoil/agendaError';
import { loginState } from 'utils/recoil/login';

Expand All @@ -17,7 +17,7 @@ export default function useAxiosAgendaError() {
return;
}
try {
const res = await instanceInAgenda.post(
const res = await instance.post(
`/pingpong/users/accesstoken?refreshToken=${refreshToken}`
);
localStorage.setItem('42gg-token', res.data.accessToken);
Expand All @@ -42,7 +42,7 @@ export default function useAxiosAgendaError() {
if (!isRecalling) {
setIsRecalling(true);
try {
const res = await instanceInAgenda.post(
const res = await instance.post(
`/pingpong/users/accesstoken?refreshToken=${refreshToken}`
);
localStorage.setItem('42gg-token', res.data.accessToken);
Expand Down
17 changes: 4 additions & 13 deletions pages/agenda/profile/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const AgendaProfile = () => {
const [isIntraId, setIsIntraId] = useState<boolean>(false); // 인트라 아이디가 42에 있는지 확인
const [isAgendaId, setIsAgendaId] = useState<boolean>(false); // 인트라 아이디가 agenda에 있는지 확인
const [activeTab, setActiveTab] = useState('current'); // 현재 활성화된 탭 상태 관리
const [agendaProfileData, setAgendaProfileData] =
useState<AgendaProfileDataProps | null>(null); // agendaProfileData 상태 추가

/** API GET */
// GET: intraData (42 인트라 데이터 가져오기)
Expand All @@ -36,7 +34,7 @@ const AgendaProfile = () => {
isReady: Boolean(queryIntraId),
});
// GET: agendaProfileData (GG 아젠다 유저 데이터 가져오기)
const { data: fetchedAgendaProfileData, getData: getAgendaProfileData } =
const { data: agendaProfileData, getData: getAgendaProfileData } =
useFetchGet<AgendaProfileDataProps>({
url: `/profile/${queryIntraId}`,
isReady: isIntraId,
Expand Down Expand Up @@ -80,20 +78,13 @@ const AgendaProfile = () => {
// 2. intraData가 있으면 인트라 아이디가 42에 있다는 뜻이므로 isIntraId = true
setIsIntraId(!!intraData);
// 3. agendaProfileData가 있으면 아젠다에 등록된 사용자이므로 isAgendaId = true
setIsAgendaId(!!fetchedAgendaProfileData);
if (isAgendaId) {
setAgendaProfileData(fetchedAgendaProfileData);
} else {
setAgendaProfileData(null); // fetchedAgendaProfileData가 없을 때 초기화
}
setIsAgendaId(!!agendaProfileData);
};
updateProfileStatus();
}, [queryIntraId, intraData, fetchedAgendaProfileData]);

useEffect(() => {
setIsIntraId(false);
setIsAgendaId(false);
}, [queryIntraId]);
updateProfileStatus();
}, [queryIntraId, intraData, agendaProfileData]);

/** UI Rendering */
if (!queryIntraId || !myIntraId) {
Expand Down

0 comments on commit fddd491

Please sign in to comment.