From bf5c8c9c148a10eb72b3bdc617c16d02ddabb253 Mon Sep 17 00:00:00 2001 From: sockki Date: Tue, 9 Jan 2024 18:49:00 +0900 Subject: [PATCH] =?UTF-8?q?FEAT:=20=EC=A3=BC=EA=B1=B0=ED=99=98=EA=B2=BD=20?= =?UTF-8?q?=EC=88=98=EC=A0=95,=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=201?= =?UTF-8?q?=EC=B0=A8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BreederCollect1/BreederBox1.tsx | 2 +- .../CollectCOMP1/DogyCollect1/DogyBox1.tsx | 6 +- .../ProfileContentForms1/AvatarUpload.tsx | 2 +- .../LivingEnvironmentForm.tsx | 74 ++++++++++--------- .../ProfileContentForms1/ProfileForm.tsx | 2 +- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/component/CollectCOMP1/BreederCollect1/BreederBox1.tsx b/src/component/CollectCOMP1/BreederCollect1/BreederBox1.tsx index 5b63c6d..a928755 100644 --- a/src/component/CollectCOMP1/BreederCollect1/BreederBox1.tsx +++ b/src/component/CollectCOMP1/BreederCollect1/BreederBox1.tsx @@ -30,7 +30,7 @@ export default function BreederBox({ return ( - {profileImagUrl ? : } + {profileImagUrl ? Breeder_image : } {verified ? ( {status === "AVAILABLE" ? ( - + Dog_image ) : status === "UNDERWAY" ? ( <> - + 예약 중 ) : ( <> - + 분양 완료 )} diff --git a/src/component/MyPage/ProfileContent/ProfileContentForms1/AvatarUpload.tsx b/src/component/MyPage/ProfileContent/ProfileContentForms1/AvatarUpload.tsx index 37790e7..00b8f71 100644 --- a/src/component/MyPage/ProfileContent/ProfileContentForms1/AvatarUpload.tsx +++ b/src/component/MyPage/ProfileContent/ProfileContentForms1/AvatarUpload.tsx @@ -109,7 +109,7 @@ const AvatarUpload = ({ setChangeAvatar }: IAvatarUpload) => { {avatarPreview !== "" ? ( <> - + { const { register, @@ -42,9 +48,13 @@ const LivingEnvironmentForm = () => { setValue, } = useForm(); const getUser = DecodeToken(); - const [deleteImgId, setDeleteImgId] = useState([]) + const [deleteImgId, setDeleteImgId] = useState([]); const [imageData, setImageData] = useState([]); - const onValid = async ({livingRoom,bathRoom,yard,}: ILivingEnvironment) => { + const onValid = async ({ + livingRoom, + bathRoom, + yard, + }: ILivingEnvironment) => { const answer = await Swal.fire({ ...alertList.doubleCheckMessage("주거 환경을 저장 하시겠습니까?"), width: "350px", @@ -53,38 +63,36 @@ const LivingEnvironmentForm = () => { try { const form = new FormData(); const id = Array.from(new Set(deleteImgId)); - console.log(id) if (livingRoom && livingRoom.length > 0) { form.append("livingRoomImg", livingRoom[0]); - } - else { - form.append("livingRoomImg",""); - } - + } if (bathRoom && bathRoom.length > 0) { form.append("bathRoomImg", bathRoom[0]); - } - else { - form.append("bathRoomImg", ""); - } + } if (yard && yard.length > 0) { form.append("yardImg", yard[0]); + } + let data = { + "deletedImgsId":id } - else { - form.append("yardImg", ""); - } - form.append("deletedImgsId", `${id}`); + form.append("deletedImgsId", JSON.stringify(data)); const url = LivingEnvironmentUrl(); const response = await put( url, form ); + if(response.data.status === "SUCCESS") { + Swal.fire({ + ...alertList.successMessage("주거 환경이 저장되었습니다"), + width: "350px", + }); + } } catch (e) {} } }; // 이미지 url만 보내면 업로드가 되는 건지 - const [imagesPre, setImagesPre] = useState({ + const [imagesPre, setImagesPre] = useState({ yard: "", bathRoom: "", livingRoom: "", @@ -115,22 +123,22 @@ const LivingEnvironmentForm = () => { const onDelete = (data: string) => { if (data === "yard") { - setImagesPre({ ...imagesPre, yard: "" }); + setImagesPre({ ...imagesPre, yard: null }); setValue(data, null); - if(imageData[2] && imageData[2].id) { - setDeleteImgId([...deleteImgId, imageData[2].id]) + if (imageData[2] && imageData[2].id) { + setDeleteImgId([...deleteImgId, imageData[2].id]); } } else if (data === "bathRoom") { - setImagesPre({ ...imagesPre, bathRoom: "" }); + setImagesPre({ ...imagesPre, bathRoom: null }); setValue(data, null); - if(imageData[1] && imageData[1].id) { - setDeleteImgId([...deleteImgId, imageData[1].id]) + if (imageData[1] && imageData[1].id) { + setDeleteImgId([...deleteImgId, imageData[1].id]); } } else if (data === "livingRoom") { - setImagesPre({ ...imagesPre, livingRoom: "" }); + setImagesPre({ ...imagesPre, livingRoom: null }); setValue(data, null); - if(imageData[0] && imageData[0].id) { - setDeleteImgId([...deleteImgId, imageData[0].id]) + if (imageData[0] && imageData[0].id) { + setDeleteImgId([...deleteImgId, imageData[0].id]); } } }; @@ -154,12 +162,12 @@ const LivingEnvironmentForm = () => {
- 주거환경{} + 주거환경 - {imagesPre.yard !== "" ? ( + {imagesPre.yard !== null ? ( <> - + onDelete("yard")}> { 마당 - {imagesPre.bathRoom !== "" ? ( + {imagesPre.bathRoom !== null ? ( <> - + onDelete("bathRoom")}> { 화장실 - {imagesPre.livingRoom !== "" ? ( + {imagesPre.livingRoom !== null ? ( <> - + onDelete("livingRoom")}> { {avatar.avatar ? ( - + ) : (