Skip to content

Commit

Permalink
Merge pull request #276 from Strong-Potato/206-feat-add-util-test
Browse files Browse the repository at this point in the history
Feat: fix split error & add toaset in modify password & add props cancel action
  • Loading branch information
NamgungJongMin authored Jan 28, 2024
2 parents 52ce52d + 0e7d8ed commit 2594eda
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/components/AlertModal/AlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ import {AlertModalProps} from '@/types/vote';
*
* 자세한 사용은 VoteMeatball.tsx 참고
*/
const AlertModal = ({title, subText, cancelText, actionButton, isSmallSize, onClickAction}: AlertModalProps) => {
const AlertModal = ({
title,
subText,
cancelText,
actionButton,
isSmallSize,
onClickAction,
onClickCancelAction,
}: AlertModalProps) => {
const [isModalOpen, setIsModalOpen] = useRecoilState(isModalOpenState);

return (
Expand All @@ -33,7 +41,13 @@ const AlertModal = ({title, subText, cancelText, actionButton, isSmallSize, onCl
</ModalBody>

<ModalFooter>
<button onClick={() => setIsModalOpen(false)} className={styles.buttons__cancel}>
<button
onClick={() => {
setIsModalOpen(false);
onClickCancelAction && onClickCancelAction();
}}
className={styles.buttons__cancel}
>
{cancelText ? cancelText : '취소'}
</button>
<button onClick={onClickAction} className={styles.buttons__action}>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Auth/ModifyPassword/ModifyPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {useNavigate} from 'react-router-dom';

import styles from './ModifyPasswordForm.module.scss';

import CustomToast from '@/components/CustomToast/CustomToast';

import {authRequest} from '@/api/auth';

import StepNewPassword from './Step/StepNewPassword';
Expand All @@ -27,6 +29,7 @@ function ModifyPasswordForm() {
},
});
const watchFields = watch();
const showToast = CustomToast();

// steps : oldPassword, newPassword
const [step, setStep] = useState('oldPassword');
Expand All @@ -40,6 +43,7 @@ function ModifyPasswordForm() {
const res = await authRequest.modifyPassword_submit(token, watchFields.password);

console.log(res);
showToast('비밀번호가 변경되었습니다.');
navigate('/user', {replace: true});
} catch (error) {
console.log(error);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Auth/Signup/SignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function SignupForm({signupStep, setSignupStep}: SignupFormProps) {
const {email, password, image, nickname} = data;
const profile = dirtyFields.image ? await s3Request.uploadImage(image as FileList) : undefined;

const res = await authRequest.signup_submit(email, password, profile.split('?')[0], nickname, code);
const res = await authRequest.signup_submit(email, password, profile?.split('?')[0], nickname, code);
console.log(res);

if (res.data.responseCode === 204) {
Expand Down
1 change: 1 addition & 0 deletions src/pages/Auth/Withdrawal/Withdrawal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function Withdrawal() {
actionButton='탈퇴하기'
isSmallSize={true}
onClickAction={signout}
onClickCancelAction={() => navigate('/user/privacy')}
/>
</main>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/types/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export interface AlertModalProps {
actionButton: string;
isSmallSize: boolean;
onClickAction?: () => void;
onClickCancelAction?: () => void;
}

export interface CandidateListProps {
Expand Down

0 comments on commit 2594eda

Please sign in to comment.