File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed
components/admin/previewComponent/noticePreview Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ export const getNotice = async (params: NoticeSearch) => {
2929 }
3030} ;
3131
32+ export const getNoticePreview = async ( ) => {
33+ try {
34+ const response = await httpClient . get < ApiNotice > ( `/notice` ) ;
35+
36+ return response . data . data ;
37+ } catch ( e ) {
38+ console . error ( e ) ;
39+ throw e ;
40+ }
41+ } ;
42+
3243export const getNoticeDetail = async ( id : string ) => {
3344 try {
3445 const response = await httpClient . get < ApiNoticeDetail > ( `/notice/${ id } ` ) ;
Original file line number Diff line number Diff line change 11import * as S from './NoticePreview.styled' ;
2- import { useGetNotice } from '../../../../hooks/user/useGetNotice' ;
32import line from '../../../../assets/line.svg' ;
43import { Spinner } from '../../../common/loadingSpinner/LoadingSpinner.styled' ;
4+ import { useGetNoticePreview } from '../../../../hooks/admin/useGetAllNoticePreview' ;
55
66const NoticePreview = ( ) => {
7- const { noticeData, isLoading, isFetching } = useGetNotice ( {
8- keyword : '' ,
9- page : 1 ,
10- } ) ;
7+ const { noticeData, isLoading, isFetching } = useGetNoticePreview ( ) ;
118
129 if ( isLoading || isFetching ) {
1310 return (
@@ -17,13 +14,13 @@ const NoticePreview = () => {
1714 ) ;
1815 }
1916
20- if ( ! noticeData ?. notices || noticeData . notices . length === 0 ) {
17+ if ( ! noticeData ) {
2118 return < S . Container > 공지사힝이 없습니다.</ S . Container > ;
2219 }
2320
2421 return (
2522 < S . Container >
26- { noticeData . notices . map ( ( notice ) => (
23+ { noticeData . map ( ( notice ) => (
2724 < S . Wrapper key = { notice . id } >
2825 < S . Dot src = { line } />
2926 < S . NoticeTitle > { notice . title } </ S . NoticeTitle >
Original file line number Diff line number Diff line change 1+ import { useQuery } from '@tanstack/react-query' ;
2+ import { CustomerService } from '../queries/keys' ;
3+ import { getNoticePreview } from '../../api/customerService.api' ;
4+
5+ export const useGetNoticePreview = ( ) => {
6+ const {
7+ data : noticeData ,
8+ isLoading,
9+ isFetching,
10+ } = useQuery ( {
11+ queryKey : [ CustomerService . noticePreview ] ,
12+ queryFn : ( ) => getNoticePreview ( ) ,
13+ select : ( notice ) => notice . notices . slice ( 0 , 5 ) ,
14+ staleTime : Infinity ,
15+ gcTime : Infinity ,
16+ } ) ;
17+
18+ return { noticeData, isLoading, isFetching } ;
19+ } ;
You can’t perform that action at this time.
0 commit comments