Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Routes, Route, useLocation } from "react-router-dom";
import Splash from "./pages/Splash";
import OnBoarding from "./pages/OnBoarding";
import Home from "./pages/Home";
import Signup from "./pages/SignUp";
import Signup from "./pages/Signup";
import Map from "./pages/Map";
import BottomNav from "./components/BottomNav";
import TopNav from "./components/TopNav";
Expand All @@ -22,7 +22,6 @@ function App() {
// 바텀nav바를 숨길 경로들
const hideBottomNavPaths = [
"/splash",
"/",
"/signup",
"/login",
"/chat/room/buy",
Expand All @@ -35,7 +34,6 @@ function App() {
// 탑nav바를 숨길 경로들
const hideTopNavPaths = [
"/splash",
"/",
"/login",
"/signup",
"/chat/room/final",
Expand Down
67 changes: 33 additions & 34 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,25 @@ const api = axios.create({
withCredentials: true,
});

// GET 요청
export const get = (url, data) => api.get(url, data);

// POST 요청
export const post = (url, data) => api.post(url, data);

// PUT 요청
export const put = (url, data) => api.put(url, data);

// DELETE 요청
export const del = (url) => api.delete(url);

// PATCH 요청
export const patch = (url, data) => api.patch(url, data);

export default api;

// // ✅ 모든 요청에 자동으로 accessTok en 추가
// api.interceptors.request.use(
// async (config) => {
// try {
// const tokenData = localStorage.getItem("userTokens");
// if (tokenData) {
// const { accessToken } = JSON.parse(tokenData);
// if (accessToken) {
// config.headers["Authorization"] = `Bearer ${accessToken}`;
// }
// }
// } catch (error) {
// console.error("토큰 불러오기 실패:", error);
// }
// return config;
// },
// (error) => Promise.reject(error)
// );
// ✅ 모든 요청에 자동으로 accessTok en 추가
api.interceptors.request.use(
async (config) => {
try {
const tokenData = localStorage.getItem("access_token");
console.log(tokenData);
if (tokenData) {
config.headers["Authorization"] = `Bearer ${tokenData}`;
}
console.log(config);
} catch (error) {
console.error("토큰 불러오기 실패:", error);
}
return config;
},
(error) => Promise.reject(error)
);

// // 🔥 응답 인터셉터: 리프레시 토큰으로 재발급 처리
// api.interceptors.response.use(
Expand All @@ -57,7 +41,7 @@ export default api;
// if (error.response?.status === 401) {
// console.log("토큰 만료됨, 리프레시 토큰 사용!");

// const tokenData = localStorage.getItem("userTokens");
// const tokenData = localStorage.getItem("refresh_token");
// if (tokenData) {
// const { refreshToken } = JSON.parse(tokenData);
// try {
Expand Down Expand Up @@ -85,3 +69,18 @@ export default api;
// return Promise.reject(error);
// }
// );

// GET 요청
export const get = (url, data) => api.get(url, data);

// POST 요청
export const post = (url, data) => api.post(url, data);

// PUT 요청
export const put = (url, data) => api.put(url, data);

// DELETE 요청
export const del = (url, data) => api.delete(url, data);

// PATCH 요청
export const patch = (url, data) => api.patch(url, data);
1 change: 1 addition & 0 deletions src/api/wish-controller/wishPost.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { post } from "./../index";
// 좋아요 API 호출
export const likeSpace = async (spaceId) => {
console.log(spaceId);
try {
const res = await post(`/api/v1/user/spaces/${spaceId}/like`);
return res.data;
Expand Down
11 changes: 7 additions & 4 deletions src/components/ItemModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ const ItemModal = ({ isOpen, onClose, item }) => {
const [liked, setLiked] = useState(false); // 상태값 저장
if (!isOpen || !item) return null;

const images = item.images && item.images.length > 0 ? item.images : [null]; // 기본 이미지 처리
const total = 5;

const images =
item.coverImageUrl && item.coverImageUrl.length > 0
? item.coverImageUrl
: [null]; // 기본 이미지 처리
const total = 1;
console.log(item);
const handlePrev = () => {
setCurrentIndex((prev) => (prev === 0 ? total - 1 : prev - 1));
};
Expand All @@ -30,7 +33,7 @@ const ItemModal = ({ isOpen, onClose, item }) => {

const handleLikeToggle = async () => {
try {
const spaceId = 123; // 임의 ID
const spaceId = item.spaceId; // 임의 ID

if (liked) {
// 이미 좋아요 상태라면 → 취소 요청
Expand Down
13 changes: 12 additions & 1 deletion src/pages/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
const [selectedFloor, setSelectedFloor] = useState(null);
const [selectedRating, setSelectedRating] = useState(null);
const [initialHeight, setInitialHeight] = useState(140);
const [loading, setLoading] = useState(true);

Check failure on line 30 in src/pages/Map.jsx

View workflow job for this annotation

GitHub Actions / build-and-lint

'loading' is assigned a value but never used. Allowed unused vars must match /^[A-Z_]/u

const [originMarkers, setOriginMarkers] = useState([]);
const [markers, setMarkers] = useState([]);
Expand All @@ -36,7 +36,7 @@
if (!location) return;
setCurrentLocation(location);
fetchPlaces();
}, [location]);

Check warning on line 39 in src/pages/Map.jsx

View workflow job for this annotation

GitHub Actions / build-and-lint

React Hook useEffect has a missing dependency: 'fetchPlaces'. Either include it or remove the dependency array

const fetchPlaces = async () => {
try {
Expand Down Expand Up @@ -276,7 +276,17 @@
setInitialHeight(140);
}}
>
<Thumbnail />
<Thumbnail>
<img
src={item.coverImageUrl || "/default-image.png"}
alt={item.spaceName || "공간 이미지"}
style={{
width: "100%",
height: "100%",
objectFit: "cover",
}}
/>
</Thumbnail>
<Info>
<Price>{item.price.toLocaleString()}원</Price>
<div
Expand Down Expand Up @@ -309,6 +319,7 @@
</ListItem>
))}
</ListContainer>
<div style={{ height: 80 }} />
</DragModal>
</DragModalContainer>

Expand Down
80 changes: 0 additions & 80 deletions src/pages/chatPage/ChatPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,86 +25,6 @@ const dummyData = [
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 7, 15, 9, 10),
},
{
id: 3,
name: "이영희",
lastMessage: "계약 관련 문의드립니다.",
time: "어제",
unreadCount: 1,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 7, 14, 20, 30),
},
{
id: 4,
name: "박민수",
lastMessage: "내일 뵙겠습니다.",
time: "8월 10일",
unreadCount: 0,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 7, 10, 12, 0),
},
{
id: 5,
name: "최지우",
lastMessage: "네 알겠습니다~",
time: "8월 5일",
unreadCount: 5,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 7, 5, 18, 45),
},
{
id: 6,
name: "윤하늘",
lastMessage: "사진 보내드릴게요.",
time: "8월 1일",
unreadCount: 0,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 7, 1, 14, 15),
},
{
id: 7,
name: "장보고",
lastMessage: "감사합니다!",
time: "7월 28일",
unreadCount: 0,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 6, 28, 11, 0),
},
{
id: 8,
name: "오세훈",
lastMessage: "혹시 내일 시간 괜찮으세요?",
time: "7월 25일",
unreadCount: 2,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 6, 25, 17, 50),
},
{
id: 9,
name: "서지수",
lastMessage: "서류 전달했습니다.",
time: "7월 21일",
unreadCount: 0,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 6, 21, 13, 30),
},
{
id: 10,
name: "정우성",
lastMessage: "네 확인했습니다.",
time: "7월 18일",
unreadCount: 0,
profile: "https://via.placeholder.com/40",
buildingImage: "https://via.placeholder.com/50",
timestamp: new Date(2024, 6, 18, 9, 20),
},
];

const ChatPage = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/chatPage/ChatRoomFinalPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ChatRoomFinalPage = () => {
<HomeBox>
<HomeButton
onClick={() => {
navigate("/main");
navigate("/home");
}}
>
홈으로 가기
Expand Down
36 changes: 30 additions & 6 deletions src/pages/chatPage/ChatRoomPage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useParams, useNavigate } from "react-router-dom";
import { useParams, useNavigate, useLocation } from "react-router-dom";
import styled from "styled-components";
import { useState } from "react";
import { useState, useEffect, useRef } from "react";
import LeftArrowIcon from "../../assets/icons/leftArrowIconBlack.svg";
import GrayIcon from "../../assets/icons/grayMarker.svg";
import SendIcon from "../../assets/icons/sendIcon.svg";
Expand All @@ -18,6 +18,9 @@ const dummyPlace = {
const ChatRoomPage = () => {
const { id } = useParams();
const navigate = useNavigate();
const location = useLocation();
const { item } = location.state || {}; // state 없으면 {} 처리
const chatEndRef = useRef(null);
const [messages, setMessages] = useState([
{
id: 1,
Expand Down Expand Up @@ -113,11 +116,28 @@ const ChatRoomPage = () => {
]);
const [input, setInput] = useState("");

useEffect(() => {
scrollToBottom();
}, [messages]);

const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes().toString().padStart(2, "0");

const ampm = hours >= 12 ? "오후" : "오전";
const displayHour = hours % 12 || 12;
const time = `${ampm} ${displayHour}:${minutes}`;

// 스크롤을 맨 아래로 이동시키는 함수
const scrollToBottom = () => {
chatEndRef.current?.scrollIntoView({ behavior: "smooth" });
};

const sendMessage = () => {
if (!input.trim()) return;
setMessages([
...messages,
{ id: Date.now(), text: input, sender: "me", time: "오후 5:40" },
{ id: Date.now(), text: input, sender: "me", time },
]);
setInput("");
};
Expand Down Expand Up @@ -145,7 +165,7 @@ const ChatRoomPage = () => {
<Info>
<Top>
<img
src={dummyPlace.image}
src={item ? item.coverImageUrl : null}
alt="item"
style={{ width: 45, height: 45, backgroundColor: "#CCC" }}
/>
Expand All @@ -165,9 +185,11 @@ const ChatRoomPage = () => {
alt="marker"
style={{ width: "auto", height: "auto" }}
/>
{dummyPlace.location}
{item ? item.location : "서울 특별시 종로 1가"}
</SubText>
<Price>{dummyPlace.price.toLocaleString()}원</Price>
<Price>
{item ? item.price.toLocaleString() : "500,000"}원
</Price>
</div>
</Top>
</Info>
Expand Down Expand Up @@ -201,6 +223,8 @@ const ChatRoomPage = () => {
)}
</MessageBubble>
))}
{/* 스크롤 끝 ref */}
<div ref={chatEndRef} />
</MessageList>

{/* 입력창 */}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/myPage/MyPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@
const navigate = useNavigate();
const [likeOpen, setLikeOpen] = useState(false);
const [hostOpen, setHostOpen] = useState(false);
const [selectedItem, setSelectedItem] = useState(null);

Check failure on line 103 in src/pages/myPage/MyPage.jsx

View workflow job for this annotation

GitHub Actions / build-and-lint

'selectedItem' is assigned a value but never used. Allowed unused vars must match /^[A-Z_]/u
const [reserveCount, setReserveCount] = useState(1);
const [progressCount, setProgressCount] = useState(1);
const [doneCount, setDoneCount] = useState(1);
const [reserveCount, setReserveCount] = useState(2);
const [progressCount, setProgressCount] = useState(0);
const [doneCount, setDoneCount] = useState(0);
return (
<MainContainer>
<Content>
Expand Down
19 changes: 16 additions & 3 deletions src/pages/post/PostingCreatePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,23 @@ const PostingCreatePage = () => {
area: "", // 전용면적 (㎡)
});

// editingData → form 형태로 변환
const mapEditingDataToForm = (data) => ({
price: data.price || data.rentalFee || "",
subText: data.subText || "", // editingData에 없으니 빈값
location: data.location || data.address || "",
subLocation: data.subLocation || "", // editingData에 없음
maxDays: data.maxDays || "", // editingData에 없음
images: data.coverImageUrl ? [data.coverImageUrl] : [], // 배열로 통일
buildingUsage: data.buildingUsage || "", // editingData에 없음
floor: data.floor?.toString() || "", // 숫자 → 문자열 변환
area: data.area || "", // editingData에 없음
});

// 수정 모드일 때 초기화
useEffect(() => {
if (editingData) {
setForm(editingData);
setForm(mapEditingDataToForm(editingData));
}
}, [editingData]);

Expand Down Expand Up @@ -70,10 +83,10 @@ const PostingCreatePage = () => {

const handleSubmit = () => {
if (isEdit) {
navigate("/main");
navigate("/home");
} else {
console.log("새 매물 등록:", form);
navigate("/main");
navigate("/home");
}
};

Expand Down
Loading
Loading