Skip to content

Commit

Permalink
Merge pull request #211 from YAPP-Github/feature/rematch-modal
Browse files Browse the repository at this point in the history
feat: 다시 매칭 모달 추가
  • Loading branch information
Jeong-jeong authored Jul 30, 2022
2 parents 7156307 + 8cd4e2e commit 32053a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/base/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const ModalInner = styled.div<IModalInnerProps>`
height: ${({ height }) => height}px;
border-radius: 4px;
animation: ${({ isClose }) => (isClose ? transitions.popOut : transitions.popIn)} 0.2s ease-in-out;
word-break: keep-all;
`;

const ModalTitle = styled.h2`
Expand Down
28 changes: 26 additions & 2 deletions src/components/domain/matching/buttons/EndButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useToggle } from '@/hooks/common';
import { postReMatchMeetingSurvey } from '@/lib/api/meeting';
import { postReMatchDatingSurvey } from '@/lib/api/dating';
import { useLocation } from 'react-router-dom';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Status } from '@/pages/MatchingPage';

interface EndButtonProps {
Expand All @@ -12,12 +12,18 @@ interface EndButtonProps {

function EndButton({ handleStatus }: EndButtonProps) {
const location = useLocation();
const [isModal, onToggleModal] = useToggle();
const [isErrorModal, onToggleErrorModal] = useToggle();
const [errorMessage, setErrorMessage] = useState('에러가 발생했습니다😭 다시한번 시도해 주세요!');
const [isConfirm, setConfirm] = useState(false);

const handleClick = async () => {
const matchMeeting = location.pathname.includes('meeting');
onToggleModal();
};

const handleRematch = async () => {
try {
const matchMeeting = location.pathname.includes('meeting');
matchMeeting ? await postReMatchMeetingSurvey() : await postReMatchDatingSurvey();
handleStatus('waiting');
} catch (e) {
Expand All @@ -26,11 +32,29 @@ function EndButton({ handleStatus }: EndButtonProps) {
onToggleErrorModal();
}
};

useEffect(() => {
if (isConfirm) {
handleRematch();
}
}, [isConfirm]);

return (
<>
<Button onClick={handleClick} size="medium">
다시 매칭하기
</Button>
{isModal && (
<Modal
width={200}
height={140}
bottonName="확인"
title="다시 매칭하시겠습니까?"
text=" 이전 설문 내용을 토대로  다시 매칭해드립니다"
onToggleModal={onToggleModal}
onClick={() => setConfirm(true)}
/>
)}
{isErrorModal && (
<Modal
width={200}
Expand Down

0 comments on commit 32053a6

Please sign in to comment.