Skip to content

Commit

Permalink
Merge pull request #194 from sullog-official/fix/home-slider-style
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinho1011 authored Aug 2, 2023
2 parents f80dd79 + e125230 commit 57064c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 46 deletions.
13 changes: 7 additions & 6 deletions src/features/home/components/Slider/Slider.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
.slider {
position: absolute;
z-index: themes.$modal;
bottom: 120px;
bottom: 160px;
width: 100%;
padding-left: 20px;
}

.slide-container {
display: flex;
justify-content: center;
}

.slide {
display: flex;
flex-direction: column;
justify-content: center;
width: calc(100% - 40px);
height: auto;
margin-right: 20px;
height: 150px;
padding: 16px 22px;
border-radius: 15px;
background-color: themes.$white;
Expand All @@ -40,8 +43,6 @@
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100px;
}

.add-btn-text {
Expand Down
6 changes: 3 additions & 3 deletions src/features/home/components/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Slider = ({ items }: SliderProps) => {
<Swiper className={cx('slider')} slidesPerView="auto" centeredSlides>
{items.map((item) => {
return (
<SwiperSlide key={item.recordId}>
<SwiperSlide key={item.recordId} className={cx('slide-container')}>
<button
className={cx('slide')}
type="button"
Expand Down Expand Up @@ -54,10 +54,10 @@ const Slider = ({ items }: SliderProps) => {
);
})}
{items.length > 0 && (
<SwiperSlide className={cx('slide')}>
<SwiperSlide className={cx('slide-container')}>
<button
type="button"
className={cx('add-btn')}
className={cx('slide', 'add-btn')}
onClick={() => {
router.push('/my/records');
}}
Expand Down
38 changes: 1 addition & 37 deletions src/shared/configs/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,7 @@ let subscribers: ((accessToken: string) => Promise<void>)[] = [];
const handleUnauthorizedError = async (error: AxiosError) => {
if (error.response?.status === 401) {
try {
if (subscribers.length > 3) {
throw new Error('exceed retry limit count');
}

// 새 액세스 토큰을 얻은 후 원래 요청을 다시 시도하기 위한 새 promise 만들기
const retryOriginalRequest = new Promise<AxiosResponse>(
(resolve, reject) => {
// 새 액세스 토큰을 기다리면서 원래 요청을 다시 시도하기 위해 subscriber 추가
subscribers.push(async (accessToken: string) => {
try {
if (error.config) {
error.config.headers['authorization'] = `Bearer ${accessToken}`;
resolve(instance(error.config));
}
} catch (err) {
reject(err);
}
});
}
);

if (!isFetchingAccessToken) {
isFetchingAccessToken = true;
// FIXME: 브라우저에서는 쿠키 세팅이 안될 것 같은데
await refreshAccessToken();
isFetchingAccessToken = false;

const accessToken = getAccessToken()!;
// 새 액세스 토큰을 기다리는 모든 구독자를 호출하고 새 토큰 값을 전달
subscribers.forEach((callback) => callback(accessToken));

// 구독자 배열 지우기
subscribers = [];
}

// 새 액세스 토큰을 가져 온 후 원래 요청을 다시 시도하기 위한 프로미스 반환
return await retryOriginalRequest;
throw new Error('exceed retry limit count');
} catch (error) {
// 새 액세스 토큰을 가져 오는 동안 오류가 발생하면 로그인 페이지로 리디렉션
if (!isServer()) {
Expand Down

0 comments on commit 57064c6

Please sign in to comment.