-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(toks-main): notice slider 이미지 적용 및 window history 없는 경우 home으로 라…
…우팅 (#407) * ✨ feat: notice slider 적용 * ✨ feat: window history 없는 경우 back button click시 home으로 routing * ✨ feat: deploy yml에 env 추가 * ✨ feat: change link tag to a tag * ✨ feat: add getNotice api * ♻️ refactor: notice api 및 type 분리 * ✨ feat: skeleton ui 적용
- Loading branch information
Showing
13 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/app/toks-main/components/MainPageSlider/SkeletonSlider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const SkeletonSlider = () => { | ||
return ( | ||
<div className="aspect-w-3 aspect-h-1 z-0 h-130px w-full animate-pulse rounded-12px bg-gray-110"></div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { NoticeSlider } from '@/common'; | ||
|
||
import { SkeletonSlider } from './SkeletonSlider'; | ||
import { QUERY_KEYS } from '../../constants/queryKeys'; | ||
import { getNotices } from '../../remotes/notice'; | ||
|
||
export const MainPageSlider = () => { | ||
const { | ||
data: notices, | ||
isLoading, | ||
isSuccess, | ||
} = useQuery({ | ||
queryKey: [QUERY_KEYS.GET_NOTICES], | ||
queryFn: async () => { | ||
try { | ||
return await getNotices(); | ||
} catch (err) { | ||
throw new Error('배너를 가져오는데 실패했습니다.'); | ||
} | ||
}, | ||
}); | ||
|
||
if (isLoading) { | ||
return <SkeletonSlider />; | ||
} | ||
|
||
if (isSuccess) { | ||
const imageInfo = notices.bottomBanners.map((el) => { | ||
return { imageUrl: el.imageUrl, landingUrl: el.landingUrl }; | ||
}); | ||
return <NoticeSlider images={imageInfo} />; | ||
} | ||
|
||
return null; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const QUERY_KEYS = { | ||
GET_NOTICES: () => ['GET_NOTICE'], | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
interface NoticeInfo { | ||
id: number; | ||
title: string; | ||
seq: number; | ||
imageUrl: string; | ||
landingUrl: string; | ||
isActive: boolean; | ||
} | ||
|
||
export interface NoticeResponse { | ||
bottomBanners: NoticeInfo[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { http } from '@/common'; | ||
|
||
import { NoticeResponse } from '../models/notice'; | ||
|
||
export const getNotices = async () => { | ||
return await http.get<NoticeResponse>('api/v1/bottom-banners'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters