Skip to content

Commit

Permalink
Merge pull request #179 from Team-Lecue/feature/Splash
Browse files Browse the repository at this point in the history
Merge Feature/splash into develop
  • Loading branch information
Arooming authored Jan 18, 2024
2 parents 5e23f8e + fe12cab commit 48b0c20
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Splash/api/getNoteNum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { api } from './../../libs/api';
const getNoteNum = async () => {
const { data } = await api.get('/api/common/splash');
return data;
};

export default getNoteNum;
7 changes: 4 additions & 3 deletions src/Splash/component/Body/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import Lottie from 'lottie-react';

import LottieImg from '../../../assets/lottie/lottie.json';
import useGetNoteNum from '../../hook/useGetNoteNum';
import * as S from './Body.style';

function Body() {
const noteNum = 30;

const { data } = useGetNoteNum();
return (
<S.BodyWrapper>
<S.LottieWrapper>
<Lottie animationData={LottieImg} />
</S.LottieWrapper>

<S.TextWrapper>
<S.Text>지금까지 {noteNum}개의</S.Text>
<S.Text>지금까지 {data && data.data.noteNum}개의</S.Text>
<S.Text>포스트잇이 붙여졌어요!</S.Text>
</S.TextWrapper>
</S.BodyWrapper>
Expand Down
17 changes: 17 additions & 0 deletions src/Splash/hook/useGetNoteNum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useQuery } from 'react-query';
import { useNavigate } from 'react-router-dom';

import getNoteNum from '../api/getNoteNum';

const useGetNoteNum = () => {
const navigate = useNavigate();
const { isLoading, data } = useQuery({
queryKey: ['get-note-num'],
queryFn: () => getNoteNum(),
onError: () => navigate('/error'),
});

return { isLoading, data };
};

export default useGetNoteNum;
5 changes: 5 additions & 0 deletions src/Splash/page/SplashPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { useEffect } from 'react';

import LoadingPage from '../../../components/common/LoadingPage';
import Body from '../../component/Body';
import Bottom from '../../component/Bottom';
import Header from '../../component/Header';
import useGetNoteNum from '../../hook/useGetNoteNum';
import * as S from './SplashPage.style';

export interface StepProps {
handleStep: (newStep: number) => void;
}

function SplashPage({ handleStep }: StepProps) {
const { isLoading } = useGetNoteNum();

useEffect(() => {
handleStep(0);
}, []);

return (
<S.Wrapper>
{isLoading && <LoadingPage />}
<Header />
<Body />
<Bottom handleStep={handleStep} />
Expand Down

0 comments on commit 48b0c20

Please sign in to comment.