From 6c31cc3160f1faf6d35f1644b934a622b5e661f4 Mon Sep 17 00:00:00 2001 From: KangYeonbae Date: Thu, 21 Nov 2024 15:51:28 +0900 Subject: [PATCH] =?UTF-8?q?user=EC=A0=95=EB=B3=B4=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/login.js | 4 +-- src/pages/owner-mypag.js | 55 ++++++++++++++++++++++++------------ src/pages/renter-mypage.js | 57 +++++++++++++++++++++++++------------- src/styles/spaceList.css | 23 +-------------- 4 files changed, 78 insertions(+), 61 deletions(-) diff --git a/src/pages/login.js b/src/pages/login.js index 99f2096..be334c0 100644 --- a/src/pages/login.js +++ b/src/pages/login.js @@ -1,7 +1,7 @@ import React, { useContext, useState } from 'react'; import '../styles/login.css'; -import authService from '../utils/AuthContext/authService'; -import { AuthContext } from '../utils/AuthContext/AuthContext'; +import authService from '../utils/authService'; +import { AuthContext } from '../utils/AuthContext'; const USER_TYPE_LABELS = { 'consumer': '일반', diff --git a/src/pages/owner-mypag.js b/src/pages/owner-mypag.js index 468a29a..56bace0 100644 --- a/src/pages/owner-mypag.js +++ b/src/pages/owner-mypag.js @@ -1,14 +1,46 @@ -import { useState } from "react"; +import { useState, useEffect, useContext } from "react"; import Calendar from 'react-calendar'; import 'react-calendar/dist/Calendar.css'; import '../styles/OwnerMypage.css'; import RegistrationModal from './registrationModal'; +import { AuthContext } from "../utils/AuthContext"; +import authService from '../utils/authService'; +import UserInfomation from "../components/UserInfo"; export default function OwnerMypage() { + const {user, isAuthenticated} = useContext(AuthContext); const [activeTab, setActiveTab] = useState('all'); const [date, setDate] = useState(new Date()); const [isModalOpen, setIsModalOpen] = useState(false); + const [userInfo, setUserInfo] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + + useEffect(() => { + const fetchUserInfo = async () => { + try { + setLoading(true); + console.log(user.userid); + const info = await authService.getUserInfo(user.userid); + setUserInfo(info); + setError(null); + console.log(info); + console.log(userInfo); + } catch (err) { + setError('사용자 정보를 불러오는데 실패했습니다.'); + console.error('Error fetching user info:', err); + } finally { + setLoading(false); + } + }; + + if (user?.userid) { + fetchUserInfo(); + } + }, [user?.userid]); + // 시설 데이터 예시 (스키마 기반) const facilityData = [ { @@ -157,22 +189,11 @@ export default function OwnerMypage() {

관리자 페이지

-
-
사업자번호
-
123-45-67890
-
-
-
상호명
-
행복한 캠핑
-
-
-
대표자명
-
김대표
-
-
-
연락처
-
02-123-4567
-
+
{/* 시설 관리 섹션 */} diff --git a/src/pages/renter-mypage.js b/src/pages/renter-mypage.js index fff3c29..f7b2b21 100644 --- a/src/pages/renter-mypage.js +++ b/src/pages/renter-mypage.js @@ -1,14 +1,45 @@ -import { useState } from "react"; +import { useContext, useEffect, useState } from "react"; import {useNavigate} from "react-router-dom"; import Calendar from 'react-calendar'; import 'react-calendar/dist/Calendar.css'; import '../styles/mypage.css'; +import { AuthContext } from "../utils/AuthContext"; +import authService from '../utils/authService'; +import UserInfomation from "../components/UserInfo"; export default function RenterMypage() { const navigate = useNavigate(); + const {user, isAuthenticated} = useContext(AuthContext); const [activeTab, setActiveTab] = useState('all'); const [date, setDate] = useState(new Date()); + const [userInfo, setUserInfo] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchUserInfo = async () => { + try { + setLoading(true); + console.log(user.userid); + const info = await authService.getUserInfo(user.userid); + setUserInfo(info); + setError(null); + console.log(info); + console.log(userInfo); + } catch (err) { + setError('사용자 정보를 불러오는데 실패했습니다.'); + console.error('Error fetching user info:', err); + } finally { + setLoading(false); + } + }; + + if (user?.userid) { + fetchUserInfo(); + } + }, [user?.userid]); + const bookingData = [ { id: 1, @@ -112,25 +143,11 @@ export default function RenterMypage() {
-
-

마이페이지

-
-
ID
-
dusqo
-
-
-
이름
-
새싹
-
-
-
이메일
-
dusqo@dusqo.com
-
-
-
연락처
-
000-000-0000
-
-
+

내 예약 목록

diff --git a/src/styles/spaceList.css b/src/styles/spaceList.css index 6f4b308..e73d73c 100644 --- a/src/styles/spaceList.css +++ b/src/styles/spaceList.css @@ -39,34 +39,13 @@ box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1); } -/* 캠핑 타입 스타일 */ -.space-box.camping-box { +.space-box { background: linear-gradient(135deg, #ffd6e7, #c8e7ff); -} - -.space-box.camping-box .list-with-box { border: 1px solid rgba(255, 255, 255, 0.2); -} - -.space-box.camping-box .list-space-name { color: #4a6baf; font-weight: 600; } -/* 합주실 타입 스타일 */ -.space-box { - background: linear-gradient(135deg, #ffe6d5, #d4f0ff); -} - -.space-box.rehearsal-box .list-with-box { - border: 1px solid rgba(255, 255, 255, 0.2); -} - -.space-box.rehearsal-box .list-space-name { - color: #e85a5a; - font-weight: 600; -} - /* 카드 내부 콘텐츠 스타일 */ .list-with-box { width: 92%;