+
+
+
goChatRoomInformation()}>
+ {selectChatRoom.title}
+
+
+
goChatRoomInformation()}>
+ {users.map((user, index) => (
+
0) ? '' : `url(${user.profileImage})`
+ }}
+ />
+ ))}
+ {extraProfilesCount > 0 && (
+
+ +{extraProfilesCount}
+
+ )}
+
+
+
+
+
+
+
+ {formatMessages(messages)}
+
+
+
+
+
+
+ )
+ }
+}
+
+export default ChatRoom;
\ No newline at end of file
diff --git a/src/page/Chat/ChatRoom/ChatRoomInformation/ChatRoomInformation.css b/src/page/Chat/ChatRoom/ChatRoomInformation/ChatRoomInformation.css
new file mode 100644
index 0000000..2da054d
--- /dev/null
+++ b/src/page/Chat/ChatRoom/ChatRoomInformation/ChatRoomInformation.css
@@ -0,0 +1,276 @@
+.chatRoomInformation {
+ height: 812px;
+ width: 375px;
+
+ margin: 0 auto;
+
+ .margin-container {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ margin: 0 16px;
+ }
+
+ .title {
+ width: 100%;
+ height: 46px;
+ margin-top: 50px;
+ background: #ffffff;
+ display: flex;
+ text-align: center;
+
+ }
+
+ .title-name {
+ /* 채팅방 이름 */
+
+ padding-top: 15px;
+ width: 90px;
+ height: 18px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+ /* identical to box height, or 112% */
+ display: flex;
+ align-items: center;
+
+ color: #3D3D3D;
+ }
+
+
+ .chat-room-header {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-bottom: 50px;
+ margin-top: 10px
+ }
+
+ .chat-room-image {
+ border-radius: 50%;
+ margin-bottom: 10px;
+
+ /* 채팅방 대표사진 */
+ width: 60px;
+ height: 60px;
+ background-color: #3D3D3D;
+
+ }
+
+ .chat-room-name {
+
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+
+ color: #3D3D3D;
+ }
+
+
+
+ .chat-room-actions {
+ width: 300px;
+ margin: 0 auto;
+ display: flex;
+ justify-content: space-evenly;
+ margin-bottom: 20px;
+ }
+
+ .action-item {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 5px;
+ width: 84px;
+ height: 84px;
+ background-color: #FAFAFA;
+ border-radius: 20%;
+ transition: all 0.3s ease;
+ }
+
+ .action-item img {
+ width: 30px;
+ height: 30px;
+ }
+
+ .action-item span {
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 12px;
+ line-height: 14px;
+
+ color: #000000;
+ }
+
+ .chat-room-timer {
+
+ margin: 0 auto;
+ width: 272px;
+ height: 40px;
+
+
+ background: #FAFAFA;
+ border-radius: 10px;
+ margin-bottom: 20px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .chat-room-timer span {
+
+
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 12px;
+ line-height: 14px;
+ /* identical to box height, or 117% */
+
+
+ color: #000000;
+ }
+
+ .participant-list {
+ margin-top: 20px;
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ }
+
+ .participant-list-text {
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 14px;
+ line-height: 18px;
+
+ color: #3D3D3D;
+ margin-bottom: 10px;
+ }
+
+ .gender {
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 12px;
+ line-height: 12px;
+ color: #777777;
+ margin-bottom: 10px;
+ }
+
+
+ .participant-group {
+ max-height: 150px;
+ overflow-y: scroll;
+ scrollbar-width: none;
+ /* Firefox */
+ -ms-overflow-style: none;
+ }
+
+ .participant-group ul {
+ padding-left: 0px;
+ }
+
+
+
+ .bar {
+ width: 343px;
+ height: 6px;
+ background-color: #FAFAFA;
+
+ }
+
+
+ .major {
+
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 12px;
+ line-height: 14px;
+ /* identical to box height, or 117% */
+ display: flex;
+ align-items: center;
+
+ color: #777777;
+ }
+
+ .nickName {
+
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 12px;
+ line-height: 14px;
+ /* identical to box height, or 117% */
+ display: flex;
+ align-items: center;
+
+ color: #3D3D3D;
+ }
+
+ .user-list {
+ display: flex;
+ flex-direction: row;
+ margin-bottom: 5px;
+ }
+
+ .user-list img {
+ width: 18px;
+ height: 18px;
+ border-radius: 50%;
+ margin-left: 3px;
+ margin-right: 5px;
+ }
+
+ .user-container {
+ display: flex;
+ flex-direction: column;
+ }
+
+
+
+
+
+
+ .action-item svg {
+ fill: none;
+ transition: all 0.3s ease;
+ }
+
+ .action-item span {
+ color: #3D3D3D;
+ transition: all 0.3s ease;
+ }
+
+ .action-item.active {
+ background-color: #FF7898;
+ /* 핑크 배경 */
+ }
+
+ .action-item.active svg {
+ fill: #fff;
+ /* 아이콘 하얀색 */
+ }
+
+ .action-item.active span {
+ color: #fff;
+ /* 글자 하얀색 */
+ }
+
+}
\ No newline at end of file
diff --git a/src/page/Chat/ChatRoom/ChatRoomInformation/ChatRoomInformation.jsx b/src/page/Chat/ChatRoom/ChatRoomInformation/ChatRoomInformation.jsx
new file mode 100644
index 0000000..cf25182
--- /dev/null
+++ b/src/page/Chat/ChatRoom/ChatRoomInformation/ChatRoomInformation.jsx
@@ -0,0 +1,205 @@
+import React, { useState, useEffect } from "react";
+import './ChatRoomInformation.css'
+import ExitDialog from '../../Dialog/ExitDialog'
+import UserIntroduceDialog from '../../Dialog/UserintroduceDialog'
+import { fetchChatroomInformation } from '../../../../api/chatRoom/fetchChatroomInformation'
+
+function ChatRoomInformation({ roomId, socket, chatRoomInformation }) {
+ const [exitDialog, setExitDialog] = useState(false);
+
+ const goChatRoom = () => {
+ chatRoomInformation(false);
+ };
+
+ const [activeItemPromise, setActiveItemPromise] = useState(null);
+ const [activeItemAlarm, setActiveItemAlarm] = useState(null);
+ const [activeItemExit, setActiveItemExit] = useState(null);
+ const [userIntroduceDialog, setUserIntroduceDialog] = useState(false);
+ const [clickUser, setClickUser] = useState();
+
+ const handleClick = (item) => {
+ if (item === "promise") {
+ if (activeItemPromise) {
+ setActiveItemPromise(false);
+ } else {
+ setActiveItemPromise(true);
+ }
+ } else if (item === "alarm") {
+ if (activeItemAlarm) {
+ setActiveItemAlarm(false);
+ } else {
+ setActiveItemAlarm(true);
+ }
+ } else if (item === "exit") {
+ if (activeItemExit) {
+ setActiveItemExit(false);
+ } else {
+ setActiveItemExit(true);
+ }
+ }
+
+ };
+
+
+ const [room, setRoom] = useState({
+ title: "프로그래밍 기초",
+ members: [
+ { gender: "여자", major: "Physics", studentId: "20210003", nickname: "Alice", profileImage: "../../../../asset/ChatRoomPic3.png" },
+ { gender: "여자", major: "Mathematicasdfasdfdassdfsssadfsdf", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic4.png" },
+ { gender: "남자", major: "Mathematicasdfasdfdassdfsssadfsdf", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic4.png" },
+ { gender: "남자", major: "Mathematicasdfasdfdassdfsssadfsdf", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic4.png" }
+ ],
+ profileImage: '../../../../asset/ChatRoomPic1.png',
+ })
+
+ const [possibleEnterNumber, setPossibleEnterNumber] = useState(3);
+ const [remainingTime, setRemainingTime] = useState('');
+ const [dDay, setDDay] = useState(0);
+
+ useEffect(() => {
+ const fetchRoomData = async () => {
+ try {
+ const data = await fetchChatroomInformation(roomId);
+ setRoom(data.room);
+ setPossibleEnterNumber(data.possibleEnterNumber);
+ setRemainingTime(data.remainingTime);
+ setDDay(data.dDay);
+ } catch (error) {
+ console.error("Error fetching room data:", error);
+ }
+ };
+
+ fetchRoomData();
+ }, [roomId]);
+
+
+
+
+ const dialogOpen = (nickname) => {
+ setUserIntroduceDialog(true);
+ setClickUser(nickname);
+ }
+
+
+
+
+ return (
+
+
setUserIntroduceDialog(false)} roomId={roomId} />
+ setExitDialog(false)} possibleEnterNumber={possibleEnterNumber} roomId={roomId} socket={socket} />
+
+
+ {/* 이미지와 채팅방 이름 */}
+
+

+
{room.title}
+
+
+ {/* 버튼들 */}
+
+ {/* 약속 잡기 */}
+
handleClick('promise')}
+ >
+
+
약속 잡기
+
+
+ {/* 알림 끄기 */}
+
handleClick('alarm')}
+ >
+
+ {activeItemAlarm ? <>
알림 키기 > :
알림 끄기
+ }
+
+
+
+ {/* 나가기 */}
+
{ handleClick('exit'); setExitDialog(true) }}
+ >
+
+
+
나가기
+
+
+
+
+ {/* 채팅방 종료 시간 */}
+
+
+ {remainingTime}에 채팅방이 종료됩니다 D-{dDay}
+
+
+
+
+
+ {/* 참여자 목록 */}
+
+
+
+
+ );
+}
+
+export default ChatRoomInformation;
\ No newline at end of file
diff --git a/src/page/Chat/ChatStartPage.jsx b/src/page/Chat/ChatStartPage.jsx
new file mode 100644
index 0000000..1889556
--- /dev/null
+++ b/src/page/Chat/ChatStartPage.jsx
@@ -0,0 +1,224 @@
+import React, { useState, useEffect } from "react";
+import './ChatPage.css'
+import EnterCheckPage from './EnterCheckPage'
+import NoEnterCheckPage from './NoEnterCheckPage'
+import { useNavigate } from 'react-router-dom';
+import logo from '../../asset/logo.png'
+import { fetchChatRoomFetch } from '../../api/chatRoom/fetchChatRoomFetch'
+
+function ChatStartPage() {
+
+ const navigate = useNavigate();
+ const [loading, setLoading] = useState(true);
+
+ const [isEnterCheck, setIsEnterClick] = useState(false);
+ //유저의 정보를 가져와 성별,입장참여 횟수를 가져온다
+ const [possibleEnterNumber, setPossibleEnterNumber] = useState(3);
+ const [gender, setGender] = useState("남자");
+
+
+ const handleNavigation = (destination) => {
+ switch (destination) {
+ case 'play':
+ navigate('/mbti');
+ break;
+ case 'talk':
+ window.location.reload(); // 페이지 새로고침 (필요에 따라 이 부분을 변경)
+ break;
+ case 'my':
+ navigate('/myPage');
+ break;
+ default:
+ break;
+ }
+ };
+
+
+ // 채팅방 정보를 저장하는 state(예시 백에서 받아와야함)
+ //나중에 역순으로 할거?
+ const [chatRooms, setChatRooms] = useState([
+ {
+ id: 1,
+ //제목 길이 20자 제한
+ title: "채팅방 메인 타이틀아아아아f",
+ //서브제목 길이 30자 제한
+ subTitle: "dddddddddddddddddddddddddddddddddddddddddddddddddd",
+
+ //방아이디로 조회한다.
+
+ // //나중에 서버로 부터 바는 member이기 때문에 삭제!
+ members: [
+ { gender: "남자", major: "Computer Science", studentId: "20210001", nickname: "John", profileImage: "../../../../asset/ChatRoomPic1.png" },
+ { gender: "여자", major: "Design", studentId: "20210002", nickname: "Jane", profileImage: "../../../../asset/ChatRoomPic2.png" }
+ ],
+ maxMembers: 2,
+ //입장체크
+ enterCheck: false,
+ host: "asdfasdf1234346",
+ maleCount: 1,
+ femaleCount: 1,
+ profileImage: '../../../../asset/ChatRoomPic1.png',
+ status: "Waiting"
+ },
+ {
+ id: 2,
+ title: "프로그래밍 기초",
+ subTitle: "프로그래밍의 기초를 배워봅시다",
+ members: [
+ { gender: "여자", major: "Physics", studentId: "20210003", nickname: "Alice", profileImage: "../../../../asset/ChatRoomPic3.png" },
+ { gender: "여자", major: "Mathematicasdfasdfdassdfsssadfsdf", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic4.png" },
+ { gender: "남자", major: "Mathematicasdfasdfdassdfsssadfsdf", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic4.png" },
+ { gender: "남자", major: "Mathematicasdfasdfdassdfsssadfsdf", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic4.png" }
+ ],
+ maxMembers: 4,
+ enterCheck: true,
+ host: "asdfasdf1234346",
+ maleCount: 2,
+ femaleCount: 2,
+ profileImage: '../../../../asset/ChatRoomPic1.png',
+ status: "active"
+ },
+ {
+ id: 3,
+ title: "프로그래밍 기초",
+ subTitle: "프로그래밍의 기초를 배워봅시다",
+ members: [
+ { gender: "여자", major: "Physics", studentId: "20210003", nickname: "Alice", profileImage: "../../../../asset/ChatRoomPic4.png" },
+ { gender: "남자", major: "Mathematics", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic5.png" },
+ { gender: "남자", major: "asd", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic6.png" },
+
+ ],
+ maxMembers: 6,
+ enterCheck: false,
+ host: "asdfasdf1234346",
+ maleCount: 2,
+ femaleCount: 1,
+ profileImage: '../../../../asset/ChatRoomPic1.png',
+ status: "Waiting"
+ },
+ {
+ id: 4,
+ title: "프로그래밍 기초",
+ subTitle: "프로그래밍의 기초를 배워봅시다",
+ //사진경로 절대경로로 수정
+ members: [
+ { gender: "여자", major: "Physics", studentId: "20210003", nickname: "Alice", profileImage: "../../../../asset/ChatRoomPic3.png" },
+ { gender: "남자", major: "Mathematics", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic2.png" },
+ { gender: "여자", major: "Mathematics", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic6.png" },
+ { gender: "남자", major: "Mathematics", studentId: "20210004", nickname: "Bob", profileImage: "../../../../asset/ChatRoomPic1.png" },
+ { gender: "여자", major: "asd", studentId: "20210004", nickname: "한준서", profileImage: "../../../../asset/ChatRoomPic5.png" }
+ ],
+ maxMembers: 6,
+ enterCheck: false,
+ host: "asdfasdf1234346",
+ maleCount: 2,
+ femaleCount: 3,
+ profileImage: '../../../../asset/ChatRoomPic1.png',
+ status: "Waiting"
+ }
+ ]);
+
+
+ useEffect(() => {
+ const fetchChatRooms = async () => {
+ try {
+ const data = await fetchChatRoomFetch();
+ const roomsWithMembers = data.rooms.map(room => ({
+ ...room,
+ members: []
+ }));
+ setChatRooms(roomsWithMembers);
+
+ setPossibleEnterNumber(data.possibleEnterNumber);
+ setGender(data.gender);
+ } catch (error) {
+ console.error('Error fetching chat rooms:', error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchChatRooms();
+ }, []);
+
+
+
+
+
+
+
+
+ const makeChatRoom = () => {
+ //챗룸 만들기로 이동
+ navigate('/makeChatRoom')
+ }
+
+
+
+ if (loading) return (
+
+ );
+
+ return (
+
+
+
+
+
+
+ setIsEnterClick(true)} >참여중
+ setIsEnterClick(false)}>모집중
+
+ {isEnterCheck ?
최대 {possibleEnterNumber}개 방까지 참여 가능합니다 :
}
+
+
+
+
+ {isEnterCheck ? (
+ setIsEnterClick(value)}
+ />
+ ) : (
+ setIsEnterClick(value)}
+ />
+ )}
+
+
+
+
+
+
+
+
handleNavigation('play')}>
+
handleNavigation('talk')}>
+
handleNavigation('my')}>
+
+
+
+ );
+}
+
+export default ChatStartPage;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/ExitDialog.jsx b/src/page/Chat/Dialog/ExitDialog.jsx
new file mode 100644
index 0000000..503f1ce
--- /dev/null
+++ b/src/page/Chat/Dialog/ExitDialog.jsx
@@ -0,0 +1,57 @@
+import React from "react";
+import { useNavigate } from 'react-router-dom';
+import './dialog.css'
+import { leaveChatRoom } from '../../../api/chatRoom/leaveChatRoom';
+import { sendLeaveMessage, unsubscribeFromRoom } from '../../../api/chatRoom/socket/socketService';
+
+function ExitDialog({ isOpen, onClose, possibleEnterNumber, roomId, socket }) {
+ const navigate = useNavigate();
+ if (!isOpen) return null;
+
+ const exitRoom = async () => {
+ try {
+ await leaveChatRoom(roomId);
+ sendLeaveMessage(socket, roomId);
+ unsubscribeFromRoom(socket, roomId);
+
+ navigate('/chatStartPage');
+ onClose();
+ } catch (error) {
+ console.error("채팅방 나가기 실패:", error);
+ }
+ }
+
+
+ return (
+
+
+
+
+
정말로 채팅방을 나가시겠어요?
+
+ 현재 나의 채팅방 입장 참여 횟수 {possibleEnterNumber}개
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default ExitDialog;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/LeaveDialog.jsx b/src/page/Chat/Dialog/LeaveDialog.jsx
new file mode 100644
index 0000000..0fba53d
--- /dev/null
+++ b/src/page/Chat/Dialog/LeaveDialog.jsx
@@ -0,0 +1,60 @@
+import React from "react";
+import { useNavigate } from 'react-router-dom';
+import './dialog.css'
+import { deleteUser } from '../../../api/deleteUser';
+
+function LeaveDialog({ isOpen, onClose }) {
+ const navigate = useNavigate();
+ if (!isOpen) return null;
+
+ const exitRoom = async () => {
+ try {
+ const result = await deleteUser();
+ if (result.success) {
+ console.log('User account deleted successfully');
+ // You can add a success message or redirect the user here
+ } else {
+ console.error('Failed to delete user account');
+ // You can add an error message or handle the error here
+ }
+ } catch (error) {
+ console.error('Error deleting user account:', error);
+ // You can add an error message or handle the error here
+ }
+ //chatStartPage로 이동
+ navigate('/');
+ onClose();
+ }
+
+ return (
+
+
+
+
+
정말로 탈퇴하시겠어요?
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default LeaveDialog;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/MaxChanceDialog.jsx b/src/page/Chat/Dialog/MaxChanceDialog.jsx
new file mode 100644
index 0000000..76f9b54
--- /dev/null
+++ b/src/page/Chat/Dialog/MaxChanceDialog.jsx
@@ -0,0 +1,33 @@
+import React, { useState } from "react";
+import './dialog.css'
+
+function MaxChanceDialog({ isOpen, onClose, possibleEnterNumber }) {
+ if (!isOpen) return null;
+
+ return (
+
+
+
+
+
최대 참여 가능한 채팅방 수가 초과되었습니다
+
+ {/* 로직구현 */}
+ 현재 나의 채팅방 입장 잔여 횟수 {possibleEnterNumber}개
+
+
+
+
+
+ );
+}
+
+export default MaxChanceDialog;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/MaxMemberDialog.jsx b/src/page/Chat/Dialog/MaxMemberDialog.jsx
new file mode 100644
index 0000000..92c0323
--- /dev/null
+++ b/src/page/Chat/Dialog/MaxMemberDialog.jsx
@@ -0,0 +1,31 @@
+import React, { useState } from "react";
+
+function MaxMemberDialog({ isOpen, onClose }) {
+ if (!isOpen) return null;
+
+ return (
+
+
+
+
+
채팅방 인원이 마감되었습니다
+
+
+
+
+
+
+
+ );
+}
+
+export default MaxMemberDialog;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/OkayDialog.jsx b/src/page/Chat/Dialog/OkayDialog.jsx
new file mode 100644
index 0000000..bd381d8
--- /dev/null
+++ b/src/page/Chat/Dialog/OkayDialog.jsx
@@ -0,0 +1,75 @@
+import { useNavigate } from 'react-router-dom';
+import './dialog.css'
+
+function OkayDialog({ isOpen, onClose, selectChatRoom, possibleEnterNumber }) {
+ const navigate = useNavigate();
+
+ if (!isOpen) return null;
+
+
+ const maxVisibleProfiles = 3;
+ const memberLength = selectChatRoom.members.length;
+ const members = selectChatRoom.members.slice(0, maxVisibleProfiles);
+ const extraProfilesCount = memberLength - maxVisibleProfiles;
+
+ const memberLengthClassName = `member-length-${memberLength}`;
+
+
+
+ const goChatRoom = () => {
+ navigate(`/chat/2`); // 원하는 경로로 이동
+ // navigate(`/chat/${selectChatRoom.id}`); // 원하는 경로로 이동
+ onClose();
+ }
+
+ return (
+
+
+
+
채팅방 메인 타이틀에 입장하시겠습니까?
+
+ {members.map((member, index) => (
+
0) ? '' : `url(${member.profileImage})`
+ }}
+ />
+ ))}
+ {extraProfilesCount > 0 && (
+
+ +{extraProfilesCount}
+
+ )}
+
+
+
+
+ 원활한 서비스 이용을 위해
+ 동시에 최대 3개의 채팅방을 이용할 수 있습니다
+
+
+ 현재 나의 채팅방 입장 참여 횟수 {possibleEnterNumber}개
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default OkayDialog;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/UserintroduceDialog.jsx b/src/page/Chat/Dialog/UserintroduceDialog.jsx
new file mode 100644
index 0000000..4d12959
--- /dev/null
+++ b/src/page/Chat/Dialog/UserintroduceDialog.jsx
@@ -0,0 +1,78 @@
+import React, { useState, useEffect } from "react";
+import { fetchAnotherInformation } from '../../../api/chatRoom/fetchAnotherInformation';
+
+function UserIntroduceDialog({ isOpen, onClose, nickname, roomId }) {
+ //유저의 정보를 받아오는 useEffect 사용
+ const [profile, setProfile] = useState({
+ profileImage: "",
+ nickname: "아아",
+ department: "컴공",
+ studentId: "202001485",
+ shortIntroduce: "안녕하세요",
+ mbti: "INFJ",
+ height: "180",
+ drinking: "소주3병마심",
+ smoking: "1갑"
+ });
+
+
+ useEffect(() => {
+ const fetchIntroduceItems = async () => {
+ try {
+ const userData = await fetchAnotherInformation(nickname, roomId);
+ setProfile(userData);
+ } catch (error) {
+ console.error('Error fetching user info:', error);
+ }
+ };
+ fetchIntroduceItems();
+ }, [nickname, roomId]);
+
+
+
+
+
+
+ if (!isOpen) return null;
+
+
+
+ return (
+
+
+
+
+

+
+
{profile.nickname}
+
{profile.department} {profile.studentId.slice(1, 3)}학번
+
+
{profile.shortIntroduce}
+
+
+
+
+ {/* 유저를통한 로직추가 */}
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default UserIntroduceDialog;
\ No newline at end of file
diff --git a/src/page/Chat/Dialog/dialog.css b/src/page/Chat/Dialog/dialog.css
new file mode 100644
index 0000000..3e3e3fd
--- /dev/null
+++ b/src/page/Chat/Dialog/dialog.css
@@ -0,0 +1,483 @@
+.dialog {
+
+ position: absolute;
+ height: 100%;
+ width: 100%;
+ top: 0px;
+ background: rgba(0, 0, 0, 0.1);
+ z-index: 1000;
+ left: 0px;
+
+ .dialog-backdrop {
+
+
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+
+ z-index: 1000;
+ /* 앞으로 오게 하기 위해 z-index 값 추가 */
+
+ /* Group 816134 */
+
+ position: absolute;
+ width: 343px;
+ height: 330px;
+ left: calc(50% - 343px/2);
+ top: 199px;
+ }
+
+ .dialog-container {
+ background-color: white;
+ border-radius: 20px;
+ width: 343px;
+ height: 330px;
+ text-align: center;
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
+ display: flex;
+ flex-direction: column;
+
+
+ }
+
+ .dialog-icon {
+ margin-top: 32px;
+ margin-bottom: 32px;
+ }
+
+ .dialog-title {
+ /* 최대 참여 가능 채팅방 수가 초과되었습니다 */
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+ margin-bottom: 0;
+ /* identical to box height, or 112% */
+
+
+ color: #3D3D3D;
+ }
+
+ .dialog-message {
+ margin-top: 3px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 12px;
+ line-height: 14px;
+ /* identical to box height, or 117% */
+
+
+ color: #3D3D3D;
+ }
+
+ .highlight-text {
+ color: #FF7898;
+ font-weight: bold;
+ }
+
+
+
+ .dialog-button {
+ background-color: #F5F5F5;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 18px;
+ line-height: 20px;
+ color: #3D3D3D;
+ border: none;
+ border-radius: 14px;
+ padding: 10px 20px;
+ font-size: 16px;
+ cursor: pointer;
+ margin: 10px 31px 0 31px;
+ }
+
+ .dialog-button:hover {
+ background-color: #FF7898;
+ }
+
+
+ .dialog-okay-title {
+ /* 에 입장하시겠습니까? */
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 16px;
+ line-height: 18px;
+ /* identical to box height, or 112% */
+ margin-top: 30px;
+ align-items: center;
+ color: #3D3D3D;
+ }
+
+ .button-container {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-evenly;
+ }
+
+ .dialog-button-cancle {
+ /* Rectangle 3470049 */
+ width: 136px;
+ height: 44px;
+ border: none;
+ background: #F5F5F5;
+ border-radius: 14px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 18px;
+ line-height: 20px;
+ color: #3D3D3D;
+ }
+
+ .dialog-button-pink {
+ /* Rectangle 3470049 */
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 18px;
+ line-height: 20px;
+ color: #FFFFFF;
+ width: 136px;
+ height: 44px;
+ border: none;
+ background: #FF7898;
+ border-radius: 14px;
+ }
+
+
+ .dialog-icon-container {
+ margin-top: 15px;
+ display: flex;
+ justify-content: center;
+ text-align: center;
+ }
+
+ /*원이 3개이상*/
+ .profile-icon-0 {
+ width: 96px;
+ height: 96px;
+ background-size: cover;
+ background-position: center;
+ border-radius: 50%;
+ position: relative;
+ background-color: #A0A0A0;
+ left: 60px;
+ top: 0;
+ z-index: 0;
+ }
+
+ .profile-icon-1 {
+ width: 96px;
+ height: 96px;
+ background-size: cover;
+ background-position: center;
+ border-radius: 50%;
+ position: relative;
+ background-color: #BBBBBB;
+ left: 0;
+ top: 0;
+ z-index: 1;
+ }
+
+ .profile-icon-2 {
+ width: 96px;
+ height: 96px;
+ background-size: cover;
+ background-position: center;
+ border-radius: 50%;
+ position: relative;
+ background-color: #F5F5F5;
+ left: -60px;
+ top: 0;
+ z-index: 2;
+ }
+
+ /*원이 2개*/
+ .profile-icon-0.member-length-2 {
+ width: 96px;
+ height: 96px;
+ background-size: cover;
+ background-position: center;
+ border-radius: 50%;
+ position: relative;
+ background-color: #A0A0A0;
+ left: 30px;
+ top: 0;
+ z-index: 0;
+ }
+
+ .profile-icon-1.member-length-2 {
+ width: 96px;
+ height: 96px;
+ background-size: cover;
+ background-position: center;
+ border-radius: 50%;
+ position: relative;
+ background-color: #BBBBBB;
+ left: -30px;
+ top: 0;
+ z-index: 1;
+ }
+
+ /*원이 1개*/
+ .profile-icon-0.member-length-1 {
+ width: 96px;
+ height: 96px;
+ background-size: cover;
+ background-position: center;
+ border-radius: 50%;
+ position: relative;
+ background-color: #A0A0A0;
+ left: 0px;
+ top: 0;
+ z-index: 0;
+ }
+
+
+ .extra-profile-count {
+
+ /* +2 */
+
+ position: absolute;
+ width: 17px;
+ height: 16px;
+ left: 200px;
+ top: 118px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 14px;
+ line-height: 16px;
+ /* identical to box height, or 114% */
+ display: flex;
+ align-items: center;
+ text-align: center;
+
+ color: #606060;
+ z-index: 3;
+
+ }
+
+ .okayDialog-container {
+ display: flex;
+ flex-direction: column;
+ margin-left: 47px;
+ }
+
+ .dialog-message-2 {
+ /* 원활한 서비스 이용을 위해 동시에 최대 3개의 채팅방을 이용할 수 있습니다 */
+ margin-top: 15px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 12px;
+ line-height: 18px;
+ /* or 150% */
+ margin-bottom: 0px;
+ color: #777777;
+
+ display: flex;
+ justify-content: start;
+ flex-direction: column;
+ text-align: left;
+ }
+
+ .dialog-message.okay {
+ margin-top: 0px;
+ margin-bottom: 16px;
+ text-align: left;
+ }
+}
+
+
+.userIntroduceDialog {
+ position: absolute;
+ height: 100%;
+ width: 100%;
+ top: 0px;
+ background: rgba(0, 0, 0, 0.1);
+ z-index: 1000;
+ left: 0px;
+ display: flex;
+ justify-content: center;
+
+ .dialog-backdrop {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ z-index: 1000;
+ position: absolute;
+ width: 375px;
+ height: 558px;
+ top: 254px;
+ }
+
+ .dialog-container {
+ background-color: white;
+ border-radius: 20px;
+ width: 100%;
+ height: 100%;
+ text-align: center;
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
+ display: flex;
+ flex-direction: column;
+
+
+ }
+
+
+ .dialog-title {
+ /* 최대 참여 가능 채팅방 수가 초과되었습니다 */
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+ margin-bottom: 0;
+ /* identical to box height, or 112% */
+ margin-top: 10px;
+
+ color: #3D3D3D;
+ }
+
+ .dialog-message {
+ margin-top: 3px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 14px;
+ color: #777777;
+ }
+
+
+ .button-container {
+ margin-top: 30px;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-evenly;
+ }
+
+
+
+
+ .dialog-button-cancle {
+ /* Rectangle 3470049 */
+ width: 136px;
+ height: 44px;
+ border: none;
+ background-color: #F5F5F5;
+ border-radius: 14px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 18px;
+ line-height: 20px;
+ cursor: pointer;
+ color: #3D3D3D;
+ }
+
+
+ .dialog-button-cancle:hover {
+ background-color: #FF7898;
+ color: #F5F5F5;
+ }
+
+ .profile-image-container {
+ margin-top: 50px;
+ }
+
+ .profile-image-container img {
+ width: 128px;
+ height: 128px;
+ border-radius: 50%;
+ }
+
+ .introduction-container {
+ margin: 10px auto;
+ margin-bottom: 30px;
+ width: 343px;
+ height: 46px;
+ background: #F5F5F5;
+ border-radius: 10px;
+ align-items: center;
+ display: flex;
+ }
+
+ .introduction {
+ /* 한 줄 소개 안녕하세요~~~~ */
+ width: 100%;
+ height: 16px;
+ padding: 0 20px;
+ text-align: left;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 14px;
+ line-height: 16px;
+
+
+ color: #3D3D3D;
+ }
+
+ .additional-info-container {
+ margin: 0 20px;
+ padding: 0 10px;
+ background: #F5F5F5;
+ border-radius: 10px;
+
+ }
+
+ .additional-info {
+ width: 100%;
+ height: 100%;
+ text-align: left;
+ display: flex;
+ flex-direction: column;
+ padding: 10px;
+ gap: 7px;
+ }
+
+ .additional-info div {
+ display: flex;
+ flex-direction: row;
+ }
+
+ .additional-info .first {
+
+ width: 45px;
+ height: 16px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 14px;
+ line-height: 16px;
+
+
+ color: #3D3D3D;
+ }
+
+ .additional-info .second {
+
+ width: 269px;
+ height: 16px;
+ margin-left: 10px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 14px;
+ line-height: 16px;
+
+
+ color: #3D3D3D;
+ }
+
+}
\ No newline at end of file
diff --git a/src/page/Chat/EnterCheckPage.jsx b/src/page/Chat/EnterCheckPage.jsx
new file mode 100644
index 0000000..00c0129
--- /dev/null
+++ b/src/page/Chat/EnterCheckPage.jsx
@@ -0,0 +1,226 @@
+import React, { useState, useEffect } from "react";
+import { useNavigate } from 'react-router-dom';
+import './ChatPage.css'
+import { roomStart } from '../../api/chatRoom/roomStart'
+import { fetchRoomParticipants } from '../../api/chatRoom/fetchRoomParticipants';
+
+function EnterCheckPage(props) {
+ const { chatRooms, isEnterCheck } = props;
+ const [expandedRoomIds, setExpandedRoomIds] = useState([]);
+ const [updatedChatRooms, setUpdatedChatRooms] = useState(
+ chatRooms.filter(room => room.enterCheck === true)
+ );
+
+ const navigate = useNavigate();
+
+ //새로고침
+ const [startY, setStartY] = useState(0);
+ const [translateY, setTranslateY] = useState(0);
+ const [isRefreshing, setIsRefreshing] = useState(false);
+
+ const threshold = 80; // 새로고침을 트리거하는 기준 거리
+
+ // 새로고침 함수
+ const handleRefresh = () => {
+ setIsRefreshing(true);
+ setTimeout(() => {
+ setIsRefreshing(false);
+ isEnterCheck(true); // enterCheck를 true로 설정
+ }, 1500);
+ };
+
+ // 터치 시작
+ const handleTouchStart = (event) => {
+ setStartY(event.touches[0].clientY);
+ };
+
+ // 터치 중일 때
+ const handleTouchMove = (event) => {
+ const currentY = event.touches[0].clientY;
+ const distance = currentY - startY;
+
+
+ // 스크롤이 최상단일 때만 동작
+ if (window.scrollY === 0 && distance > 0) {
+ setTranslateY(distance * 0.3); // 끌린 만큼 translateY 값을 설정
+ }
+
+ // 기준 거리를 넘었을 때 새로고침
+ if (distance > threshold) {
+ handleRefresh();
+ }
+ };
+
+ // 터치 끝
+ const handleTouchEnd = () => {
+ setTranslateY(0); // 터치가 끝나면 원래 위치로 돌아가기
+ };
+
+
+
+ //토글확장 관리
+ const toggleExpand = (roomId) => {
+ setExpandedRoomIds(prevState =>
+ prevState.includes(roomId)
+ ? prevState.filter(id => id !== roomId)
+ : [...prevState, roomId]
+ );
+ console.log(expandedRoomIds)
+ };
+
+
+
+ const goChatRoom = (roomId) => {
+ console.log(roomId)
+ navigate(`/chat/${roomId}`);
+ //navigate(`/chat/${roomId}`); // 원하는 경로로 이동
+ }
+
+ // 수정된 handleButtonClick 함수
+ const handleButtonClick = async (event, room) => {
+ // console.log(room)
+ //console.log("sdafdddddddddddffdfdfsdfsdfdsfsdfdsfsdfsdfsdfsdf")
+ if (room.members.length < room.maxMembers) {
+ event.stopPropagation(); // 이벤트 버블링을 막음
+ } else {
+ event.stopPropagation();
+ const started = await roomStart(room.id);
+ if (started) {
+ goChatRoom(room.id);
+ } else {
+ // 시작 실패 시 에러 처리 (예: 알림 표시)
+ console.error('Failed to start the room');
+ }
+ }
+ };
+
+
+
+
+ useEffect(() => {
+ if (expandedRoomIds.length > 0) {
+ const updateMembers = async () => {
+ const updatedRooms = await Promise.all(
+ updatedChatRooms.map(async (room) => {
+ if (room.id === expandedRoomIds[expandedRoomIds.length - 1]) {
+ const updatedMembers = await fetchRoomParticipants(room.id);
+ return {
+
+ ...room,
+ members: updatedMembers,
+ maleCount: updatedMembers.filter(member => member.gender === "남자").length,
+ femaleCount: updatedMembers.filter(member => member.gender === "여자").length
+ };
+ }
+ return room;
+ })
+ );
+
+ setUpdatedChatRooms(updatedRooms);
+ };
+
+ updateMembers();
+ }
+ }, [expandedRoomIds, isEnterCheck, chatRooms]);
+
+
+
+ return (
+
+ {isRefreshing &&
}
+ {updatedChatRooms
+ .map(room => {
+ const maleCount = room.maleCount;
+ const femaleCount = room.femaleCount;
+
+ const isExpanded = expandedRoomIds.includes(room.id); // 현재 방이 확장되었는지 확인
+ return (
+
+
goChatRoom(room.id)}>
+
+
+
+
+
+ {/* /사진수정/ */}
+

+
{room.title}
+
남: {maleCount} 여: {femaleCount}
+
{room.subTitle}
+
+
toggleExpand(room.id)}>
+
+ 참여인원 보기
+ {!isExpanded ? :
+ }
+
+
+ {/* 확장된 상태일 때만 멤버 리스트를 렌더링 */}
+
+
+
+
+
+
+
+
+
+
+ );
+ })}
+
+ )
+}
+
+
+export default EnterCheckPage;
\ No newline at end of file
diff --git a/src/page/Chat/MakeChatRoom/MakeChatRoom.css b/src/page/Chat/MakeChatRoom/MakeChatRoom.css
new file mode 100644
index 0000000..bf09277
--- /dev/null
+++ b/src/page/Chat/MakeChatRoom/MakeChatRoom.css
@@ -0,0 +1,255 @@
+.makeChatRoom {
+
+ height: 812px;
+ width: 375px;
+ margin: 0 auto;
+
+ .margin-container {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ margin: 0 10px;
+ }
+
+ .title {
+ width: 100%;
+ height: 46px;
+ margin-top: 50px;
+ background: #ffffff;
+ display: flex;
+ text-align: center;
+ margin-left: 6px;
+ justify-content: space-between;
+ }
+
+ .title-name {
+ /* 채팅방 이름 */
+
+ padding-top: 15px;
+ width: 120px;
+ height: 18px;
+
+ cursor: pointer;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+ /* identical to box height, or 112% */
+ display: flex;
+ align-items: center;
+
+ color: #3D3D3D;
+
+
+ }
+
+ .small-title {
+ /* 채팅방 정보 */
+ margin-top: 20px;
+ width: 73px;
+ height: 18px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+
+ color: #3D3D3D;
+
+ }
+
+ .top {
+ width: 100%;
+ display: flex;
+ flex-direction: row;
+ gap: 20px;
+ height: 80px;
+ margin-bottom: 20px;
+ justify-content: space-between;
+
+ }
+
+
+ .chat-room-info {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-top: 5px;
+ }
+
+
+
+ .top img {
+ border: 1px solid #ccc;
+ border-radius: 50%;
+ width: 80px;
+ height: 100%;
+ /* background-color: none; */
+ }
+
+
+ .edit-avatar {
+ border: 1px solid #ccc;
+ border-radius: 50%;
+ position: relative;
+ width: 20px;
+ height: 20px;
+ left: -110px;
+ top: 80px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background: #F5F5F5;
+ }
+
+ .chat-room-name {
+
+
+ width: 230px;
+ background: #F5F5F5;
+ border-radius: 10px;
+ margin: auto 0px;
+ height: 50px;
+ border: 1px solid #ccc;
+ padding: 0 10px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 14px;
+ line-height: 16px;
+ color: #777777;
+ }
+
+ .chat-room-description {
+
+ width: 335px;
+ height: 100px;
+
+ background: #F5F5F5;
+ border-radius: 10px;
+
+ border: 1px solid #ccc;
+ border-radius: 10px;
+ font-size: 14px;
+
+
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 10px;
+ color: #777777;
+ }
+
+ .members-settings {
+ margin-top: 50px;
+ margin-bottom: 20px;
+ }
+
+ .small-title2 {
+ width: 73px;
+ height: 18px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 16px;
+ line-height: 18px;
+ margin-bottom: 30px;
+ color: #3D3D3D;
+ }
+
+ .gender-settings {
+ margin-left: 10px;
+ display: flex;
+ flex-direction: column;
+ gap: 15px;
+ }
+
+
+ .gender-settings div {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 10px;
+ }
+
+ .gender-settings span {
+
+ width: 25px;
+ height: 16px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 14px;
+ line-height: 16px;
+
+
+ color: #3D3D3D;
+ }
+
+
+
+ .count-button {
+
+ padding: 5px 15px;
+ border-radius: 20px;
+ border: 1px solid #ccc;
+ background-color: #fff;
+ cursor: pointer;
+ }
+
+ .count-button.active {
+ background-color: #FF7898;
+ border-color: #ccc;
+ color: #F5F5F5;
+ }
+
+
+
+ .note {
+ margin-top: 50px;
+ font-size: 12px;
+ color: #888;
+ margin-bottom: 20px;
+ }
+
+ .create-room-button {
+ /* Rectangle 13 */
+ margin: 5px auto;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 700;
+ font-size: 18px;
+ line-height: 20px;
+ color: #FFFFFF;
+ background: #FF7898;
+ width: 343px;
+ height: 50px;
+ background: #FF7898;
+ border-radius: 5px;
+ border: none;
+ }
+
+ .create-room-button:hover {
+ background-color: #FF7898;
+ }
+
+ .error {
+ margin-left: 7px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 12px;
+ line-height: 14px;
+ display: flex;
+ align-items: center;
+ color: #FF3131;
+ }
+
+}
\ No newline at end of file
diff --git a/src/page/Chat/MakeChatRoom/MakeChatRoom.jsx b/src/page/Chat/MakeChatRoom/MakeChatRoom.jsx
new file mode 100644
index 0000000..609dd7a
--- /dev/null
+++ b/src/page/Chat/MakeChatRoom/MakeChatRoom.jsx
@@ -0,0 +1,224 @@
+import React, { useState, useRef } from "react";
+import './MakeChatRoom.css'
+import { useNavigate } from 'react-router-dom';
+import Pic1 from '../../../asset/ChatRoomPic1.png'
+import Pic2 from '../../../asset/ChatRoomPic2.png'
+import Pic3 from '../../../asset/ChatRoomPic3.png'
+import Pic4 from '../../../asset/ChatRoomPic4.png'
+import Pic5 from '../../../asset/ChatRoomPic5.png'
+import Pic6 from '../../../asset/ChatRoomPic6.png'
+import { makeChatRoom } from '../../../api/chatRoom/makeChatRoom';
+
+
+
+function MakeChatRoom() {
+
+ const profileImages = [
+ Pic1, Pic2, Pic3, Pic4, Pic5, Pic6
+ ]
+ const getRandomImage = () => {
+ return profileImages[Math.floor(Math.random() * profileImages.length)];
+ };
+
+ const navigate = useNavigate();
+
+ const [count, setCount] = useState(3);
+ const [roomTitle, setRoomTitle] = useState('');
+ const [subTitle, setSubTitle] = useState('');//30자 이내로 제한
+ const [profileImage, setProfileImage] = useState(getRandomImage());
+ const [error, setError] = useState('');
+
+ const handleNavigation = (destination) => {
+ switch (destination) {
+ case 'play':
+ window.location.reload();
+ break;
+ case 'talk':
+ navigate('/ChatStartPage'); // 페이지 새로고침 (필요에 따라 이 부분을 변경)
+ break;
+ case 'my':
+ navigate('/myPage');
+ break;
+ default:
+ break;
+ }
+ };
+
+ const fileInputRef = useRef(null);
+
+ const handleImageClick = () => {
+ fileInputRef.current.click();
+ };
+
+ const handleImageChange = (event) => {
+ const file = event.target.files[0];
+ if (file) {
+ const reader = new FileReader();
+ reader.onloadend = () => {
+ setProfileImage(reader.result);
+ };
+ reader.readAsDataURL(file);
+ }
+ };
+
+
+ const handleTitleChange = (e) => {
+ if (e.target.value.length <= 20) {
+ setRoomTitle(e.target.value);
+ }
+ };
+
+ const handleSubTitleChange = (e) => {
+ if (e.target.value.length <= 50) {
+ setSubTitle(e.target.value);
+ }
+ };
+
+ const makeRoom = async () => {
+ if (roomTitle === '' || subTitle === '') {
+ setError('모든 필드를 입력해 주세요.');
+ return;
+ }
+
+ try {
+ const numberOfMembers = count * 2;
+ const roomData = {
+ title: roomTitle,
+ subTitle: subTitle,
+ profileImage: profileImage,
+ maxMembers: numberOfMembers,
+ maleCount: count,
+ femaleCount: count
+ };
+
+ await makeChatRoom(roomData);
+ console.log("Room Created");
+ navigate('/ChatStartPage');
+ setError('');
+ } catch (error) {
+ setError(error.message);
+ }
+ };
+
+
+
+
+ return (
+ <>
+
+
+
+
navigate('/ChatStartPage')} >
+
+
+ 채팅방 만들기
+
+
+
+
+
채팅방 정보
+
+
+
+
+

+
+
+
+
+
+
+
인원 설정
+
+
+ 남자
+ {[2, 3, 4, 5].map(cnt => (
+
+ ))}
+
+
+
+ 여자
+ {[2, 3, 4, 5].map(cnt => (
+
+ ))}
+
+
+
+
+
+ {/* 로직추가 */}
+ - 생성된 채팅방은 30일 후에 자동으로 종료됩니다.
+
+
+ {/* Display error message if needed */}
+ {error &&
+ {error}
}
+
+
+
+
+
+
+
+
+
handleNavigation('play')}>
+
handleNavigation('talk')}>
+
handleNavigation('my')}>
+
+
+
+
+
+ >
+ );
+}
+
+export default MakeChatRoom;
\ No newline at end of file
diff --git a/src/page/Chat/NoEnterCheckPage.jsx b/src/page/Chat/NoEnterCheckPage.jsx
new file mode 100644
index 0000000..f7f985e
--- /dev/null
+++ b/src/page/Chat/NoEnterCheckPage.jsx
@@ -0,0 +1,273 @@
+import React, { useState, useEffect } from "react";
+import './ChatPage.css'
+import OkayDialog from './Dialog/OkayDialog'
+import MaxMemberDialog from './Dialog/MaxMemberDialog'
+import MaxChanceDialog from './Dialog/MaxChanceDialog'
+import { fetchRoomParticipants } from "../../api/chatRoom/fetchRoomParticipants";
+
+function NoEnterCheckPage(props) {
+ const { chatRooms, possibleEnterNumber, gender, isEnterCheck } = props;
+ const [expandedRoomIds, setExpandedRoomIds] = useState([]);
+ const [okayDialog, setOkayDialog] = useState(false);
+ const [maxMemberDialog, setMaxMemberDialog] = useState(false);
+ const [maxChanceDialog, setMaxChanceDialog] = useState(false);
+ const [selectChatRoom, setSelectChatRoom] = useState(false);
+
+
+ const [updatedChatRooms, setUpdatedChatRooms] = useState(
+ chatRooms.filter(room => room.enterCheck === false)
+ );
+
+
+
+
+ //새로고침
+ const [startY, setStartY] = useState(0);
+ const [translateY, setTranslateY] = useState(0);
+ const [isRefreshing, setIsRefreshing] = useState(false);
+
+
+
+ const threshold = 80; // 새로고침을 트리거하는 기준 거리
+
+ // 새로고침 함수
+ const handleRefresh = () => {
+ setIsRefreshing(true);
+ setTimeout(() => {
+ setIsRefreshing(false);
+ isEnterCheck(false); // 페이지 새로고침 (필요에 따라 이 부분을 변경)
+ }, 1500);
+ };
+
+ // 터치 시작
+ const handleTouchStart = (event) => {
+ setStartY(event.touches[0].clientY);
+ };
+
+ // 터치 중일 때
+ const handleTouchMove = (event) => {
+ const currentY = event.touches[0].clientY;
+ const distance = currentY - startY;
+
+
+ // 스크롤이 최상단일 때만 동작
+ if (window.scrollY === 0 && distance > 0) {
+ setTranslateY(distance * 0.3); // 끌린 만큼 translateY 값을 설정
+ }
+
+ // 기준 거리를 넘었을 때 새로고침
+ if (distance > threshold) {
+ handleRefresh();
+ }
+ };
+
+ // 터치 끝
+ const handleTouchEnd = () => {
+ setTranslateY(0); // 터치가 끝나면 원래 위치로 돌아가기
+ };
+
+
+ useEffect(() => {
+ if (expandedRoomIds.length > 0) {
+ const updateMembers = async () => {
+ const updatedRooms = await Promise.all(
+ updatedChatRooms.map(async (room) => {
+ if (room.id === expandedRoomIds[expandedRoomIds.length - 1]) {
+ const updatedMembers = await fetchRoomParticipants(room.id);
+ return {
+
+ ...room,
+ members: updatedMembers,
+ maleCount: updatedMembers.filter(member => member.gender === "남자").length,
+ femaleCount: updatedMembers.filter(member => member.gender === "여자").length
+ };
+ }
+ return room;
+ })
+ );
+
+ setUpdatedChatRooms(updatedRooms);
+ };
+
+ updateMembers();
+ }
+ }, [expandedRoomIds, isEnterCheck, chatRooms]);
+
+
+ //전에꺼
+ // // expandedRoomIds가 변경될 때마다 서버에서 members를 가져와 업데이트하는 useEffect
+ // useEffect(() => {
+ // if (expandedRoomIds.length > 0) {
+ // const fetchRoomDetails = async (roomId) => {
+ // try {
+ // const response = await api.get(`/api/chatroom/participants/${roomId}`);
+ // return response.data; // 서버로부터 members를 받아옴
+ // } catch (error) {
+ // console.error(`Error fetching room details for roomId: ${roomId}`, error);
+ // return [];
+ // }
+ // };
+
+ // const updateMembers = async () => {
+ // const updatedRooms = await Promise.all(
+ // chatRooms.map(async (room) => {
+ // if (room.id === expandedRoomIds[expandedRoomIds.length - 1]) {
+ // const updatedMembers = await fetchRoomDetails(room.id);
+ // return { ...room, members: updatedMembers };
+ // }
+ // console.log(updatedChatRooms);
+ // return room;
+ // })
+ // );
+
+ // setUpdatedChatRooms(updatedRooms);
+ // };
+
+ // updateMembers();
+ // }
+ // }, [expandedRoomIds,isEnterCheck]); // expandedRoomIds가 변경될 때마다
+
+
+
+
+
+
+
+ const toggleExpand = (roomId) => {
+ setExpandedRoomIds(prevState =>
+ prevState.includes(roomId)
+ ? prevState.filter(id => id !== roomId) // 이미 확장된 상태면 닫기
+ : [...prevState, roomId] // 확장되지 않았다면 추가
+ );
+ };
+
+ const enterCheckMessage = (chatRoom) => {
+ const halfMaxMembers = Math.floor(chatRoom.maxMembers / 2); // 최대 인원의 절반 계산
+ let maleCount = chatRoom.maleCount;
+ let femaleCount = chatRoom.femaleCount;
+
+ // 유저가 남자일 때: 남성 인원이 절반보다 적으면 true
+ if (gender === "남자" && maleCount < halfMaxMembers) {
+ return true;
+ }
+
+ // 유저가 여자일 때: 여성 인원이 절반보다 적으면 true
+ if (gender === "여자" && femaleCount < halfMaxMembers) {
+ return true;
+ }
+
+ // 그 외에는 참가 불가
+ return false;
+ };
+
+ const dialogOpen = (room) => {
+ if (!enterCheckMessage(room)) {
+ setMaxMemberDialog(true);
+ } else if (possibleEnterNumber === 0) {
+ setMaxChanceDialog(true)
+ } else {
+ setSelectChatRoom(room)
+ setOkayDialog(true);
+ }
+ }
+
+
+
+
+
+
+
+
+ return (
+ <>
+ {/* 다이얼로그 컴포넌트들 */}
+
setOkayDialog(false)} />
+ setMaxMemberDialog(false)} />
+ setMaxChanceDialog(false)} />
+
+
+ {isRefreshing &&
}
+
+ {updatedChatRooms
+ .map(room => {
+ const maleCount = room.maleCount;
+ const femaleCount = room.femaleCount;
+
+ const isExpanded = expandedRoomIds.includes(room.id); // 현재 방이 확장되었는지 확인
+ return (
+
+
dialogOpen(room)}>
+ {enterCheckMessage(room) ?
참여가능
:
참여불가
}
+
{room.title}
+
+ 남 {enterCheckMessage(room) ? {maleCount} : {maleCount}}/{room.maxMembers / 2}
+ 여 {enterCheckMessage(room) ? {femaleCount} : {femaleCount}}/{room.maxMembers / 2}
+
+
+
{room.subTitle}
+
+
toggleExpand(room.id)}>
+
+ 참여인원 보기
+ {!isExpanded ? :
+ }
+
+
+ {/* 확장된 상태일 때만 멤버 리스트를 렌더링 */}
+
+
+
+ );
+ })}
+
+ >
+ )
+
+}
+
+
+
+export default NoEnterCheckPage;
\ No newline at end of file
diff --git a/src/page/Login/Login.css b/src/page/Login/Login.css
new file mode 100644
index 0000000..a99a284
--- /dev/null
+++ b/src/page/Login/Login.css
@@ -0,0 +1,430 @@
+.LoginPage {
+ height: 812px;
+ width: 375px;
+ margin: 0 auto;
+
+ .container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ font-family: 'Pretendard', sans-serif;
+ height: 100%;
+ }
+
+ .login-heading {
+ width: 300px;
+ height: 24px;
+ margin-top: 50px;
+ margin-bottom: 5px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 20px;
+ line-height: 24px;
+ align-items: center;
+ color: #3D3D3D;
+ }
+
+ .login-subtext {
+ /* 안전한 인피 활동을 위해 학교 인증이 필요해요 */
+ width: 300px;
+ height: 18px;
+ margin-bottom: 50px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 16px;
+ align-items: center;
+ color: #3D3D3D;
+ }
+
+ .password-input {
+ /* 이메일 입력창 */
+ width: 290px;
+ height: 46px;
+ margin-top: 1px;
+ /* 상단 여백 */
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .header {
+ /* 상단 헤더 */
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ }
+
+ .back-button {
+ /* 왼쪽 꺽쇠 */
+ border: none;
+ background-color: transparent;
+ font-size: 24px;
+ cursor: pointer;
+ width: 22px;
+ height: 22px;
+ margin-top: 80px;
+ align-self: flex-start;
+ }
+
+ .button-container {
+ margin-top: auto;
+ }
+
+ .bottom-Button {
+ /* 하단 버튼 */
+ width: 300px;
+ height: 50px;
+
+ color: #F7F7F7;
+ background: #FF7898;
+ border-radius: 8px;
+ border-color: rgb(255, 255, 255);
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 700;
+ font-size: 18px;
+
+ margin-bottom: 40px;
+ margin-top: auto;
+
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .bottom-Button:disabled {
+ background-color: #dadada;
+ color: white;
+ }
+
+ .error-message {
+ color: red;
+ font-size: 0.5em;
+
+ width: 320px;
+ height: 14px;
+
+ }
+
+ .email-input {
+ /* 이메일 입력창 */
+ width: 290px;
+ height: 46px;
+ margin-top: 1px;
+ /* 상단 여백 */
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ }
+
+ .code-inputs {
+ /* 인증번호 입력 */
+ display: flex;
+ justify-content: center;
+ gap: 10px;
+ /* 입력 필드 사이의 간격 */
+ }
+
+ .code-input {
+ width: 35px;
+ /* 네모 박스 너비 */
+ height: 35px;
+ /* 네모 박스 높이 */
+ font-size: 16px;
+ text-align: center;
+ border: 1px solid #ccc;
+ /* 테두리 */
+ border-radius: 5px;
+ /* 모서리를 둥글게 */
+ margin-bottom: 40px;
+
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .resend {
+ /* 메일을 못받으셨나요? */
+ width: 450px;
+ height: 16px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 14px;
+ line-height: 16px;
+
+ margin-left: 160px;
+ margin-bottom: 330px;
+ color: #8C8C8C;
+ }
+
+ .login-subtext1 {
+ width: 300px;
+ height: 18px;
+ margin-bottom: 20px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 16px;
+ display: flex;
+ align-items: center;
+ color: #3D3D3D;
+ }
+
+ .header {
+ /* 상단 헤더 */
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ }
+
+ /* 실행 단계 배경 CSS */
+ .progress-bar {
+ width: 240px;
+ height: 10px;
+ margin-top: 90px;
+ align-self: flex-start;
+ margin-right: 70px;
+ background: #D9D9D9;
+ border-radius: 50px;
+ }
+
+ /* 실행 단계 CSS */
+ .progress {
+ height: 100%;
+ background-color: #ff7096;
+ border-radius: 10px;
+ }
+
+ .password-input {
+ /* 비밀번호 입력창 */
+ width: 290px;
+ height: 46px;
+ margin-bottom: 30px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+
+ .repassword-input {
+ /* 비밀번호 확인창 */
+ width: 290px;
+ height: 46px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ }
+
+ .error-message,
+ .error-message1 {
+ color: red;
+ font-size: 0.5em;
+ margin-left: 20px;
+ margin-top: 10px;
+ width: 320px;
+ height: 14px;
+ /* 고정된 높이 설정 */
+ visibility: hidden;
+ /* 기본적으로 메시지를 숨김 */
+ }
+
+ .error-message.visible,
+ .error-message1.visible {
+ visibility: visible;
+ /* 에러가 있을 때만 보이도록 */
+ }
+
+ .login4-input {
+ /* 닉네임 입력창 */
+ width: 295px;
+ height: 50px;
+ margin-bottom: 15px;
+ }
+
+ .check-button {
+ /* 중복 확인 버튼 */
+ width: 300px;
+ height: 50px;
+ background: #FF7898;
+ border-radius: 8px;
+ color: #fff;
+ font-size: 16px;
+ border: none;
+ border-radius: 5px;
+ cursor: pointer;
+ margin-bottom: 10px;
+ }
+
+ .gender-options {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 22px;
+ margin-bottom: 10px;
+ }
+
+ .rectangle,
+ .rectangle1 {
+ box-sizing: border-box;
+ width: 140px;
+ height: 140px;
+ /* 높이 조정 */
+ background: #FFFFFF;
+ border: 2px solid #DADADA;
+ border-radius: 3px;
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-start;
+ /* 이미지와 텍스트를 위쪽 정렬 */
+ align-items: center;
+ padding-top: 10px;
+ /* 이미지와 텍스트 사이에 패딩 추가 */
+ }
+
+ .rectangle.selected {
+ background-color: #EAF0FF;
+ }
+
+ .rectangle1.selected {
+ background-color: #FFF0EF;
+ }
+
+ .boy-image {
+ width: 170px;
+ height: 240px;
+ margin-top: -63px;
+ background-size: contain;
+ background-position: center;
+ background-repeat: no-repeat;
+ }
+
+ .girl-image {
+ width: 80px;
+ height: 110px;
+ margin-top: -5px;
+ background-size: contain;
+ background-position: center;
+ background-repeat: no-repeat;
+ }
+
+ .boyplace {
+ margin-top: -78px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 20px;
+ line-height: 24px;
+ display: flex;
+ justify-content: center;
+ text-align: center;
+ color: #3D3D3D;
+
+ }
+
+ .girlplace {
+ margin-top: 0px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 20px;
+ margin-top: -5px;
+ line-height: 24px;
+ display: flex;
+ justify-content: center;
+ text-align: center;
+ color: #3D3D3D;
+ }
+
+ .login5-heading {
+ width: 300px;
+ height: 24px;
+ margin-top: 50px;
+ margin-bottom: 30px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 20px;
+ line-height: 24px;
+ display: flex;
+ align-items: center;
+ color: #3D3D3D;
+ }
+
+ /* 단과대 선택 */
+ .input {
+ width: 100%;
+ padding: 10px;
+ font-size: 16px;
+ margin-top: 5px;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ }
+
+ .student-id {
+ /* 학번 입력창 */
+ width: 290px;
+ height: 46px;
+ margin-bottom: 100px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ }
+
+ .select-container1 {
+ /* 단과대 선택창 */
+ width: 282px;
+ height: 50px;
+ margin-bottom: 20px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 400;
+ font-size: 16px;
+ line-height: 18px;
+ }
+
+ .select-container2 {
+ /* 학과 선택창 */
+ width: 282px;
+ height: 50px;
+ height: 20px;
+ }
+
+ .select-department {
+ width: 100%;
+ padding: 10px;
+ font-size: 16px;
+ margin-top: 5px;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ }
+
+ .year-month-day-container {
+ display: flex;
+ gap: 10px;
+ margin-bottom: 410px;
+ }
+
+ .year-input {
+ width: 85px;
+ height: 46px;
+ }
+
+ .month-input {
+ width: 85px;
+ height: 46px;
+ }
+
+ .day-input {
+ width: 85px;
+ height: 46px;
+ }
+}
\ No newline at end of file
diff --git a/src/page/Login/Login.jsx b/src/page/Login/Login.jsx
new file mode 100644
index 0000000..951af35
--- /dev/null
+++ b/src/page/Login/Login.jsx
@@ -0,0 +1,90 @@
+import React, { useState } from "react";
+import { useNavigate } from 'react-router-dom';
+import { IoChevronBack } from "react-icons/io5";
+import { postLogin } from "../../api/postLogin";
+import './Login.css';
+
+// 로그인
+const Login = () => {
+ const [password, setPassword] = useState("");
+ const [error, setError] = useState("");
+ const navigate = useNavigate();
+
+
+ const handleNext = async () => {
+ if (password.trim() === "") {
+ setError("비밀번호를 입력해주세요.");
+ return;
+ }
+
+ const storedEmail = localStorage.getItem('userEmail');
+ const logindata = {
+ schoolEmail: storedEmail,
+ password: password
+ }
+ try {
+ const loginResponse = await postLogin(logindata);
+ console.log("로그인 응답:", loginResponse); // 전체 응답 출력
+ // 응답에서 액세스 토큰 추출
+ // 이곳에서 loginResponse.headers를 제대로 접근할 수 있는지 확인
+ const accessToken = loginResponse.headers?.authorization; // Optional chaining 추가
+ if (!accessToken) {
+ throw new Error("Access token not found in response headers");
+ }
+
+ const token = accessToken.split(' ')[1]; // 'Bearer ' 제거
+
+ localStorage.setItem('accessToken', token);
+ navigate('/ChatStartPage');
+ } catch (error) {
+ console.error('Error posting email data:', error);
+ }
+
+ };
+
+ const handleBack = () => {
+ navigate('/'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
비밀번호를 입력해주세요
+
가입하실 때 설정한 비밀번호를 입력하세요
+
+
{
+ setPassword(e.target.value);
+ setError(""); // 에러 메시지 초기화
+ }}
+ />
+ {error && (
+
{error}
// 에러 메시지 출력
+ )}
+
+
+
+
+
+
+ );
+};
+
+export default Login;
\ No newline at end of file
diff --git a/src/page/Login/Login1.jsx b/src/page/Login/Login1.jsx
new file mode 100644
index 0000000..9764324
--- /dev/null
+++ b/src/page/Login/Login1.jsx
@@ -0,0 +1,80 @@
+import React, { useContext, useState } from "react";
+import { useNavigate } from 'react-router-dom';
+import { IoChevronBack } from "react-icons/io5";
+import { postMail } from "../../api/postMail";
+import './Login.css';
+import { UserContext } from "../../context/UserContext";
+
+// 메일 인증 / 작성
+const Login1 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [email, setEmail] = useState("");
+ const navigate = useNavigate();
+
+ const handleInputChange = (e) => {
+ setEmail(e.target.value);
+ };
+
+ const handleButtonClick = async (e) => {
+ e.preventDefault();
+ if (email) {
+ console.log(`Verification code sent to: ${email}`);
+ updateUser({ schoolEmail: email });
+ console.log("context updated");
+
+ // 이메일을 로컬 스토리지에 저장
+ localStorage.setItem('userEmail', email);
+ console.log("Email saved to localStorage");
+
+ } else {
+ console.log("Please enter a valid email");
+ return; // 유효하지 않은 이메일일 경우 함수 종료
+ }
+
+ try {
+ await postMail(email);
+ console.log('email data posted successfully');
+ navigate('/login2');
+ } catch (error) {
+ console.error('Error posting email data:', error);
+ }
+ };
+
+ const handleBack = () => {
+ navigate('/'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
학교 이메일을 입력해 주세요
+
안전한 인피 활동을 위해 학교 인증이 필요해요
+
+
+
+
+
+
+
+ );
+};
+
+export default Login1;
diff --git a/src/page/Login/Login2.jsx b/src/page/Login/Login2.jsx
new file mode 100644
index 0000000..56d7e42
--- /dev/null
+++ b/src/page/Login/Login2.jsx
@@ -0,0 +1,119 @@
+import React, { useState, useEffect, useContext } from "react";
+import { useNavigate } from "react-router-dom";
+import { IoChevronBack } from "react-icons/io5";
+import { postMailCheck } from "../../api/postMailCheck";
+import { postMail } from "../../api/postMail";
+import { UserContext } from "../../context/UserContext";
+import './Login.css';
+
+// 메일 인증 / 인증번호 입력
+const Login2 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [code, setCode] = useState(new Array(6).fill("")); // 6자리 코드 입력 관리
+ const navigate = useNavigate();
+ const [email, setEmail] = useState(""); // 세션 스토리지에서 가져올 이메일 상태
+
+ useEffect(() => {
+ // 로컬 스토리지에서 이메일 값을 불러옵니다.
+ const storedEmail = localStorage.getItem('userEmail');
+ if (storedEmail) {
+ setEmail(storedEmail);
+ if (User.email !== storedEmail) { // 이메일이 다를 경우에만 업데이트
+ updateUser({ email: storedEmail }); // Context에 이메일 업데이트
+ }
+ }
+ }, [User.email, updateUser]); // User.email을 의존성으로 추가
+
+ const handleInputChange = (element, index) => {
+ let newCode = [...code];
+ const inputValue = element.value;
+
+ // 사용자가 입력을 했을 때
+ newCode[index] = inputValue;
+ setCode(newCode);
+
+ // 입력 후 다음 필드로 이동
+ if (inputValue && element.nextSibling) {
+ element.nextSibling.focus();
+ }
+ };
+
+ const handleKeyDown = (event, index) => {
+ // 백스페이스 키가 눌렸을 때
+ if (event.key === 'Backspace' && code[index] === "") {
+ if (event.target.previousSibling) {
+ event.target.previousSibling.focus(); // 이전 입력 필드로 포커스 이동
+ }
+ }
+ };
+
+
+ const handleResend = async () => {
+ try {
+ await postMail(email);
+ console.log('Email data posted successfully');
+ navigate('/login2');
+ } catch (error) {
+ console.error('Error posting email data:', error);
+ }
+ };
+
+ const handleSubmit = async () => {
+ const enteredCode = code.join("");
+ console.log(`Entered code: ${enteredCode}`);
+
+ try {
+ await postMailCheck(email, enteredCode);
+ console.log('Key data posted successfully');
+ navigate("/login3");
+ } catch (error) {
+ console.error('Error posting key data:', error);
+ }
+ };
+
+ const handleBack = () => {
+ navigate('/login1'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
인증 메일이 보내졌습니다
+
인증 번호 6자리를 입력해주세요
+
+
+ {code.map((digit, index) => (
+ handleInputChange(e.target, index)}
+ onKeyDown={(e) => handleKeyDown(e, index)} // onKeyDown 이벤트 추가
+ onFocus={(e) => e.target.select()}
+ />
+ ))}
+
+
+ 메일을 못받으셨나요?
+ 다시 받기
+
+
+
+
+
+
+ );
+};
+
+export default Login2;
diff --git a/src/page/Login/Login3.jsx b/src/page/Login/Login3.jsx
new file mode 100644
index 0000000..02d9cbb
--- /dev/null
+++ b/src/page/Login/Login3.jsx
@@ -0,0 +1,127 @@
+import React, { useState, useContext } from "react";
+import { useNavigate } from "react-router-dom";
+import { IoChevronBack } from "react-icons/io5";
+import { UserContext } from "../../context/UserContext";
+import './Login.css';
+
+// 비밀번호 설정 페이지
+const Login3 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [password, setPassword] = useState("");
+ const [confirmPassword, setConfirmPassword] = useState("");
+ const [passwordError, setPasswordError] = useState("");
+ const [confirmPasswordError, setConfirmPasswordError] = useState("");
+
+ const navigate = useNavigate();
+
+ // 비밀번호 유효성 검사 함수
+ const validatePassword = (value) => {
+ const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*])[A-Za-z\d!@#$%^&*]{8,}$/;
+ return passwordRegex.test(value);
+ };
+
+ // 비밀번호 입력 처리
+ const handlePasswordChange = (e) => {
+ const newPassword = e.target.value;
+ setPassword(newPassword);
+
+ if (!validatePassword(newPassword)) {
+ setPasswordError("비밀번호는 영문, 숫자, 특수문자를 포함한 8자 이상이어야 합니다");
+ } else {
+ setPasswordError("");
+ }
+
+ if (newPassword !== confirmPassword && confirmPassword) {
+ setConfirmPasswordError("비밀번호가 일치하지 않습니다");
+ } else {
+ setConfirmPasswordError("");
+ }
+ };
+
+ // 비밀번호 확인 입력 처리
+ const handleConfirmPasswordChange = (e) => {
+ const newConfirmPassword = e.target.value;
+ setConfirmPassword(newConfirmPassword);
+
+ if (newConfirmPassword !== password) {
+ setConfirmPasswordError("비밀번호가 일치하지 않습니다");
+ } else {
+ setConfirmPasswordError("");
+ }
+ };
+
+ // 뒤로 가기 처리
+ const handleBack = () => {
+ navigate('/login2');
+ };
+
+ // 제출 처리
+ const handleSubmit = () => {
+ if (!passwordError && !confirmPasswordError && password && confirmPassword) {
+ updateUser({password: password});
+ console.log("비밀번호 설정 완료:", password, User);
+ navigate("/login4");
+ } else {
+ console.log("비밀번호 설정 오류");
+ }
+ };
+ return (
+
+
+
+
+
+
비밀번호를 설정해주세요
+
영문, 숫자, 특수문자를 조합하여 8자 이상으로 설정해주세요
+
+
+
+ {/* 비밀번호 유효성 검사 에러 메시지 */}
+
+ {passwordError}
+
+
+
+
+
+
+ {/* 비밀번호 확인 에러 메시지 */}
+
+ {confirmPasswordError}
+
+
+
+
+
+
+
+
+ );
+};
+
+export default Login3;
diff --git a/src/page/Login/Login4.jsx b/src/page/Login/Login4.jsx
new file mode 100644
index 0000000..54ed62f
--- /dev/null
+++ b/src/page/Login/Login4.jsx
@@ -0,0 +1,100 @@
+import React, { useState, useContext } from "react";
+import { useNavigate } from "react-router-dom";
+import './Login.css';
+import { IoChevronBack } from "react-icons/io5";
+import { UserContext } from "../../context/UserContext";
+import { getIsNickExist } from "../../api/getIsNickExist";
+
+// 닉네임 설정
+const Login4 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [nickname, setNickname] = useState("");
+ const [isNicknameChecked, setIsNicknameChecked] = useState(false); // 중복 확인 완료 상태
+ const navigate = useNavigate();
+
+ const handleCheckNickname = async () => {
+ if (nickname.length >= 2 && nickname.length <= 20) {
+ try {
+ const response = await getIsNickExist(nickname);
+
+ if (response.data === false) {
+ console.log('닉네임 중복 확인 완료');
+ setIsNicknameChecked(true); // 중복 확인 완료
+ alert("닉네임 확인 완료");
+ } else {
+ console.error('닉네임 중복 확인 실패:', response);
+ setIsNicknameChecked(false);
+ alert("닉네임이 이미 존재합니다.");
+ }
+
+ } catch (error) {
+ console.error('Error posting nickname data:', error);
+ setIsNicknameChecked(false); // 중복 확인 실패 시 버튼 비활성화 유지
+ }
+ } else {
+ setIsNicknameChecked(false); // 중복 확인 실패 시 버튼 비활성화 유지
+ alert("닉네임은 2자 이상, 20자 이하로 입력해주세요.");
+ }
+ };
+
+ const handleNext = () => {
+ if (nickname.length >= 2 && nickname.length <= 20 && isNicknameChecked) {
+ updateUser({nickname:nickname});
+ console.log(User);
+ navigate("/login5", { state: { nickname } });
+ } else {
+ alert("닉네임을 다시 확인해주세요.");
+ }
+ };
+
+ const handleBack = () => {
+ navigate('/login3'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
+
닉네임을 입력해주세요
+
한글로만 2자 이상, 20자 이하로 가능해요
+
+
{
+ setNickname(e.target.value);
+ setIsNicknameChecked(false); // 닉네임이 변경될 때마다 중복 확인 초기화
+ }}
+ />
+
+
+
+
+
+
+
+
+ );
+};
+
+export default Login4;
\ No newline at end of file
diff --git a/src/page/Login/Login5.jsx b/src/page/Login/Login5.jsx
new file mode 100644
index 0000000..7cfbfe7
--- /dev/null
+++ b/src/page/Login/Login5.jsx
@@ -0,0 +1,81 @@
+import React, { useState, useContext } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { IoChevronBack } from "react-icons/io5";
+import './Login.css';
+import boyImage from '../../asset/boy.png';
+import girlImage from '../../asset/girl.png';
+import { UserContext } from "../../context/UserContext";
+
+// 성별 입력
+const Login5 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [selectedGender, setSelectedGender] = useState(null);
+ const navigate = useNavigate();
+
+ const handleGenderSelect = (gender) => {
+ setSelectedGender(gender);
+ };
+
+ const handleSubmit = () => {
+ if (selectedGender) {
+ console.log(`선택된 성별: ${selectedGender}`);
+ updateUser({gender:selectedGender});
+ console.log(User);
+ navigate('/login6', { state: { gender: selectedGender } });
+ }
+ };
+
+ const handleBack = () => {
+ navigate('/login4'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
춘식이님의 성별을 알려주세요
+
+
handleGenderSelect('남성')}
+ >
+
+

+
남성
+
+
+
handleGenderSelect('여성')}
+ >
+
+

+
여성
+
+
+
+
+
+
+
+
+ );
+};
+
+export default Login5;
\ No newline at end of file
diff --git a/src/page/Login/Login6.jsx b/src/page/Login/Login6.jsx
new file mode 100644
index 0000000..f084530
--- /dev/null
+++ b/src/page/Login/Login6.jsx
@@ -0,0 +1,128 @@
+import React, { useState, useContext } from "react";
+import { useNavigate } from "react-router-dom";
+import { IoChevronBack } from "react-icons/io5";
+import { UserContext } from "../../context/UserContext";
+import './Login.css';
+// 학번, 학과 입력
+const Login6 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [studentNumber, setStudentNumber] = useState("");
+ const [division, setDivision] = useState("");
+ const [department, setDepartment] = useState("");
+ const navigate = useNavigate();
+
+ // 단과대와 학과 정보를 정의
+ const divisionsAndDepartments = {
+ "인문대학": ["국어국문학과", "영어영문학과", "독어독문학과", "불어불문학과", "일어일문학과", "중어중문학과"],
+ "자연과학대학": ["수학과", "물리학과", "화학과", "패션산업학과", "해양학과"],
+ "사회과학대학": ["사회복지학과", "신문방송학과", "문헌정보학과", "창의인재개발학과"],
+ "글로벌정경대학" : ["행정학과", "정치외교학과", "경제학과", "무역학부", "소비자학과"],
+ "공과대학": ["기계공학과", "메카트로닉스공학과", "전기공학과", "전자공학과", "산업경영학과", "신소재공학과", "안전공학과", "에너지화학공학과"],
+ "정보기술대학" : ["컴퓨터공학부", "정보통신공학과","임베디드시스템공학과"],
+ "경영대학": ["경영학부", "세무회계학과"],
+ "예술체육대학": ["조형예술학부", "디자인학부", "공연예술학과", "체육학부", "운동건강학부"],
+ "사범대학": ["국어교육과", "영어교육과", "일어교육과", "수학교육과", "체육교육과", "유아교육과", "역사교육과", "윤리교육과"],
+ "도시과학대학": ["도시행정학과", "건설환경공학과", "환경공학과", "도시공학과", "도시건축학과"],
+ "생명과학기술": ["생명공학부", "생명공학부 생명공학전공", "생명공학부 나노바이오전공", "도시공학과"],
+ "동북아국제통상학부": ["동북아국제통상학부", "한국통상전공"],
+ "법학부":["법학부"]
+ };
+
+ const handleSubmit = (e) => {
+ e.preventDefault();
+ if (studentNumber && division && department) {
+ updateUser({
+ college:division,
+ studentId: studentNumber,
+ department:department
+ });
+ console.log('context updated:', User);
+ navigate("/login7");
+ } else {
+ alert("모든 항목을 입력해 주세요.");
+ }
+ };
+
+ const handleBack = () => {
+ navigate('/login5'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
춘식이님에 대해 알려주세요
+
학번 9자리를 입력해주세요
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default Login6;
\ No newline at end of file
diff --git a/src/page/Login/Login7.jsx b/src/page/Login/Login7.jsx
new file mode 100644
index 0000000..c33b693
--- /dev/null
+++ b/src/page/Login/Login7.jsx
@@ -0,0 +1,145 @@
+import React, { useState, useContext, useEffect } from "react";
+import { useNavigate } from "react-router-dom"; // useNavigate 추가
+import { IoChevronBack } from "react-icons/io5";
+import { UserContext } from "../../context/UserContext";
+import { postUser } from "../../api/postUser";
+import './Login.css';
+
+// 생년월일 입력
+const Login7 = () => {
+ const { User, updateUser } = useContext(UserContext);
+ const [year, setYear] = useState("");
+ const [month, setMonth] = useState("");
+ const [day, setDay] = useState("");
+ const [profile, setProfile] = useState("");
+ const navigate = useNavigate(); // navigate 초기화
+ const [birthdate, setBirthdate] = useState("");
+
+ useEffect(() => {
+ if (setYear | setDay | setMonth) {
+
+ console.log("Birthdate updated:", birthdate);
+
+ }
+ }, [setYear, setDay, setMonth]);
+
+ const isLeapYear = (year) => {
+ return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
+ };
+
+ const validateBirthdate = (year, month, day) => {
+ if (year.length !== 4 || month.length !== 2 || day.length !== 2) {
+ alert("생년월일을 정확히 입력해 주세요.");
+ return false;
+ }
+
+
+ // 형식 체크
+ if (!/^\d{4}$/.test(year) || !/^\d{2}$/.test(month) || !/^\d{2}$/.test(day)) {
+ alert("생년월일은 숫자만 포함해야 합니다.");
+ return false;
+ }
+
+ const yearNum = parseInt(year, 10);
+ const monthNum = parseInt(month, 10);
+ const dayNum = parseInt(day, 10);
+
+ // 월 범위 체크
+ if (monthNum < 1 || monthNum > 12) {
+ alert("월은 1에서 12 사이의 숫자여야 합니다.");
+ return false;
+ }
+
+ // 각 월에 따라 최대 일수 체크
+ const daysInMonth = [31, (isLeapYear(yearNum) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+
+ if (dayNum < 1 || dayNum > daysInMonth[monthNum - 1]) {
+ alert("입력한 날짜는 유효하지 않습니다.");
+ return false;
+ }
+ const birthdate = `${year}-${month}-${day}`;
+ setBirthdate(birthdate);
+ console.log("생일:", birthdate);
+ return true;
+ };
+ const handleSubmit = async (e) => {
+
+ e.preventDefault();
+
+ if (!validateBirthdate(year, month, day)) {
+ return;
+ }
+
+
+ try {
+ const randomImageIndex = Math.floor(Math.random() * 6);
+ await postUser({ ...User, profile: `${randomImageIndex}`, birthday: birthdate });
+ console.log('user data posted successfully');
+ navigate('/login');
+ } catch (error) {
+ console.error('Error posting user data:', error);
+ }
+
+
+ };
+
+ const handleBack = () => {
+ navigate('/login6'); // 이전 페이지로 이동
+ };
+
+ return (
+
+
+
+
+
+
+
춘식이님의 생일을 알려주세요
+
+
+
+
+
+
+
+ );
+};
+
+export default Login7;
diff --git a/src/page/Main/Main.css b/src/page/Main/Main.css
index e69de29..d86f5b5 100644
--- a/src/page/Main/Main.css
+++ b/src/page/Main/Main.css
@@ -0,0 +1,80 @@
+.MainPage {
+ height: 812px;
+ width: 375px;
+ margin: 0 auto;
+
+ .img-title {
+ /* 인피 로고 */
+ width: 95px;
+ height: 45px;
+ background: url('../../asset/logo.png');
+ background-size: contain;
+ margin-top: 100px; /* 상단 여백 */
+ margin-bottom: 20px;
+ align-self: flex-start;
+ margin-right: 170px;
+ }
+
+ .img-container{
+ display: flex;
+ justify-content: center
+ }
+
+ .img-bg {
+ /* 메인 이미지 */
+ width: 290px;
+ height: 211px;
+ background: url('../../asset/main.png');
+ background-size: contain;
+ margin-top: 10px;
+ margin-bottom: 50px;
+ }
+
+ .img-subtitle {
+ /* 인천대에서 피어나다 */
+ width: 184.2px;
+ height: 18.35px;
+ background: url('../../asset/sublogo.png');
+
+ background-size: contain;
+ margin-top: 10px;
+
+ align-self: flex-start;
+ margin-left: 110px;
+ }
+
+ .container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ font-family: 'Pretendard', sans-serif;
+ height: 100%;
+ }
+
+ .botton-container{
+ margin-top:auto;
+ }
+
+ .bottom-Button {
+ /* 하단 버튼 */
+ width: 300px;
+ height: 50px;
+
+ color: #F7F7F7;
+ background: #FF7898;
+ border-radius: 8px;
+ border-color: rgb(255, 255, 255);
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 700;
+ font-size: 18px;
+
+ margin-bottom: 40px;
+ margin-top: auto;
+
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
+}
\ No newline at end of file
diff --git a/src/page/Main/Main.jsx b/src/page/Main/Main.jsx
index c647dac..1a96bcb 100644
--- a/src/page/Main/Main.jsx
+++ b/src/page/Main/Main.jsx
@@ -1,11 +1,48 @@
import React from "react";
+import './Main.css'
+import { useNavigate } from 'react-router-dom';
+import mainImage from '../../asset/main.png';
+import mainLogo from '../../asset/logo.png';
+import subLogo from '../../asset/sublogo.png';
-function Main(){
- return(
-
- 메인
-
- )
-}
+// 시작화면
+function Main() {
+ const navigate = useNavigate(); // useNavigate 훅 사용
+
+ //로컬스토리지 확인후 로그인 페이지 혹은 회원가입 페이지로 이동
+ const handleButtonClick = () => {
+ if (localStorage.getItem('userEmail')) {
+ navigate('../Login'); // '/next' 경로로 이동
+ } else {
+ navigate('../Login1'); // '/next' 경로로 이동
+ //navigate('../SignUp'); // '/next' 경로로 이동
+ }
+ };
+
+
+ return (
+
+
+
+

+
-export default Main;
\ No newline at end of file
+
+

+
+
+
+

+
+
+
+
+
+
+
+ )
+}
+
+ export default Main;
\ No newline at end of file
diff --git a/src/page/Mbti/Mbti.css b/src/page/Mbti/Mbti.css
index a6c92e1..a11b70c 100644
--- a/src/page/Mbti/Mbti.css
+++ b/src/page/Mbti/Mbti.css
@@ -6,6 +6,7 @@
background-color: #FFFFFF ;
width: 375px;
height: 100vh;
+
header {
/* 상단 헤더 */
@@ -14,7 +15,7 @@
flex-direction: row;
align-items: center;
justify-content: flex-start;
- margin-top: 62px;
+ margin-top: 15%;
}
.back-button {
@@ -57,7 +58,7 @@
background: #FF7898;
border-radius: 5px;
position: absolute;
- bottom: 83px;
+ bottom: 10%;
font-family: 'Pretendard';
font-style: normal;
font-weight: 700;
@@ -70,8 +71,8 @@
margin: 16px;
display: flex;
position: absolute;
- bottom: 240px;
- margin-top: 140px;
+ bottom: 28%;
+
flex-direction: column;
align-items: center;
@@ -105,6 +106,33 @@
margin-bottom: 20px;
}
+
+ .answerselected{
+ box-sizing: border-box;
+
+
+ width: 343px;
+ height: 68px;
+
+ background: #FF7898;
+ border: 2px solid #FF7898;
+ border-radius: 49px;
+
+
+ white-space: pre-wrap;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 500;
+ font-size: 17px;
+ line-height: 20px;
+ /* identical to box height, or 88% */
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ text-align: center;
+ color: #FFFFFF;
+ margin-bottom: 20px;
+ }
#Q{
white-space: pre-wrap;
width: auto;
@@ -113,7 +141,7 @@
font-family: 'Pretendard';
font-style: normal;
font-weight: 600;
- font-size: 20px;
+ font-size: 19px;
line-height: 20px;
/* identical to box height, or 88% */
display: flex;
@@ -121,8 +149,94 @@
color: #3D3D3D;
- margin-bottom: 130px;
+ margin-bottom: 100px;
+
+
+ }
+ #mbti_main{
+ justify-content: center;
+ }
+ #mbti_title{
+
+ background-image: url('../../asset/횃불이\ 테스트.png');
+ background-repeat: no-repeat;
+ width: 280px;
+ height: 50px;
+ margin-bottom: 30px;
+ margin-top:100px ;
+ }
+ #subTitle{
+ /* 당신의 횃불이 유형은? */
+
+ width: 176px;
+ height: 14px;
+
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 20px;
+ line-height: 14px;
+ color: #777777;
+ margin-bottom: 45px;
+ }
+ #mbtiMain_img{
+
+ width: 80%;
+ height: 300px;
+ background: #D9D9D9;
+ place-self: center center;
+
}
-}
\ No newline at end of file
+
+
+
+}
+.modal {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ background: white;
+ padding: 20px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ outline: none;
+ max-width: 375px;
+ width: 300px;
+ z-index: 1000; /* 모달이 다른 요소들 위에 표시되도록 */
+ text-align: center; /* 텍스트 가운데 정렬 */
+ background: #FFFFFF;
+ border-radius: 10px;
+ font-family: 'Pretendard';
+ font-style: normal;
+ font-weight: 600;
+ font-size: 18px;
+ line-height: 28px;
+ letter-spacing: -1px;
+ color: #000000;
+}
+
+.overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: rgba(0, 0, 0, 0.75);
+ z-index: 999; /* 모달 오버레이가 다른 요소들 위에 표시되도록 */
+}
+
+#img {
+ background-image: url('../../asset/loading.gif');
+ background-size: contain;
+ background-repeat: no-repeat;
+ background-position: center; /* 이미지를 수평, 수직 중앙 정렬 */
+ max-width: 100%;
+ width: 30%;
+ height: 200px;
+ margin-bottom: 20px; /* 이미지 아래 여백 추가 */
+ display: block; /* img를 블록 요소로 변경 */
+ margin: 0 auto; /* 수평 가운데 정렬 */
+}
diff --git a/src/page/Mbti/Mbti.jsx b/src/page/Mbti/Mbti.jsx
index c46b47d..61820b6 100644
--- a/src/page/Mbti/Mbti.jsx
+++ b/src/page/Mbti/Mbti.jsx
@@ -1,11 +1,48 @@
import React from 'react';
+import { useNavigate } from "react-router-dom";
+import './Mbti.css';
function Mbti (){
+
+ const navigate = useNavigate();
+
+
+ const handleNavigation = (destination) => {
+ switch (destination) {
+ case 'play':
+ window.location.reload(); // 페이지 새로고침 (필요에 따라 이 부분을 변경)
+ break;
+ case 'talk':
+ navigate('/ChatStartPage');
+ break;
+ case 'my':
+ navigate('/myPage');
+ break;
+ default:
+ break;
+ }
+ };
+ const handleNext = () => {
+ navigate('/mbti1')
+ }
return (
-
-
+
+
+
당신의 횃불이 유형은?
+
+
+
+
+
handleNavigation('play')}>
+
handleNavigation('talk')}>
+
handleNavigation('my')}>
+
+
);
};
diff --git a/src/page/Mbti/Mbti1.jsx b/src/page/Mbti/Mbti1.jsx
index 2a5d7a2..6ab37c5 100644
--- a/src/page/Mbti/Mbti1.jsx
+++ b/src/page/Mbti/Mbti1.jsx
@@ -1,16 +1,53 @@
-import React from "react";
+import React, { useContext, useEffect, useState } from "react";
import { IoChevronBack } from "react-icons/io5"; // 아이콘 추가
import Question from "./Question";
import "./Mbti.css";
import { useNavigate } from "react-router-dom";
-
+import { MbtiContext } from "../../context/MbitContext";
function Mbti1(){
+ const { Mbti, updateMbti } = useContext(MbtiContext);
+ const [isa1Checked,setIsa1Checked]=useState(false);
+ const [isa2Checked,setIsa2Checked]=useState(false);
+ const [selectedAnswer, setSelectedAnswer] = useState(null); // 선택된 답변 상태
+ const selectedValue1 = Mbti.selectList["1"];
const navigate = useNavigate();
+ useEffect(() =>{
+ if(selectedValue1){
+ setIsa1Checked(true);
+ setIsa2Checked(false);
+ }
+ else{
+ setIsa1Checked(false);
+ setIsa2Checked(true);
+ }
+ },[selectedValue1])
+
+
+
+ // 사용자가 선택한 답변을 업데이트하는 함수
+ const handleAnswerSelected = (answer) => {
+ setSelectedAnswer(answer); // 선택된 답변을 상태로 저장
+ };
+
const handleBack = () => {
+ if (selectedAnswer === 1) { //1번선택하면 e+1
+ updateMbti({ selectList: { ...Mbti.selectList, "1": true } });
+ console.log("Context updated:");
+
+ } else if (selectedAnswer === 2) {
+ updateMbti({selectList: { ...Mbti.selectList, "1": false } });
+ }
navigate("/mbti"); // 이전 페이지로 이동
};
const handleNext = () => {
+ if (selectedAnswer === 1) {
+ updateMbti({ selectList: { ...Mbti.selectList, "1": true } });
+ console.log("Context updated:");
+
+ } else if (selectedAnswer === 2) {
+ updateMbti({ selectList: { ...Mbti.selectList, "1": false } });
+ }
navigate("/mbti2");
};
@@ -27,9 +64,12 @@ function Mbti1(){