Skip to content

Commit

Permalink
πŸ’„ λŒ“κΈ€ μž‘μ„± 쀑 λͺ¨λ‹¬ λ‚˜κ°€κΈ° λ˜λŠ” λ”€λ“œ 클릭 μ‹œ confirm 을 κΈ°λ³Έ window μ—μ„œ μ»΄ν¬λ„ŒνŠΈ λ””μžμΈμœΌλ‘œ μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
jini0012 committed Dec 17, 2024
1 parent 4ce28b7 commit 0ddfc9a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/components/modal/PostModal.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React, { useState } from "react";
import styles from "./PostModal.module.css";
import PostContent from "../post/PostContent";
import { ConfirmModal } from "../Controls";

export default function PostModal({ postId, isShow, onClose }) {
const [isModalOpen, setIsModalOpen] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [comment, setComment] = useState(undefined);
const [isConfirmModalOpen, setIsConfirmModalOpen] = useState(false);

function handleModalClose() {
if (comment) {
const exitAnswer = confirm("λŒ“κΈ€μ„ μž‘μ„±μ€‘μž…λ‹ˆλ‹€. μ’…λ£Œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?");
if (!exitAnswer) return;
setIsConfirmModalOpen(true);
return;
}
setIsModalOpen(false);
onClose();
Expand All @@ -37,6 +39,20 @@ export default function PostModal({ postId, isShow, onClose }) {
setComment={setComment}
/>
</dialog>
{isConfirmModalOpen && (
<ConfirmModal
onConfirm={() => {
setIsModalOpen(false);
onClose();
setComment(undefined);
setIsLoading(true);
setIsConfirmModalOpen(false);
}}
isOpen={() => setIsConfirmModalOpen(true)}
closeModal={() => setIsConfirmModalOpen(false)}
message="λŒ“κΈ€μ„ μž‘μ„±μ€‘μž…λ‹ˆλ‹€. μ’…λ£Œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?"
/>
)}
</>
) : null}
</>
Expand Down

0 comments on commit 0ddfc9a

Please sign in to comment.