-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [fix]: index.tsx 메인 페이지에 Cancel Modal 적용 * [fix]: Mentoring index.tsx에 Cancel Modal 적용 * [fix]: Reservation page에 Cancel Modal 적용 * [fix]: Home page에 Feedback Modal 적용 #157 * [fix]: CANCLE읋 CANCEL로 변환 * [fix]: Success, Fail 문자열 변경 * [fix]: TextArea 에서 최대 문자 길이 제한 변경 * [fix]: useState 초기값 수정
- Loading branch information
1 parent
458433e
commit 93ea4d8
Showing
13 changed files
with
158 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export const enum ButtonType { | ||
ACCEPT, | ||
CANCLE, | ||
CANCEL, | ||
} |
1 change: 1 addition & 0 deletions
1
42manito/src/Types/Reservations/ReservationPatchCancelReq.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export interface ReservationPatchCancelReqDto { | ||
id: number; | ||
content: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Select } from "antd"; | ||
import React, {Dispatch, SetStateAction} from "react"; | ||
interface args{ | ||
setOpenTextArea: Dispatch<SetStateAction<boolean>>; | ||
setCancelMsg: Dispatch<SetStateAction<string>>; | ||
} | ||
|
||
export default function CancelMessageSelect({setOpenTextArea, setCancelMsg} : args) { | ||
const defaultMsg = [ | ||
{label: "시간이 맞지않아 취소합니다.", value: 1}, | ||
{label: "멘토/멘티로부터 연락이 없어서 취소합니다.", value: 2}, | ||
{label: "직접 입력", value: 3} | ||
] | ||
|
||
const handleChange = (value: number) => { | ||
const msgObj = defaultMsg.find(({value: id}) => id === value); | ||
if (msgObj === undefined) | ||
setCancelMsg(""); | ||
else | ||
setCancelMsg(msgObj.label); | ||
if (value === 3) | ||
setOpenTextArea(true); | ||
else | ||
setOpenTextArea(false); | ||
}; | ||
|
||
return ( | ||
<Select | ||
defaultValue={1} | ||
onChange={handleChange} | ||
style={{ width: "100%" }} | ||
options={defaultMsg} | ||
className="w-full max-w-[500px]" | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React, { useState } from "react"; | ||
import {RootState, useAppDispatch} from "@/RTK/store"; | ||
import { Input } from "antd"; | ||
import { Button } from "@/common"; | ||
import { ButtonType } from "@/Types/General/ButtonType"; | ||
import {closeCancelModal, setSelectedReservation} from "@/RTK/Slices/Reservation"; | ||
import CancelMessageSelect from "@/components/Cancel/CancelMessageSelect"; | ||
import { BaseQueryError } from "@reduxjs/toolkit/src/query/baseQueryTypes"; | ||
import {usePatchReservationCancelMutation} from "@/RTK/Apis/Reservation"; | ||
import {useSelector} from "react-redux"; | ||
|
||
|
||
const CancelModal = () => { | ||
const [openTextArea, setOpenTextArea] = useState(false); | ||
const [cancelMsg, setCancelMsg] = useState("시간이 맞지않아 취소합니다."); | ||
const dispatch = useAppDispatch(); | ||
const [patchCancelReservation] = usePatchReservationCancelMutation(); | ||
const reservation = useSelector( | ||
(state: RootState) => state.rootReducers.reservation.selectedReservation, | ||
); | ||
const handleCancel = async (msg?: string, errorMsg?: string) => { | ||
try { | ||
const data = await patchCancelReservation({ | ||
id: reservation.id, | ||
content: cancelMsg, | ||
}).unwrap(); | ||
dispatch(setSelectedReservation(data)); | ||
alert(msg ? msg : "멘토링이 취소되었습니다."); | ||
dispatch(closeCancelModal()); | ||
} catch (e: BaseQueryError<any>) { | ||
alert(errorMsg ? errorMsg : "멘토링 취소가 실패했습니다."); | ||
} | ||
}; | ||
|
||
const handleClose = () => { | ||
dispatch(closeCancelModal()); | ||
}; | ||
|
||
return ( | ||
<div | ||
className="connect-wrapper" | ||
id="wrapper" | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
<section | ||
className={`connect-modal-section`} | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
<div className="connect-container"> | ||
<div className="connect-title mt-5"> 멘토링 취소</div> | ||
<div className="connect-content-wrapper"> | ||
<div className="connect-header"> 취소하려는 이유를 선택해주세요 </div> | ||
<CancelMessageSelect setOpenTextArea={setOpenTextArea} setCancelMsg={setCancelMsg}/> | ||
{openTextArea && <Input.TextArea | ||
showCount | ||
maxLength={100} | ||
style={{ height: 80, marginBottom: 24 }} | ||
onChange={(e) => setCancelMsg(e.target.value)} | ||
placeholder="최대 100글자" | ||
className="w-full max-w-[500px] mt-3" | ||
/>} | ||
</div> | ||
<div className="connect-btn-wrapper"> | ||
<Button | ||
buttonType={ButtonType.CANCEL} | ||
onClick={() => handleClose()} | ||
> | ||
닫기 | ||
</Button> | ||
<Button | ||
buttonType={ButtonType.ACCEPT} | ||
onClick={() => handleCancel()} | ||
> | ||
취소하기 | ||
</Button> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CancelModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters