Skip to content

Commit

Permalink
Merge pull request #72 from Hana4Team/fix/#67
Browse files Browse the repository at this point in the history
[Fix/#67] λ―Έμ…˜μ™„λ£Œ, νšŒμ›κ°€μž… 버그 μˆ˜μ •
  • Loading branch information
abcxj123 authored Jun 10, 2024
2 parents 86f57f3 + 7db3e29 commit 6263ab0
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/components/molecules/BankBookIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const BankBookIntro: FC<IProps> = ({
<p className='text-[#666666] text-lg'>{content}</p>
</div>
</div>
<img src='/public/images/λ³„λŒμ΄2.svg' alt='λ³„λŒμ΄' className='h-64' />
<img src='/images/λ³„λŒμ΄2.svg' alt='λ³„λŒμ΄' className='h-64' />
</div>
</div>
);
Expand Down
17 changes: 10 additions & 7 deletions src/components/molecules/IntroduceStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export const IntroduceStep: FC<IProps> = ({ step }) => {
</div>
<div className='flex flex-col gap-5 mb-10'>
<div>πŸ”Ήμ§€λ‚œλ‹¬ λ‚˜μ˜ μ†ŒλΉ„μŠ΅κ΄€μ„ ν™•μΈν•©λ‹ˆλ‹€.</div>
<div>πŸ”Ήμ§€λ‚œλ‹¬ μ†ŒλΉ„λ‚΄μ—­μ„ μ°Έκ³ ν•˜μ—¬ 이번 달 μ˜ˆμ‚°μ„ μ„€μ •ν•©λ‹ˆλ‹€.</div>
<div>
πŸ”Ήμ§€λ‚œλ‹¬ μ†ŒλΉ„λ‚΄μ—­μ„ μ°Έκ³ ν•˜μ—¬ 이번 달 μ˜ˆμ‚°μ„ μ„€μ •ν•˜λ©΄ 1단계 λ―Έμ…˜
성곡!.
</div>
<div>
πŸ”ΉμΉ΄ν…Œκ³ λ¦¬λ³„λ‘œ 더 μƒμ„Έν•˜κ²Œ μ˜ˆμ‚°μ„ ν™•μΈν•˜κ³  μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
</div>
Expand Down Expand Up @@ -49,9 +52,9 @@ export const IntroduceStep: FC<IProps> = ({ step }) => {
πŸ”Ήλ¨Έλ‹ˆλ°•μŠ€ 톡μž₯을 κ°œμ„€ν•˜μ—¬ 톡μž₯μͺΌκ°œκΈ°λ₯Ό 톡해 μˆ˜μž…κ³Ό μ§€μΆœμ„ ν†΅μ œν• 
수 μžˆμŠ΅λ‹ˆλ‹€.
</div>
<div>πŸ”Ήλ¨Έλ‹ˆλ°•μŠ€λ₯Ό μ‚¬μš©ν•˜λ©΄μ„œ μžμ‹ μ˜ κ³Όμ†ŒλΉ„μ§€μˆ˜λ₯Ό ν™•μΈν•΄λ³΄μ•„μš”.</div>
<div>
πŸ”Ήλ¨Έλ‹ˆλ°•μŠ€ 이용 ν•œλ‹¬ ν›„ μ§€λ‚œλ‹¬ μ†ŒλΉ„λ‚΄μ—­κ³Ό λΉ„κ΅ν•˜μ—¬ μ†ŒλΉ„κ°€ 5%이상
κ°μ†Œλ˜μ—ˆμ„ μ‹œ 2단계 성곡
πŸ”Ήν•œλ‹¬λ™μ•ˆ λ¨Έλ‹ˆλ°•μŠ€λ₯Ό 톡해 μžμ‹ μ˜ μ†ŒλΉ„λ₯Ό κ΄€λ¦¬ν•˜λ©΄ 2단계 λ―Έμ…˜ 성곡!
</div>
<div>πŸ”Ήμ„±κ³΅ν•˜λ©΄ ν•˜λ‚˜λ¨Έλ‹ˆλ₯Ό μ§€κΈ‰ν•΄λ“œλ¦½λ‹ˆλ‹€.</div>
</div>
Expand Down Expand Up @@ -100,8 +103,8 @@ export const IntroduceStep: FC<IProps> = ({ step }) => {
μžˆμŠ΅λ‹ˆλ‹€.
</div>
<div>
πŸ”Ή100일이 μ§€λ‚œ ν›„ 3단계 성곡! 50일 이상 저좕에 성곡할 μ‹œ 금리 6%
κ°€ μ§€κΈ‰λ©λ‹ˆλ‹€.
πŸ”Ή100일이 μ§€λ‚œ ν›„ 3단계 성곡! 50일 이상 저좕에 성곡할 μ‹œ μ΅œλŒ€ 금리
κ°€ μ μš©λ©λ‹ˆλ‹€.
</div>
<div>πŸ”Ήμ„±κ³΅ν•˜λ©΄ ν•˜λ‚˜λ¨Έλ‹ˆλ₯Ό μ§€κΈ‰ν•΄λ“œλ¦½λ‹ˆλ‹€.</div>
</div>
Expand Down Expand Up @@ -133,8 +136,8 @@ export const IntroduceStep: FC<IProps> = ({ step }) => {
</div>
<div>πŸ”Ήλ‘œλ“œλ§΅μ„ 톡해 μžμ‹ μ˜ ν˜„μž¬ κΈˆμ•‘μ„ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.</div>
<div>
πŸ”Ήλ§ŒκΈ°μΌμ΄ μ§€λ‚œ ν›„ 4단계 성곡! λͺ©ν‘œκΈˆμ•‘ 도달 μ‹œ 졜고 κΈˆλ¦¬κ°€
μ§€κΈ‰λ©λ‹ˆλ‹€.
πŸ”Ήλ§ŒκΈ°μΌμ΄ μ§€λ‚œ ν›„ 4단계 성곡! λͺ©ν‘œκΈˆμ•‘ 도달 μ‹œ μ΅œλŒ€ κΈˆλ¦¬κ°€
μ μš©λ©λ‹ˆλ‹€.
</div>
<div>πŸ”Ήμ„±κ³΅ν•˜λ©΄ ν•˜λ‚˜λ¨Έλ‹ˆλ₯Ό μ§€κΈ‰ν•΄λ“œλ¦½λ‹ˆλ‹€.</div>
</div>
Expand Down
14 changes: 5 additions & 9 deletions src/components/molecules/PasswordForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, ReactNode, useEffect, useRef } from 'react';
import React, { FC, ReactNode, useEffect } from 'react';

interface IProps {
title: ReactNode;
Expand All @@ -18,19 +18,16 @@ export const PasswordForm: FC<IProps> = ({
checkPwdCondition,
}) => {
useEffect(() => {
if (step === 6 || step == undefined) {
if (step === 6 || step === undefined) {
inputRef.current.forEach((input) => {
if (input) {
input.value = '';
}
});
focusFirstInput();
}
}, [step, re]);

useEffect(() => {
focusFirstInput();
}, [step, re]);

const handleInput = (
index: number,
event: React.ChangeEvent<HTMLInputElement>
Expand All @@ -46,15 +43,14 @@ export const PasswordForm: FC<IProps> = ({
}

checkPwdCondition?.();
focusFirstInput();
};

const handleKeyDown = (
index: number,
event: React.KeyboardEvent<HTMLInputElement>
) => {
if (event.key === 'Backspace') {
if (!inputRef.current[index]?.value && index >= 0) {
if (!inputRef.current[index]?.value && index > 0) {
inputRef.current[index - 1]?.focus();
}
}
Expand Down Expand Up @@ -88,7 +84,7 @@ export const PasswordForm: FC<IProps> = ({
ref={(el) => (inputRef.current[index] = el)}
onChange={(e) => handleInput(index, e)}
onKeyDown={(e) => handleKeyDown(index, e)}
onFocus={() => focusFirstInput()}
onClick={focusFirstInput}
/>
))}
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/pages/MissionMain.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { MissionStep } from '../components/molecules/MissionStep';
import Topbar from '../components/Topbar';
import { MissionStartHeader } from '../components/molecules/MissionStartHeader';
import { useQuery } from '@tanstack/react-query';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { ApiClient } from '../apis/apiClient';
import { useEffect } from 'react';

const step = [
{ title: 'λ‚΄ μ†ŒλΉ„ μŠ΅κ΄€ μ•ŒκΈ°', text: 'μ§€λ‚œ 달 λ‚˜μ˜ μ†ŒλΉ„ μŠ΅κ΄€μ„ μ•Œμ•„λ³΄μ•„μš”' },
Expand All @@ -19,6 +20,7 @@ const step = [
];

export const MissionMain = () => {
const queryClient = useQueryClient();
const { data: user, isSuccess } = useQuery({
queryKey: ['user'],
queryFn: () => {
Expand All @@ -27,6 +29,12 @@ export const MissionMain = () => {
},
});

useEffect(() => {
queryClient.invalidateQueries({
queryKey: ['user'],
});
}, []);

return (
<>
<Topbar title='μ΄μ‚¬λ―Έμ…˜' />
Expand Down
9 changes: 8 additions & 1 deletion src/pages/MyHome.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useQuery } from '@tanstack/react-query';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import React, { useEffect, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { ApiClient } from '../apis/apiClient';
import { Shopping } from '../components/organisms/Shopping';

export const MyHome = () => {
const navigate = useNavigate();
const queryClient = useQueryClient();
const { pathname } = useLocation();
const [isOpenModal, setIsModalOpen] = useState<boolean>(false);
const [visible, setVisible] = useState<boolean>(false);
Expand All @@ -28,6 +29,12 @@ export const MyHome = () => {
};
}, []);

useEffect(() => {
queryClient.invalidateQueries({
queryKey: ['home'],
});
}, []);

return (
<>
{isSuccess && (
Expand Down
32 changes: 17 additions & 15 deletions src/pages/auth/Join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,21 @@ export const Join = () => {
else setIsActive(false);
}
if (title === 'confirmPwd') {
if (confirmPwdRef.current.map((p) => p?.value).join('').length === 6)
if (confirmPwdRef.current.map((p) => p?.value).join('').length === 6) {
setIsActive(true);
else setIsActive(false);
if (
confirmPwdRef.current.map((p) => p?.value).join('') ===
inputs.password
) {
const updatedConfirmPassword = confirmPwdRef.current
.map((p) => p?.value)
.join('');
setInputs({
...inputs,
confirmPassword: updatedConfirmPassword,
});
}
} else setIsActive(false);
}
};

Expand All @@ -121,17 +133,8 @@ export const Join = () => {
};

const pwdCheck = () => {
if (
confirmPwdRef.current.map((p) => p?.value).join('') === inputs.password
) {
if (inputs.confirmPassword === inputs.password) {
setIsPwdCorrect(true);
const updatedConfirmPassword = confirmPwdRef.current
.map((p) => p?.value)
.join('');
setInputs({
...inputs,
confirmPassword: updatedConfirmPassword,
});
setIsActive(true);
return true;
} else {
Expand Down Expand Up @@ -162,8 +165,8 @@ export const Join = () => {
setIsActive(false);
}
if (step === 3 && isPhone) {
postMessage(inputs.phoneNumber);
setStep((prev) => prev + 1);
postMessage(inputs.phoneNumber);
setIsActive(false);
}
if (step === 4) {
Expand All @@ -179,8 +182,7 @@ export const Join = () => {
setIsActive(false);
}
if (step === 6) {
pwdCheck();
postJoin(inputs);
pwdCheck() && postJoin(inputs);
}
if (step === 7) {
navigate('/home');
Expand Down
104 changes: 95 additions & 9 deletions src/pages/mission3/Savings100Days.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { Calendar } from '../../components/organisms/Calendar';
import Topbar from '../../components/Topbar';
import { useNavigate } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { ApiClient } from '../../apis/apiClient';
import { differenceInDays, formatDate } from 'date-fns';
import { AlarmAnimation } from '../../components/organisms/AlarmAnimation';
import { AlertModal } from '../../components/AlertModal';

export const Savings100Days = () => {
const navigate = useNavigate();
const startDate = useRef<string>('');
const endDate = useRef<string>('');
const queryClient = useQueryClient();
const [showStepModal, setShowStepModal] = useState<boolean>(false);
const [showAlarm, setShowAlarm] = useState<boolean>(false);
const alarmMsgRef = useRef<string>('');

const { data: saving100, isSuccess } = useQuery({
queryKey: ['saving100'],
Expand All @@ -27,6 +31,67 @@ export const Savings100Days = () => {
},
});

const { data: userInfo } = useQuery({
queryKey: ['userInfo'],
queryFn: () => {
const res = ApiClient.getInstance().getUser();
return res;
},
});

const { mutate: checkMission, isSuccess: isSuccess0 } = useMutation({
mutationKey: ['checkMission'],
mutationFn: () => {
const res = ApiClient.getInstance().updateMissionCheck();
return res;
},
});

const { mutate: updateHanaMoney } = useMutation({
mutationKey: ['updateHanaMoney'],
mutationFn: (isMission: boolean) => {
const res = ApiClient.getInstance().updatePoint(isMission);
return res;
},
onSuccess: (data) => {
postAlarm(`ν•˜λ‚˜λ¨Έλ‹ˆ ${data.points}원 적립!`);
},
});

const { mutate: postAlarm } = useMutation({
mutationKey: ['updateHanaMoney'],
mutationFn: (contents: string) => {
const res = ApiClient.getInstance().postAlarm(contents);
return res;
},
onSuccess: (_, variables) => {
checkMission();
setShowAlarm(true);
alarmMsgRef.current = variables;
},
});

useEffect(() => {
if (!isSuccess0 && userInfo?.step === 3 && userInfo.stepStatus === 2) {
setShowStepModal(true);
}
}, [userInfo]);

useEffect(() => {
queryClient.invalidateQueries({
queryKey: ['userInfo', 'saving100', 'saving100Check'],
});
}, []);

const onCloseStepModal = async () => {
try {
updateHanaMoney(true);
setShowStepModal(false);
} catch (e) {
console.log(e);
}
};

const moveToTermination = () => {
isSuccess &&
navigate('/termination', {
Expand All @@ -48,6 +113,24 @@ export const Savings100Days = () => {
<>
{isSuccess && isCheckSuccess && (
<>
{showAlarm && (
<AlarmAnimation
message={alarmMsgRef.current}
showAlarm={showAlarm}
onClickShowAlarm={(status: boolean) => setShowAlarm(status)}
/>
)}
{showStepModal && (
<AlertModal onClose={() => onCloseStepModal()}>
<div className='flex flex-col font-hanaMedium text-2xl text-center'>
<p>
3단계 λ―Έμ…˜μ„ <span className='text-hanaDeepGreen'>μ™„λ£Œ</span>
ν–ˆμŠ΅λ‹ˆλ‹€!
</p>
</div>
</AlertModal>
)}

<Topbar
title={saving100.productName}
onClick={() => navigate('/mission')}
Expand Down Expand Up @@ -76,11 +159,14 @@ export const Savings100Days = () => {
</div>
<div className='absolute bg-gray-100 w-[100%] h-5 rounded-lg border-2'></div>
<div
className={`absolute bg-hanaGreen w-[${Math.floor(
(differenceInDays(new Date(), saving100.startDate) /
100) *
100
)}%] h-5 rounded-lg`}
className={`absolute bg-hanaGreen h-5 rounded-lg`}
style={{
width: `${Math.floor(
(differenceInDays(new Date(), saving100.startDate) /
100) *
100
)}%`,
}}
></div>
</div>
</div>
Expand Down
Loading

0 comments on commit 6263ab0

Please sign in to comment.