Skip to content

Commit 1414323

Browse files
authored
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 적용
1 parent 1d48cbf commit 1414323

File tree

13 files changed

+104
-13
lines changed

13 files changed

+104
-13
lines changed

.github/workflows/devDeploy.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy
33
on:
44
workflow_dispatch:
55
branches:
6-
- 'dev'
6+
- 'dev'
77

88
jobs:
99
ci:
@@ -15,6 +15,13 @@ jobs:
1515
NEXT_PUBLIC_GA_ID: ${{ secrets.GA_ID }}
1616
NEXT_PUBLIC_HJID: ${{ secrets.HOTJAR_HJID }}
1717
NEXT_PUBLIC_HJSV: ${{ secrets.HOTJAR_HJSV }}
18+
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
19+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }}
20+
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
21+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
22+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}
23+
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.FIREBASE_MESSAGING_APP_ID }}
24+
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MESSAGING_MEASUREMENT_ID }}
1825

1926
strategy:
2027
matrix:

src/app/template.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CategoryBottomSheet } from './toks-main/components/CategoryBottomSheet'
99
export default function Template({ children }: StrictPropsWithChildren) {
1010
// TODO: useAuth hook 구현
1111
// TODO: useLogin Modal hook 구현
12+
// TODO: GlobalPortal 제거
1213
const pathName = usePathname();
1314

1415
return (

src/app/toks-main/components/CardList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useQuizListInfinityQuery } from '@/queries/useQuizListInfinityQuery';
99

1010
import { QuizNotice } from './QuizNotice';
1111
import { SkeletonCardList } from './SkeletonCard';
12-
import { CARD_LIST_QUERY_DEFAULT } from '../constants';
12+
import { CARD_LIST_QUERY_DEFAULT } from '../constants/constants';
1313

1414
export const CardList = () => {
1515
const router = useRouter();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const SkeletonSlider = () => {
2+
return (
3+
<div className="aspect-w-3 aspect-h-1 z-0 h-130px w-full animate-pulse rounded-12px bg-gray-110"></div>
4+
);
5+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
3+
import { NoticeSlider } from '@/common';
4+
5+
import { SkeletonSlider } from './SkeletonSlider';
6+
import { QUERY_KEYS } from '../../constants/queryKeys';
7+
import { getNotices } from '../../remotes/notice';
8+
9+
export const MainPageSlider = () => {
10+
const {
11+
data: notices,
12+
isLoading,
13+
isSuccess,
14+
} = useQuery({
15+
queryKey: [QUERY_KEYS.GET_NOTICES],
16+
queryFn: async () => {
17+
try {
18+
return await getNotices();
19+
} catch (err) {
20+
throw new Error('배너를 가져오는데 실패했습니다.');
21+
}
22+
},
23+
});
24+
25+
if (isLoading) {
26+
return <SkeletonSlider />;
27+
}
28+
29+
if (isSuccess) {
30+
const imageInfo = notices.bottomBanners.map((el) => {
31+
return { imageUrl: el.imageUrl, landingUrl: el.landingUrl };
32+
});
33+
return <NoticeSlider images={imageInfo} />;
34+
}
35+
36+
return null;
37+
};
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const QUERY_KEYS = {
2+
GET_NOTICES: () => ['GET_NOTICE'],
3+
} as const;

src/app/toks-main/models/notice.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
interface NoticeInfo {
2+
id: number;
3+
title: string;
4+
seq: number;
5+
imageUrl: string;
6+
landingUrl: string;
7+
isActive: boolean;
8+
}
9+
10+
export interface NoticeResponse {
11+
bottomBanners: NoticeInfo[];
12+
}

src/app/toks-main/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isVisibleFloatingButtonBottomSheetAtom } from '@/store';
88

99
import { CardList } from './components/CardList';
1010
import { MainPageBottomSheet } from './components/MainPageBottomSheet';
11+
import { MainPageSlider } from './components/MainPageSlider';
1112

1213
function ToksMainPage() {
1314
const { getSavedToastInfo, clearSavedToast } = useToast();
@@ -32,6 +33,8 @@ function ToksMainPage() {
3233
title={toastData.title}
3334
/>
3435
)}
36+
<MainPageSlider />
37+
<div className="h-24px" />
3538
<CardList />
3639

3740
<FloatingButton
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { http } from '@/common';
2+
3+
import { NoticeResponse } from '../models/notice';
4+
5+
export const getNotices = async () => {
6+
return await http.get<NoticeResponse>('api/v1/bottom-banners');
7+
};

0 commit comments

Comments
 (0)