Skip to content

Commit

Permalink
feat: /make/snowball loading창 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
esthel7 committed Dec 9, 2023
1 parent c821303 commit 720d84b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions front/src/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Main = () => {
const { setMessageList } = useContext(MessageListContext);
const leftArrowRef = useRef<HTMLImageElement>(null);
const rightArrowRef = useRef<HTMLImageElement>(null);
const [isLoading, setLoading] = useState(false);
const [isLoading, setIsLoading] = useState(false);

const delayButton = () => {
if (leftArrowRef.current && rightArrowRef.current) {
Expand Down Expand Up @@ -124,7 +124,7 @@ const Main = () => {
.message_list as Array<Message>;
setSnowBallData(resSnowballData);
setMessageList(messageList);
setLoading(true);
setIsLoading(true);

if (
userData.nickname === null ||
Expand Down
48 changes: 28 additions & 20 deletions front/src/pages/Make/Snowball/Snowball.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';
import axios from 'axios';
import { theme } from '@utils';
import { Loading, theme } from '@utils';
import { SnowGlobeCanvas, Button } from '@components';
import { MainDeco } from './MainDeco';
import { SnowBallContext } from '@pages/Visit/SnowBallProvider';
Expand Down Expand Up @@ -55,6 +55,7 @@ const Snowball = () => {
const navigate = useNavigate();
const [nickname, setNickname] = useState('김부캠');
const [make, setMake] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const { setUserData, snowBallData } = useContext(SnowBallContext);

window.history.pushState({}, '', '/main');
Expand All @@ -68,6 +69,7 @@ const Snowball = () => {
.then(res => {
if (res.status === 200) {
const userData = res.data.user as UserData;
setIsLoading(true);
setUserData(userData);
setNickname(userData.nickname);
} else {
Expand All @@ -82,29 +84,35 @@ const Snowball = () => {

return (
<>
{make ? (
<MainDeco set={setMake} />
{!isLoading ? (
<Loading />
) : (
<>
<SnowGlobeCanvas snowBallData={snowBallData} />
<StyledHeader>
<StyledName>{nickname}</StyledName>&nbsp;님
<StyledWelcome>환영합니다 :&#41;</StyledWelcome>
</StyledHeader>
{make ? (
<MainDeco set={setMake} />
) : (
<>
<SnowGlobeCanvas snowBallData={snowBallData} />
<StyledHeader>
<StyledName>{nickname}</StyledName>&nbsp;님
<StyledWelcome>환영합니다 :&#41;</StyledWelcome>
</StyledHeader>

<StyledBottom>
<StyledBall>스노우볼</StyledBall>은 소중한 마음을 주고 받는
<br />
예쁜 선물 상자가 될 거예요.
</StyledBottom>
<StyledBottom>
<StyledBall>스노우볼</StyledBall>은 소중한 마음을 주고 받는
<br />
예쁜 선물 상자가 될 거예요.
</StyledBottom>

<StyledButtonBox>
<Button
text={'스노우볼 만들기'}
color={theme.colors['--primary-red-primary']}
view={[make, setMake]}
/>
</StyledButtonBox>
<StyledButtonBox>
<Button
text={'스노우볼 만들기'}
color={theme.colors['--primary-red-primary']}
view={[make, setMake]}
/>
</StyledButtonBox>
</>
)}
</>
)}
</>
Expand Down

0 comments on commit 720d84b

Please sign in to comment.