Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[FE]Feat/#97 옷장 등록 수정 삭제" #101

Merged
merged 1 commit into from
Aug 22, 2024
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
7 changes: 6 additions & 1 deletion FITple-Frontend/data/ClothApi.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const localhost = "http://localhost:3000";

export const ClothApi = async () => {
export const ClothApi = async (category, cursorId, size) => {
try {
const url = new URL(`${localhost}/FITple/my/closet/main`);

// 쿼리 파라미터 추가
if (category !== undefined) url.searchParams.append("category", category);
if (cursorId !== undefined) url.searchParams.append("cursorId", cursorId);
if (size !== undefined) url.searchParams.append("size", size);

const response = await fetch(url, {
method: "GET",
credentials: "include",
Expand Down
22 changes: 0 additions & 22 deletions FITple-Frontend/data/DeleteApi.jsx

This file was deleted.

26 changes: 0 additions & 26 deletions FITple-Frontend/data/UpdateApi.jsx

This file was deleted.

5 changes: 2 additions & 3 deletions FITple-Frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import LayoutMain from "./layout/LayoutMain";
import ProfileEditPage from "./pages/ProfileEditPage/ProfileEditPage";
import ChangepwdPage from "./pages/ChangepwdPage/ChangepwdPage";
import NotFoundPage from "./pages/NotFoundPage/NotFoundPage";
import Modal from "react-modal";
Modal.setAppElement("#root"); // 모달이 root에 렌더링 되도록 설정
import SearchTotalPage from "./pages/SearchTotalPage/SearchTotalPage";
function App() {
return (
<>
Expand All @@ -60,7 +59,7 @@ function App() {
<Route path="/cloth" element={<ClothmainPage />} />
<Route path="/clothdetail/:clothId" element={<ClothdetailPage />} />
<Route path="/clothregister" element={<ClothregisterPage />} />
<Route path="/clothupdate/:clothId" element={<ClothupdatePage />} />
<Route path="/clothupdate" element={<ClothupdatePage />} />
{/* 프로필페이지 */}
<Route path="/profile" element={<ProfilePage />} />
<Route path="/profile/edit" element={<ProfileEditPage />} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Link } from "react-router-dom";
import {
Container,
Text1,
Expand All @@ -24,9 +23,7 @@ const RegisterPopUp = ({ onClose }) => {
<Text2>개인정보 등 민감한 정보는 수정해주세요!</Text2>
<ButtonContainer>
<Button onClick={handleClose}>뒤로가기</Button>
<Link to="/cloth">
<Button2 onClick={handleRegister}>등록하기</Button2>
</Link>
<Button2 onClick={handleRegister}>등록하기</Button2>
</ButtonContainer>
</Container>
);
Expand Down
4 changes: 2 additions & 2 deletions FITple-Frontend/src/components/SideBar/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const SideBar = ({ setCategory }) => {
const [selectedCategory, setSelectedCategory] = useState("전체");

const handleCategoryClick = (category) => {
setSelectedCategory(category.name); // 클릭된 카테고리 이름 업데이트
setCategory(category.id); // 클릭된 카테고리 ID 업데이트
setSelectedCategory(category.name);
setCategory(category.id);
};

return (
Expand Down
27 changes: 5 additions & 22 deletions FITple-Frontend/src/pages/ClothdetailPage/ClothdetailPage.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useParams, Link } from "react-router-dom";
import Modal from "react-modal";
import { deleteCloth } from "../../../data/DeleteApi";
import {
BackIcon,
CurrentCloth,
Expand Down Expand Up @@ -45,7 +43,6 @@ import CompareResult from "../../components/CompareResult/CompareResult";
import useAuthStore from "../../../data/store/userAuthStore"; // 토큰을 가져오기 위해 zustand의 store import

function ClothdetailPage() {
const navigate = useNavigate();
const { clothId } = useParams(); // URL에서 clothId 가져오기
const [clothData, setClothData] = useState(null); // 가져온 데이터를 저장할 상태
const [note, setNote] = useState("");
Expand Down Expand Up @@ -91,21 +88,7 @@ function ClothdetailPage() {

fetchClothDetail();
}, [clothId, token]); // clothId 또는 token이 변경될 때마다 데이터를 다시 가져옴
const handleDeleteCloth = async () => {
try {
// 옷 정보 삭제 API 호출
await deleteCloth(clothId);

// 삭제 성공 시 알림 표시 및 메인 페이지로 이동
alert("옷 정보가 삭제되었습니다.");
navigate("/cloth"); // 삭제 후 메인 페이지로 이동
} catch (error) {
// 에러 처리
alert("옷 정보 삭제에 실패했습니다. 다시 시도해주세요.");
} finally {
setisDeletePopupOpen(false); // 팝업 닫기
}
};
useEffect(() => {
// 팝업이 열릴 때에도 기본 UI 요소가 사라지지 않도록 관리
if (popupOpen) {
Expand All @@ -119,6 +102,10 @@ function ClothdetailPage() {
setIsEdit(!isEdit);
};

const handleDeleteCloth = () => {
setisDeletePopupOpen(!isDeletePopupOpen);
};

const handleInputchange = (e) => {
setNote(e.target.value);
};
Expand Down Expand Up @@ -277,13 +264,9 @@ function ClothdetailPage() {
<Clothdebar />
{isEdit && (
<EditButtons isEdit={isEdit}>
<Link
to={`/clothupdate/${clothData.cloth_id}`}
state={{ clothData }} // state는 이렇게 전달합니다.
>
<Link to="/clothupdate">
<EditButton>옷 정보 수정하기</EditButton>
</Link>

<EditButton onClick={handleDeleteCloth}>
옷 정보 삭제하기
</EditButton>
Expand Down
Loading