diff --git a/app/modal/page.jsx b/app/modal/page.jsx deleted file mode 100644 index 581db82..0000000 --- a/app/modal/page.jsx +++ /dev/null @@ -1,29 +0,0 @@ -'use client'; - -import React, { useState, useEffect } from "react"; -import ModalComponent from '../../components/modal/modal-component'; -import {Bell, Settings} from "lucide-react"; - -export default function ModalPage() { - const [isMounted, setIsMounted] = useState(false); - - useEffect(() => { - setIsMounted(true); - }, []); - - if (!isMounted) return null; - - return ( -
- {/* Header */} -
-
-
-

학습 설정

-
-
-
- -
- ); -} \ No newline at end of file diff --git a/app/signup/page.jsx b/app/signup/page.jsx index cec71e1..e9f5553 100644 --- a/app/signup/page.jsx +++ b/app/signup/page.jsx @@ -2,17 +2,15 @@ import React, { useState } from 'react'; import Link from 'next/link'; import Title from '../../components/landing/Title'; +import Modal from '../../components/modal/modal'; // 모달 컴포넌트 추가 +import ModalComponent from '../../components/modal/modal-component'; // 모달 내용 const SignupPage = () => { const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); - - const handleCardClick = (path) => { - console.log(`Navigating to ${path}`); - window.location.href = path; - }; + const [isModalOpen, setIsModalOpen] = useState(false); // 모달 상태 추가 const handleSignup = async (event) => { event.preventDefault(); @@ -32,7 +30,7 @@ const SignupPage = () => { }); if (res.ok) { - handleCardClick('../modal'); + setIsModalOpen(true); // 회원가입 성공 시 모달 열기 } else { const data = await res.json(); alert(data.message); @@ -95,8 +93,13 @@ const SignupPage = () => { + + {/* ✅ 회원가입 성공 시 모달 띄우기 */} + setIsModalOpen(false)}> + + ); }; -export default SignupPage; \ No newline at end of file +export default SignupPage; diff --git a/components/modal/category-selector.jsx b/components/modal/category-selector.jsx index 09e193b..f885281 100644 --- a/components/modal/category-selector.jsx +++ b/components/modal/category-selector.jsx @@ -1,26 +1,25 @@ "use client"; -import React, { useMemo } from 'react'; +import React, { useMemo } from "react"; const categories = [ - { id : 1, name: '백엔드', icon: 'fas fa-server' }, - { id : 2, name: '프론트엔드', icon: 'fas fa-code' }, - { id : 3, name: '네트워크', icon: 'fas fa-network-wired' }, - { id : 4, name: '데이터베이스', icon: 'fas fa-database' }, - { id : 5, name: '운영체제', icon: 'fas fa-window-restore' }, - { id : 6, name: '자료구조', icon: 'fas fa-cubes' }, + { id: 1, name: "백엔드", icon: "fas fa-server" }, + { id: 2, name: "프론트엔드", icon: "fas fa-code" }, + { id: 3, name: "네트워크", icon: "fas fa-network-wired" }, + { id: 4, name: "데이터베이스", icon: "fas fa-database" }, + { id: 5, name: "운영체제", icon: "fas fa-window-restore" }, + { id: 6, name: "자료구조", icon: "fas fa-cubes" }, ]; const CategoryButtons = ({ availableCategories, onSelect }) => { return ( -
- {availableCategories.map(category => ( +
+ {availableCategories.map((category) => ( ))} @@ -30,39 +29,45 @@ const CategoryButtons = ({ availableCategories, onSelect }) => { const SelectedCategories = ({ selectedCategories, onDeselect }) => { return ( -
- {selectedCategories.map(category => ( - - ))} +
+ {selectedCategories.length > 0 ? ( + selectedCategories.map((category) => ( + + )) + ) : ( +

선택된 카테고리가 없습니다.

+ )}
); }; -const CategorySelector = ({ selectedCategories, onSelect, onDeselect }) => { +const CategorySelector = ({ selectedCategories = [], onSelect, onDeselect }) => { const availableCategories = useMemo(() => { return categories.filter( - category => !selectedCategories.some(selected => selected.id === category.id) + (category) => !selectedCategories.some((selected) => selected.id === category.id) ); }, [selectedCategories]); return (
+ {/* ✅ 선택된 카테고리 표시 */}
-

선택된 카테고리

+

선택된 카테고리

+ + {/* ✅ 선택 가능한 카테고리 표시 */}
-

카테고리 선택

+

카테고리 선택

{ + const options = [ + { value: '7시', label: '오전 7시' }, + { value: '8시', label: '오전 8시' }, + { value: '9시', label: '오전 9시' } + ]; + return ; +}; +const QuestionInput = ({ value, onChange }) => { + const options = [ + { value: '1개', label: '1개' }, + { value: '2개', label: '2개' }, + { value: '3개', label: '3개' }, + { value: '4개', label: '4개' }, + { value: '5개', label: '5개' } + ]; + return ; +}; + const CategorySelector = dynamic(() => import('./category-selector'), { ssr: false }); -const TimeSelector = dynamic(() => import('./time-selector'), { ssr: false }); -const QuestionInput = dynamic(() => import('./question-input'), { ssr: false }); + export default function ModalComponent() { const [selectedCategories, setSelectedCategories] = useState([]); @@ -56,31 +74,14 @@ export default function ModalComponent() { console.error("Error sending data:", error); } }; - const TimeSelector = ({ value, onChange }) => { - const options = [ - { value: '7시', label: '오전 7시' }, - { value: '8시', label: '오전 8시' }, - { value: '9시', label: '오전 9시' } - ]; - return ; - }; - const QuestionInput = ({ value, onChange }) => { - const options = [ - { value: '1개', label: '1개' }, - { value: '2개', label: '2개' }, - { value: '3개', label: '3개' }, - { value: '4개', label: '4개' }, - { value: '5개', label: '5개' } - ]; - return ; - }; - return ( -
+

학습 설정

+ + {/* ✅ 선택된 카테고리가 정상적으로 렌더링되도록 설정 */}
); -} \ No newline at end of file +} diff --git a/components/modal/modal.jsx b/components/modal/modal.jsx new file mode 100644 index 0000000..4074edc --- /dev/null +++ b/components/modal/modal.jsx @@ -0,0 +1,43 @@ +"use client"; + +import React, { useEffect } from "react"; +import ModalComponent from "@/components/modal/modal-component"; + +const Modal = ({ isOpen, onClose, children }) => { + useEffect(() => { + const handleEsc = (event) => { + if (event.key === "Escape") { + onClose(); // ESC 키를 누르면 모달 닫기 + } + }; + + if (isOpen) { + document.addEventListener("keydown", handleEsc); + } + + return () => { + document.removeEventListener("keydown", handleEsc); + }; + }, [isOpen, onClose]); + + if (!isOpen) return null; // 모달이 닫혀있으면 렌더링 안 함 + + return ( +
+ {/* ✅ 모달 크기 자동 조절 + 스크롤 가능하도록 수정 */} +
+ {/* ✅ 닫기 버튼 위치 조정 */} + + +
+
+
+ ); +}; + +export default Modal;