Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/UMC-FITple/Frontend into fea…
Browse files Browse the repository at this point in the history
…ture/#46
  • Loading branch information
junhxxk committed Aug 21, 2024
2 parents b4368b4 + a244386 commit c4f70bc
Show file tree
Hide file tree
Showing 14 changed files with 371 additions and 141 deletions.
29 changes: 29 additions & 0 deletions FITple-Frontend/data/SearchMainApi.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const localhost = "http://localhost:3000";

export const searchMain = async (category, clothId, size) => {
try {
const url = new URL(`${localhost}/FITple/search/main`);

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

console.log("url", url);
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});

if (!response.ok) {
throw new Error(`서버 오류: ${response.status}`);
}

return await response.json();
} catch (error) {
console.error("검색 요청 중 오류가 발생했습니다.", error);
throw new Error("네트워크 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
}
};
256 changes: 190 additions & 66 deletions FITple-Frontend/src/components/CompareInputPopUp/CompareInputPopUp.jsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,193 @@
import { AddInputCardBtn, BackArrowBtn, BackgroundContainer, CloseBtn, CompareInput, CompareInputAndText, CompareInputAndTextContainer, CompareInputCard, CompareInputCardConfirmBtn, CompareInputCardDelBtn, CompareInputContainer, CompareInputText, ComparePopUpBackground, ComparePopUpContainer, ComparePopUpInnerContainer, ComparePopUpInnerMainContainer, ComparePopUpMainText, CompareSubText } from "./CompareInputPopUp.style"
import { useState } from "react";
import {
AddInputCardBtn,
BackArrowBtn,
BackgroundContainer,
CloseBtn,
CompareInput,
CompareInputAndText,
CompareInputAndTextContainer,
CompareInputCard,
CompareInputCardConfirmBtn,
CompareInputCardDelBtn,
CompareInputContainer,
CompareInputText,
ComparePopUpBackground,
ComparePopUpContainer,
ComparePopUpInnerContainer,
ComparePopUpInnerMainContainer,
ComparePopUpMainText,
CompareSubText,
} from "./CompareInputPopUp.style";

function CompareInputPopUp({ popupClose, comparePopUpOpen, onSave, compareSearchPopUpOpen,}) {
const [inputValues, setInputValues] = useState([
{
size: "",
totalLength: "",
shoulderWidth: "",
chestWidth: "",
armholeWidth: "",
sleeveWidth: "",
sleeveLength: "",
hemWidth: "",
},
]);

function CompareInputPopUp() {
const handleInputChange = (index, field, value) => {
const updatedInputValues = [...inputValues];
updatedInputValues[index][field] = value;
setInputValues(updatedInputValues);
};

return (
<>
<BackgroundContainer>
<ComparePopUpContainer>
<ComparePopUpBackground>
<ComparePopUpInnerContainer>
<ComparePopUpInnerMainContainer>
<BackArrowBtn src="../assets/_.svg" />
<ComparePopUpMainText>사이즈 비교</ComparePopUpMainText>
<CloseBtn src="../assets/X(Compare).svg" />
</ComparePopUpInnerMainContainer>
<CompareSubText>비교할 옷의 사이즈를 입력해주세요.</CompareSubText>
<CompareInputContainer>
<CompareInputCard>
<CompareInputAndTextContainer>
<CompareInputAndText>
<CompareInputText>사이즈</CompareInputText>
<CompareInput/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>총장</CompareInputText>
<CompareInput/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>어깨단면</CompareInputText>
<CompareInput/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>가슴단면</CompareInputText>
<CompareInput/>
</CompareInputAndText>
</CompareInputAndTextContainer>
<CompareInputAndTextContainer>
<CompareInputAndText>
<CompareInputText>암홀단면</CompareInputText>
<CompareInput/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>소매단면</CompareInputText>
<CompareInput/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>소매길이</CompareInputText>
<CompareInput/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>밑단단면</CompareInputText>
<CompareInput/>
</CompareInputAndText>
</CompareInputAndTextContainer>
<CompareInputCardDelBtn>삭제하기</CompareInputCardDelBtn>
</CompareInputCard>
<AddInputCardBtn src="../assets/Group 330.svg" />
</CompareInputContainer>
<CompareInputCardConfirmBtn>저장하기</CompareInputCardConfirmBtn>
</ComparePopUpInnerContainer>
</ComparePopUpBackground>
</ComparePopUpContainer>
</BackgroundContainer>
</>
)
}

export default CompareInputPopUp
const handleSaveClick = () => {
onSave([...inputValues]);
};

// 새로운 Input 카드를 추가하는 함수
const addInputCard = () => {
setInputValues([
...inputValues,
{
size: "",
totalLength: "",
shoulderWidth: "",
chestWidth: "",
armholeWidth: "",
sleeveWidth: "",
sleeveLength: "",
hemWidth: "",
},
]);
};

// 특정 Input 카드를 삭제하는 함수
const removeInputCard = (index) => {
const updatedCards = inputValues.filter((_, i) => i !== index);
setInputValues(updatedCards);
};

return (
<>
<BackgroundContainer>
<ComparePopUpContainer>
<ComparePopUpBackground>
<ComparePopUpInnerContainer>
<ComparePopUpInnerMainContainer>
<BackArrowBtn src="../assets/_.svg" onClick={comparePopUpOpen} />
<ComparePopUpMainText>사이즈 비교</ComparePopUpMainText>
<CloseBtn src="../assets/X(Compare).svg" onClick={popupClose} />
</ComparePopUpInnerMainContainer>
<CompareSubText>비교할 옷의 사이즈를 입력해주세요.</CompareSubText>
<CompareInputContainer>
{/* 상태에 따라 각 CompareInputCard 렌더링 */}
{inputValues.map((card, index) => (
<CompareInputCard key={index}>
<CompareInputAndTextContainer>
<CompareInputAndText>
<CompareInputText>사이즈</CompareInputText>
<CompareInput
value={card.size}
onChange={(e) =>
handleInputChange(index, "size", e.target.value)
}
/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>총장</CompareInputText>
<CompareInput
value={card.totalLength}
onChange={(e) =>
handleInputChange(index, "totalLength", e.target.value)
}
/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>어깨단면</CompareInputText>
<CompareInput
value={card.shoulderWidth}
onChange={(e) =>
handleInputChange(index, "shoulderWidth", e.target.value)
}
/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>가슴단면</CompareInputText>
<CompareInput
value={card.chestWidth}
onChange={(e) =>
handleInputChange(index, "chestWidth", e.target.value)
}
/>
</CompareInputAndText>
</CompareInputAndTextContainer>
<CompareInputAndTextContainer>
<CompareInputAndText>
<CompareInputText>암홀단면</CompareInputText>
<CompareInput
value={card.armholeWidth}
onChange={(e) =>
handleInputChange(index, "armholeWidth", e.target.value)
}
/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>소매단면</CompareInputText>
<CompareInput
value={card.sleeveWidth}
onChange={(e) =>
handleInputChange(index, "sleeveWidth", e.target.value)
}
/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>소매길이</CompareInputText>
<CompareInput
value={card.sleeveLength}
onChange={(e) =>
handleInputChange(index, "sleeveLength", e.target.value)
}
/>
</CompareInputAndText>
<CompareInputAndText>
<CompareInputText>밑단단면</CompareInputText>
<CompareInput
value={card.hemWidth}
onChange={(e) =>
handleInputChange(index, "hemWidth", e.target.value)
}
/>
</CompareInputAndText>
</CompareInputAndTextContainer>
{index !== 0 && (
<CompareInputCardDelBtn
onClick={() => removeInputCard(index)}
>
삭제하기
</CompareInputCardDelBtn>
)}
</CompareInputCard>
))}
{/* 새로운 CompareInputCard를 추가하는 버튼 */}
<AddInputCardBtn
src="../assets/Group 330.svg"
onClick={addInputCard}
/>
</CompareInputContainer>
<CompareInputCardConfirmBtn
onClick={() => {
handleSaveClick();
compareSearchPopUpOpen();
}}
>
저장하기
</CompareInputCardConfirmBtn>
</ComparePopUpInnerContainer>
</ComparePopUpBackground>
</ComparePopUpContainer>
</BackgroundContainer>
</>
);
}

export default CompareInputPopUp;
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@ export const CompareSubText = styled.div`

export const CompareInputContainer = styled.div`
margin-top: 19px;
width: 338px;
width: 358px;
height: 334px;
display: flex;
flex-direction: column;
align-items: center;
overflow-y: auto;
`;

export const CompareInputCard = styled.div`
margin-bottom: 12px;
border-radius: 15px;
border: 1px solid #838383;
width: 338px;
height: 200px;
min-height: 200px;
position: relative;
`;

Expand Down
14 changes: 11 additions & 3 deletions FITple-Frontend/src/components/CompareLoading/CompareLoading.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { BackgroundContainer, ComparePopUpContainer, ComparePopUpBackground, ComparePopUpInnerContainer, ComparePopUpInnerMainContainer, BackArrowBtn, ComparePopUpMainText, CloseBtn, FITpleLogo, CompareLoadingText, CompareLoadingSubText, CompareLoadingBar, CompareLoadingInnerBar, } from "./CompareLoading.style"
import { useEffect } from "react";

function CompareLoading({ popupClose, compareSearchPopUpOpen, cleanCompareData, compareResultOpen }) {
useEffect(() => {
// 1초 후에 cleanCompareData 함수 호출
const timer = setTimeout(() => {
compareResultOpen();
}, 1200);

function CompareLoading() {
return () => clearTimeout(timer); // 컴포넌트 언마운트 시 타이머 클리어
}, [cleanCompareData]);

return (
<>
Expand All @@ -10,9 +18,9 @@ function CompareLoading() {
<ComparePopUpBackground>
<ComparePopUpInnerContainer>
<ComparePopUpInnerMainContainer>
<BackArrowBtn src="../assets/_.svg" />
<BackArrowBtn src="../assets/_.svg" onClick={compareSearchPopUpOpen} />
<ComparePopUpMainText>사이즈 비교</ComparePopUpMainText>
<CloseBtn src="../assets/X(Compare).svg" />
<CloseBtn src="../assets/X(Compare).svg" onClick={()=>{popupClose(); cleanCompareData();}} />
</ComparePopUpInnerMainContainer>
<FITpleLogo src="../assets/핏플 로고.svg" />
<CompareLoadingText>내 옷과 사이즈 비교 중이에요!</CompareLoadingText>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from "styled-components";
import styled, { keyframes } from "styled-components";

export const BackgroundContainer = styled.div`
position: fixed;
Expand Down Expand Up @@ -87,9 +87,19 @@ export const CompareLoadingBar = styled.div`
background-color: #EFEFEF;
`;

const fillBar = keyframes`
0% {
width: 0;
}
100% {
width: 100%;
}
`;

export const CompareLoadingInnerBar = styled.div`
height: 15px;
width: 170px;
width: 0; /* 애니메이션 시작 시 폭 0 */
border-radius: 50px;
background-color: #0276FE;
animation: ${fillBar} 1s forwards; /* 애니메이션 적용 */
`;
7 changes: 3 additions & 4 deletions FITple-Frontend/src/components/ComparePopUp/ComparePopUp.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BackgroundContainer, CloseBtn, CompareIMGOrText, CompareIMGUploadCameraLogo, CompareIMGUploadContainer, CompareIMGUploadText, CompareInputUploadText, ComparePopUpBackground, ComparePopUpContainer, ComparePopUpInnerContainer, ComparePopUpMainText } from "./ComparePopUp.style"
import { BackgroundContainer, CloseBtn, CompareIMGOrText, CompareIMGUploadCameraLogo, CompareIMGUploadContainer, CompareIMGUploadText, CompareInputUploadText, ComparePopUpBackground, ComparePopUpContainer, ComparePopUpInnerContainer, ComparePopUpMainText } from "./ComparePopUp.style";


function ComparePopUp({popupClose}) {
function ComparePopUp({popupClose, compareInputPopUpOpen}) {

return (
<>
Expand All @@ -18,7 +17,7 @@ function ComparePopUp({popupClose}) {
<CompareIMGUploadText>사이즈 정보<br/>이미지 업로드하기</CompareIMGUploadText>
</CompareIMGUploadContainer>
<CompareIMGOrText>혹은</CompareIMGOrText>
<CompareInputUploadText>수기로 사이즈 등록하기</CompareInputUploadText>
<CompareInputUploadText onClick={compareInputPopUpOpen}>수기로 사이즈 등록하기</CompareInputUploadText>
</ComparePopUpInnerContainer>
</ComparePopUpBackground>
</ComparePopUpContainer>
Expand Down
Loading

0 comments on commit c4f70bc

Please sign in to comment.