Skip to content

Commit

Permalink
Custom Input 작업중:
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyong8175 committed Feb 4, 2024
1 parent 0f8c6d4 commit 31f463d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 31 deletions.
5 changes: 3 additions & 2 deletions src/component/ManageOwnDogs/ContentBox/ContentBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const ContentBox = () => {

useEffect(() => {
const fetchData = async () => {
const url = `${process.env.REACT_APP_API_URL}breeder/dogs?page=${page - 1}`;
const res = await get<IData>(
`${process.env.REACT_APP_API_URL}breeder/dogs`,
url
);

return res.data.data;
Expand All @@ -54,7 +55,7 @@ const ContentBox = () => {
setDogs(res.content);
})
.catch(err => console.log(err));
}, []);
}, [page]);

const searchItems = (searchValue: string) => {
setInputText(searchValue);
Expand Down
23 changes: 18 additions & 5 deletions src/component/ManageOwnDogs/CustomInput/CustomInput.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { BiSolidDownArrow } from "react-icons/bi";

import * as S from "./styles";

interface IProps {
value?: string;
genderValue?: string;
statusValue?: string;
genderArr?: string[];
statusArr?: string[];
width: string;
Expand All @@ -14,7 +15,8 @@ interface IProps {
}

const CustomInput = ({
value,
genderValue,
statusValue,
genderArr,
statusArr,
width,
Expand All @@ -23,10 +25,15 @@ const CustomInput = ({
updateStatusState
}: IProps) => {
const [isArrowClicked, setIsArrowClicked] = useState(false);
const [gender, setGender] = useState<string | undefined>(value);
const [status, setStatus] = useState<string | undefined>(value);
const [gender, setGender] = useState<string | undefined>();
const [status, setStatus] = useState<string | undefined>();

if (genderArr) {
useEffect(() => {
setGender(genderValue);
console.log("g");

}, [genderValue])
return (
<S.Wrapper width={width} height={height}>
<S.Input value={gender} disabled />
Expand Down Expand Up @@ -55,6 +62,12 @@ const CustomInput = ({
);
}

useEffect(() => {
setStatus(statusValue);
console.log('s');

}, [statusValue])

return (
<S.Wrapper width={width} height={height}>
<S.Input value={status} disabled />
Expand Down
2 changes: 1 addition & 1 deletion src/component/ManageOwnDogs/Form/OwnDogsCreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const OwnDogsCreateForm = () => {
<CustomInput
width={"84%"}
height="48px"
value={
genderValue={
dog?.gender?.gender ? dog?.gender?.gender : "MALE"
}
genderArr={["FEMAIL", "MALE"]}
Expand Down
37 changes: 22 additions & 15 deletions src/component/ManageOwnDogs/Form/OwnDogsEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ interface IProps {
// status: IStatus;
// }

export type IStatus = 'AVAILABLE' | 'DONE';
export interface IStatus {
status: 'AVAILABLE' | 'DONE';
};

export interface IGender {
gender: 'FEMALE' | 'MALE';
Expand All @@ -36,11 +38,11 @@ const initialState:IDogEditInfo = {
birthDate: "",
dogImgUrl: [],
dogType: "",
gender: "FEMALE",
gender: "",
id: -1,
management: "",
name: "",
status: 'AVAILABLE'
status: ""
}

interface IDate {
Expand Down Expand Up @@ -83,11 +85,10 @@ const OwnDogsEditForm = ({dog}: IProps) => {
*/
useEffect(() => {
setDog1(dog!);
// setDog1({...dog1, status: {status: dog1.status.status}})
handleDate(dog?.birthDate!);
setPrevImages(dog?.dogImgUrl!);
}, [dog])

}, [dog]);
/*
Handle Date
*/
Expand Down Expand Up @@ -161,10 +162,7 @@ const OwnDogsEditForm = ({dog}: IProps) => {
const updateStatusState = (value: string) => {
if (value === 'AVAILABLE') setDog1({...dog1, status: 'AVAILABLE'});
else setDog1({...dog1, status: 'DONE'});
}

console.log(dog1);

}

/*
Submit 할 때 create | edit 인지 확인 (dog1.id)
Expand Down Expand Up @@ -204,6 +202,15 @@ const OwnDogsEditForm = ({dog}: IProps) => {
} else {
formDataToSend.append('dogImgFiles', formDataFile[0]);
}
} else {
if (dog1.dogImgUrl.length > 0) {
dog1.dogImgUrl.forEach((d) => {
formDataToSend.append('dogImgFiles', d);
});
} else {
formDataToSend.append('dogImgFiles', dog1.dogImgUrl[0]);
}
formDataToSend.append('dogImgFiles', "");
}

formDataToSend.forEach((e) => {
Expand Down Expand Up @@ -285,8 +292,8 @@ const OwnDogsEditForm = ({dog}: IProps) => {
<CustomInput
width={"84%"}
height="48px"
value={
dog1?.gender ? dog1?.gender : "MALE"
genderValue={
dog1?.gender === "FEMALE" ? dog1?.gender : "MALE"
}
genderArr={["FEMAIL", "MALE"]}
updateGenderState={updateGenderState}
Expand All @@ -298,10 +305,10 @@ const OwnDogsEditForm = ({dog}: IProps) => {
<CustomInput
width={"84%"}
height="48px"
value={
dog1?.status
statusValue={
dog1?.status === "AVAILABLE"
? dog1?.status
: "AVAILABLE"
: "DONE"
}
statusArr={["DONE", "AVAILABLE"]}
updateStatusState={updateStatusState}
Expand Down
8 changes: 4 additions & 4 deletions src/component/ManageReview/ContentBox/ContentBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ const ContentBox = () => {

useEffect(() => {
const fetchData = async () => {
const url = `${process.env.REACT_APP_API_URL}adopter/reviews?page=${page - 1}`;
const res = await get<any>(
`${process.env.REACT_APP_API_URL}adopter/reviews`
url
);

console.log(res.data.data);
console.log(res);

return res.data.data;
};
Expand All @@ -71,8 +72,7 @@ const ContentBox = () => {
setTotalPage(res.totalPages);
})
.catch((err) => console.log(err));
setPage(1);
}, []);
}, [page]);

const searchItems = (searchValue: string) => {
setInputText(searchValue);
Expand Down
6 changes: 2 additions & 4 deletions src/pages/ManageOwnDogs/edit/EditOwnDogs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Navbar from "../../../component/MyPage/Navbar/Navbar";
import CustomLayout from "../../Layout/CustomLayout";
import OwnDogsEditForm, { IStatus } from "../../../component/ManageOwnDogs/Form/OwnDogsEditForm";
import OwnDogsEditForm, { IGender, IStatus } from "../../../component/ManageOwnDogs/Form/OwnDogsEditForm";
import { BoxsContainer, Container, SubmitButton } from "../styles";
import { useParams } from "react-router-dom";
import { useState , useEffect} from "react";
Expand Down Expand Up @@ -36,11 +36,9 @@ const EditOwnDogs = () => {
dogImgUrl: res.data.data.dogImgUrl,
birthDate: res.data.data.birthDate,
management: res.data.data.management,
status: res.data.data.status || "AVAILABLE",
status: res.data.data.status,
gender: res.data.data.gender,
});

console.log(res.data.data.status);
}
getDogById();
}, [id]);
Expand Down
13 changes: 13 additions & 0 deletions src/utils/ReviewUrl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const ReviewUrl = () => {
return (
<div>ReviewUrl</div>
)
}

export default ReviewUrl

// export const BreedersCollecturl = ({ page, searchs }: IBreedersCollecturl) => {
// return `breeders?page=${page - 1}${searchs.auth ? "&verification=yes" : ""}${
// searchs.keyword === "" ? "" : `&keyword=${searchs.keyword}`
// }`;
// };

0 comments on commit 31f463d

Please sign in to comment.