Skip to content

Commit

Permalink
Merge pull request #164 from softeerbootcamp4th/fix/#154/code
Browse files Browse the repository at this point in the history
Fix/#154/code
  • Loading branch information
subsub-e authored Aug 22, 2024
2 parents 9e5d983 + 8b8542f commit 0af54a5
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 256 deletions.
6 changes: 3 additions & 3 deletions admin/src/pages/UploadPrize/UploadPrize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function UploadPrize() {
unsavedChangesModal,
handleConfirmNavigation,
handleCancelNavigation,
} = useNavigationBlocker(modified, () => {
setModified(false);
} = useNavigationBlocker(selectedFile, () => {
setSelectedFile(null);
});

useEffect(() => {
Expand Down Expand Up @@ -93,7 +93,7 @@ function UploadPrize() {
setErrorMessage('파일 업로드 중 오류가 발생했습니다.');
} finally {
setIsLoading(false);
setModified(false);
setSelectedFile(null);
}
};

Expand Down
7 changes: 3 additions & 4 deletions admin/src/pages/UploadReward/UploadReward.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function UploadReward() {
const [processMessage, setProcessMessage] = useState(
'폴더 안에 들어가서 파일만을 선택하여 압축한 zip 파일을 업로드해주세요.',
);
const [modified, setModified] = useState(false);

const totalReward = 500;
const createFormData = useFormData();
Expand All @@ -27,8 +26,8 @@ function UploadReward() {
unsavedChangesModal,
handleConfirmNavigation,
handleCancelNavigation,
} = useNavigationBlocker(modified, () => {
setModified(false);
} = useNavigationBlocker(selectedFile, () => {
setSelectedFile(null);
});

const handleClick = () => {
Expand Down Expand Up @@ -59,7 +58,7 @@ function UploadReward() {
setErrorMessage('파일 업로드 중 오류가 발생했습니다.');
} finally {
setIsLoading(false);
setModified(false);
setSelectedFile(null);
}
};

Expand Down
24 changes: 24 additions & 0 deletions service/src/components/SlideUpMotion/SlideUpMotion.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import { animationVariants } from '@/styles/FramerMotion';
import { motion } from 'framer-motion';

function SlideUpMotion({ children, delay = 0 }) {
return (
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{ duration: 0.6, ease: 'easeOut', delay }}
>
{children}
</motion.div>
);
}

SlideUpMotion.propTypes = {
children: PropTypes.node.isRequired,
delay: PropTypes.number,
};

export default SlideUpMotion;
32 changes: 32 additions & 0 deletions service/src/components/buttons/BaseButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';

function BaseButton({
value,
onClickFunc,
styles = '',
disabled = false,
bgColor,
textColor,
}) {
return (
<button
onClick={onClickFunc}
className={`${styles} ${disabled ? 'opacity-30' : 'opacity-100 hover-scale-ani'} set-center rounded-full ${bgColor} ${textColor}`}
disabled={disabled}
>
{value}
</button>
);
}

BaseButton.propTypes = {
value: PropTypes.string.isRequired,
onClickFunc: PropTypes.func.isRequired,
styles: PropTypes.string,
disabled: PropTypes.bool,
bgColor: PropTypes.string.isRequired,
textColor: PropTypes.string.isRequired,
};

export default React.memo(BaseButton);
23 changes: 7 additions & 16 deletions service/src/components/buttons/BlueButton.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import BaseButton from '@/components/buttons/BaseButton';

function BlueButton({ value, styles, onClickFunc, disabled = false }) {
function BlueButton(props) {
return (
<button
onClick={onClickFunc}
className={`${styles} ${disabled ? 'opacity-30' : 'opacity-100 hover-scale-ani'} set-center rounded-full bg-primary-blue text-neutral-white`}
>
{value}
</button>
<BaseButton
{...props}
bgColor="bg-primary-blue"
textColor="text-neutral-white"
/>
);
}

BlueButton.propTypes = {
value: PropTypes.string.isRequired,
onClickFunc: PropTypes.func.isRequired,
styles: PropTypes.string.isRequired,
disabled: PropTypes.bool,
};

//memo를 이용하여 rerender 방지
export default React.memo(BlueButton);
23 changes: 7 additions & 16 deletions service/src/components/buttons/BluePurpleButton.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import BaseButton from '@/components/buttons/BaseButton';

function BluePurpleButton({ value, onClickFunc, styles, disabled = false }) {
function BluePurpleButton(props) {
return (
<button
onClick={onClickFunc}
className={`${styles} ${disabled ? 'opacity-30' : 'opacity-100 hover-scale-ani'} set-center rounded-full bg-gradient-blue-purple text-neutral-white`}
disabled={disabled}
>
{value}
</button>
<BaseButton
{...props}
bgColor="bg-gradient-blue-purple"
textColor="text-neutral-white"
/>
);
}

BluePurpleButton.propTypes = {
value: PropTypes.string.isRequired,
onClickFunc: PropTypes.func.isRequired,
styles: PropTypes.string.isRequired,
disabled: PropTypes.bool,
};

export default React.memo(BluePurpleButton);
23 changes: 7 additions & 16 deletions service/src/components/buttons/WhiteButton.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import BaseButton from '@/components/buttons/BaseButton';

function WhiteButton({ value, onClickFunc, styles, disabled = false }) {
function WhiteButton(props) {
return (
<button
onClick={onClickFunc}
className={`${styles} ${disabled ? 'opacity-30' : 'opacity-100 hover-scale-ani'} set-center rounded-full bg-neutral-white text-neutral-black`}
disabled={disabled}
>
{value}
</button>
<BaseButton
{...props}
bgColor="bg-neutral-white"
textColor="text-neutral-black"
/>
);
}

WhiteButton.propTypes = {
value: PropTypes.string.isRequired,
onClickFunc: PropTypes.func.isRequired,
styles: PropTypes.string.isRequired,
disabled: PropTypes.bool,
};

export default React.memo(WhiteButton);
16 changes: 3 additions & 13 deletions service/src/pages/eventIntro/EventIntro.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import EventIntroMain from '@/pages/eventIntro/EventIntroMain';
import EventIntroNav from '@/pages/eventIntro/EventIntroNav';
import EventIntroRewards from '@/pages/eventIntro/EventIntroRewards';
import { animationVariants } from '@/styles/FramerMotion';
import { motion } from 'framer-motion';
import SlideUpMotion from '@/components/SlideUpMotion/SlideUpMotion';
import { Helmet } from 'react-helmet-async';

function EventIntro() {
Expand All @@ -28,18 +27,9 @@ function EventIntro() {
<EventIntroMain />
<div className="bg-gradient-lightblue-white-vertical mt-[1px]">
<EventIntroNav />
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{
duration: 0.6,
ease: 'easeOut',
delay: 0.1,
}}
>
<SlideUpMotion delay={0.1}>
<EventIntroRewards />
</motion.div>
</SlideUpMotion>
</div>
</div>
);
Expand Down
12 changes: 3 additions & 9 deletions service/src/pages/eventIntro/EventIntroMain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ import casperCarImage from '@/assets/images/casper_car_image.webp';
import arrow from '@/assets/icons/arrow.svg';
import casperCarImageShadow from '@/assets/images/casperCarImageShadow.webp';
import { Link } from 'react-router-dom';
import { animationVariants } from '@/styles/FramerMotion';
import { motion } from 'framer-motion';
import SlideUpMotion from '@/components/SlideUpMotion/SlideUpMotion';

function EventIntroMain() {
return (
<div className="bg-gradient-violetblue-cobaltblue h-[872px] pt-[151px]">
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{ duration: 0.6, ease: 'easeOut' }}
>
<SlideUpMotion>
<div className="flex justify-between">
<div className="ml-3000">
<div className="inline-block px-500 py-200 bg-primary-berrypurple mb-600">
Expand Down Expand Up @@ -80,7 +74,7 @@ function EventIntroMain() {
/>
</div>
</div>
</motion.div>
</SlideUpMotion>
</div>
);
}
Expand Down
16 changes: 3 additions & 13 deletions service/src/pages/eventIntro/EventIntroNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import EventIntroNavItem from '@/pages/eventIntro/EventIntroNavItem';
import EventIntroNavData from '@/constants/eventIntro/EventIntroNavData';
import { useNavigate } from 'react-router-dom';
import { animationVariants } from '@/styles/FramerMotion';
import { motion } from 'framer-motion';
import SlideUpMotion from '@/components/SlideUpMotion/SlideUpMotion';

function EventIntroNav() {
const navigate = useNavigate();
Expand All @@ -20,18 +19,9 @@ function EventIntroNav() {
className="nav-item"
onClick={() => handleNavigation(item.section)}
>
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{
duration: 0.6,
ease: 'easeOut',
delay: 0.5 + (index * 2) / 10,
}}
>
<SlideUpMotion delay={0.5 + (index * 2) / 10}>
<EventIntroNavItem item={item} />
</motion.div>
</SlideUpMotion>
</div>
))}
</div>
Expand Down
6 changes: 2 additions & 4 deletions service/src/pages/joinEvent/CarCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ function CarCard() {
const { userInfo } = useContext(AuthContext);
const navigate = useNavigate();

const gotoWorldCup = () => {
navigate('/event/worldCup');
};
const gotoWorldCup = () => navigate('/event/worldCup');

return (
<div className="flex flex-col justify-between hover-scale-ani bg-carCard px-800 pt-700 pb-500 w-[320px] h-[417px] rounded-[30px]">
Expand All @@ -38,7 +36,7 @@ function CarCard() {
</div>
<div className={`set-center ${userInfo.car ? 'invisible' : 'visible'}`}>
<BlueButton
value="자동차 얻기 "
value="자동차 얻기"
onClickFunc={gotoWorldCup}
styles="px-800 py-400 text-detail-2-medium"
/>
Expand Down
33 changes: 9 additions & 24 deletions service/src/pages/joinEvent/JoinEventIntroMain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { AuthContext } from '@/context/authContext';
import BluePurpleButton from '@/components/buttons/BluePurpleButton';
import { useNavigate } from 'react-router-dom';
import { getScenario } from '@/api/scenario';
import { animationVariants } from '@/styles/FramerMotion';
import { motion } from 'framer-motion';
import SlideUpMotion from '@/components/SlideUpMotion/SlideUpMotion';

function JoinEventIntroMain() {
const navigate = useNavigate();
Expand All @@ -27,6 +26,7 @@ function JoinEventIntroMain() {
setScenario(commonScenario);
} catch (error) {
console.error(error);
setScenario('시나리오를 불러오는 데 실패했습니다. 다시 시도해주세요.');
}
};
getData();
Expand All @@ -49,46 +49,31 @@ function JoinEventIntroMain() {
<div className="bg-join-event-main bg-cover bg-center h-screen pt-[250px] flex flex-col">
<div className="flex gap-2000 px-3000">
<div className="space-y-1200">
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{ duration: 0.6, ease: 'easeOut' }}
>
<SlideUpMotion>
<div className="flex items-center gap-300">
<CarCard />
<div className="text-heading-1-bold text-neutral-white">+</div>
<ToolBoxCard />
</div>
</motion.div>
</SlideUpMotion>
<div
className={`text-center underline text-neutral-white text-shadow-default ${phoneNumber ? 'invisible' : 'visible'}`}
>
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{ duration: 0.5, ease: 'easeOut', delay: 1.0 }}
>
<SlideUpMotion delay={1}>
<span className="cursor-pointer" onClick={openPhoneModal}>
보유 아이템이 있다면? 전화번호 입력하고 내 아이템 개수
확인하기
</span>
</motion.div>
</SlideUpMotion>
</div>
</div>
<motion.div
initial="hidden"
animate="visible"
variants={animationVariants}
transition={{ duration: 0.6, ease: 'easeOut', delay: 0.5 }}
>
<SlideUpMotion delay={0.5}>
<div className="relative flex flex-col">
<div className="text-heading-banner-title-2 text-nowrap mb-1000">
<span className="text-gradient-blue-purple">캐스퍼 EV</span>
떠나기
</div>
<div className="w-[84px] bg-op-30-blue px-400 py-100 mb-400 text-detail-2-medium text-neutral-white">
<div className="w-max bg-op-30-blue px-400 py-100 mb-400 text-detail-2-medium text-neutral-white">
Day {day}
</div>
<div className="whitespace-pre-line h-1800 text-detail-1-regular text-neutral-black mb-1500">
Expand All @@ -111,7 +96,7 @@ function JoinEventIntroMain() {
</>
)}
</div>
</motion.div>
</SlideUpMotion>
</div>
</div>
{openPhoneInputModal && (
Expand Down
Loading

0 comments on commit 0af54a5

Please sign in to comment.