diff --git a/src/apis/AxiosInstance.js b/src/apis/AxiosInstance.js index 81fbbc7..015ae4a 100644 --- a/src/apis/AxiosInstance.js +++ b/src/apis/AxiosInstance.js @@ -6,6 +6,8 @@ const token = tokenString ? JSON.parse(tokenString) : null; const Axios = axios.create({ // eslint-disable-next-line no-undef baseURL: import.meta.env.VITE_BASE_URL, + // baseURL: "http://localhost:8080/api", // Replace with your actual API URL + // eslint-disable-next-line no-undef headers: { Authorization: `Bearer ${token?.loginState?.data?.accessToken}`, "Content-Type": "application/json", diff --git a/src/pages/CommunityPage/CommunityDetail.jsx b/src/pages/CommunityPage/CommunityDetail.jsx index 00661a6..e9fab6a 100644 --- a/src/pages/CommunityPage/CommunityDetail.jsx +++ b/src/pages/CommunityPage/CommunityDetail.jsx @@ -10,12 +10,11 @@ const CommunityDetail = () => { const { no } = useParams(); // %% URL에서 글 번호(no)를 가져옴 %% const [postDetail, setPostDetail] = useState([]); const [comments, setComments] = useState([]); + const [refreshComments, setRefreshComments] = useState(false); useEffect(() => { - // 상세정보 불러오기 - axios - .get(`/communities/${no}`) + .get(`https://ureca.store/api/communities/${no}`) .then(response => { setPostDetail(response.data); console.log('나눔 상세 :', response.data); @@ -24,26 +23,27 @@ const CommunityDetail = () => { console.error('Error fetching data:', error); }); }, [no]); + // 댓글 목록 불러오기 +useEffect(( ) => { + const fetchComments = async () => { + try { + const response = await axios.get(`https://ureca.store/api/communityComments`); + setComments(response.data); // 댓글 목록 갱신 + console.log('댓글 목록 :', response.data); + } catch (error) { + console.error('Error:', error); + } + }; + + fetchComments(); +}, [refreshComments]); - useEffect(() => { - axios - .get(`/communityComments`) - .then(response => { - setComments(response.data); - console.log('댓글 목록 :', response.data); - }) - .catch(error => { - console.error('Error fetching data:', error); - }); - }, []); // 좋아요 수 증가 함수 const good = () => { const updatedGood = postDetail.good + 1; - - // 서버의 좋아요 수 업데이트 요청 axios - .put(`/communities/${no}`, { ...postDetail, good: updatedGood }) + .put(`https://ureca.store/api/communities/${no}`, { ...postDetail, good: updatedGood }) .then(response => { console.log('좋아요 업데이트:', response.data); setPostDetail(prevDetail => ({ ...prevDetail, good: updatedGood })); @@ -51,22 +51,23 @@ const CommunityDetail = () => { .catch(error => { console.error('좋아요 업데이트 실패:', error); }); - }; + } //댓글 등록 const handleSubmit = e => { e.preventDefault(); // 새로고침 방지 const formData = new FormData(e.target); + const user = localStorage.getItem('userId'); const data = Object.fromEntries(formData.entries()); //객체로 변환 - // const now = new Date().toISOString(); - // data.createdAt = now; // 현재 시간 추가 data.post = no; - //글 등록 + data.user = user; axios - .post('/communityComments', data) + .post('https://ureca.store/api/communityComments', data) .then(response => { console.log('등록 : ', response.data); setComments(prevComments => [...prevComments, response.data]); console.log('등록 data : ', data); + alert('댓글이 등록되었습니다!'); + setRefreshComments(prev => !prev); }) .catch(error => console.error('오류 발생:', error)); @@ -76,7 +77,7 @@ const CommunityDetail = () => { return ( - + 1 / 5 @@ -122,7 +123,6 @@ const CommunityDetail = () => { - 등록 @@ -248,8 +248,10 @@ const CommentST = styled.div` `; const CommentFrom = styled.form` width: 100%; + position: absolute; display: flex; justify-content: flex-end; + bottom: 0px; margin-top: auto; margin-bottom: 64px; `; @@ -257,6 +259,7 @@ const Container = styled.div` height: 100dvh; display: flex; flex-direction: column; + position: relative; `; const CommentCC = styled.input` height: 40px; diff --git a/src/pages/CommunityPage/CommunityList.jsx b/src/pages/CommunityPage/CommunityList.jsx index b898c2a..4bc89c0 100644 --- a/src/pages/CommunityPage/CommunityList.jsx +++ b/src/pages/CommunityPage/CommunityList.jsx @@ -22,7 +22,7 @@ const CommunityList = () => { useEffect(() => { axios - .get('/communities') + .get('https://ureca.store/api/communities') .then(response => { setComunityList(response.data); // 응답 데이터 저장 console.log('게시글 목록:', response.data); @@ -39,7 +39,7 @@ const CommunityList = () => { const updatedGood = (item.good || 0) + 1; // 서버의 좋아요 수 업데이트 요청 axios - .put(`/communities/${postId}`, { ...item, good: updatedGood }) + .put(`https://ureca.store/api/communities/${postId}`, { ...item, good: updatedGood }) .then(response => { console.log('좋아요 업데이트:', response.data); }) @@ -56,7 +56,7 @@ const CommunityList = () => { // 댓글 목록 불러오기 useEffect(() => { axios - .get(`/communityComments`) + .get(`https://ureca.store/api/communityComments`) .then(response => { setComments(response.data); console.log('댓글 목록 :', response.data); @@ -96,7 +96,7 @@ const CommunityList = () => { e.preventDefault(); navigate(`/community/detail/${item.postId}`); }}> - + 제목 : {item.title} diff --git a/src/pages/CommunityPage/CommunityWrite.jsx b/src/pages/CommunityPage/CommunityWrite.jsx index e1662c9..5096f92 100644 --- a/src/pages/CommunityPage/CommunityWrite.jsx +++ b/src/pages/CommunityPage/CommunityWrite.jsx @@ -36,7 +36,7 @@ const CommunityWrite = () => { } try { - const response = await axios.post('/communities', formData, { + const response = await axios.post('https://ureca.store/api/communities', formData, { headers: { 'Content-Type': 'multipart/form-data', }, diff --git a/src/pages/HealthCare/HealthCare.jsx b/src/pages/HealthCare/HealthCare.jsx index e348fb8..a383f8f 100644 --- a/src/pages/HealthCare/HealthCare.jsx +++ b/src/pages/HealthCare/HealthCare.jsx @@ -7,12 +7,49 @@ import styled from "styled-components"; const HealthCare = () => { const [selectedDate, setSelectedDate] = useState(new Date()); const [appointments, setAppointments] = useState([]); + const [petId, setPetId] = useState(); const [showInput, setShowInput] = useState({ hospital: true, nextVisit: false, healthCare: false, }); const [memo, setMemo] = useState(""); + const user = localStorage.getItem('userId'); + console.log(user) + + const petData = () => { + axios.get(`https://ureca.store/api/pets`) + .then((response) => { + setPetId( user === response.data.userId) + console.log('petId :', response.data); + }) + } + + + useEffect(() => { + const userData = (date) => { + if (!date || isNaN(new Date(date).getTime())) { + return ""; + } + return new Date(date).toISOString().split("T")[0]; + }; + + + + + + // const = async () => { + // try { + // const response = await axios.get(`https://ureca.store/api/healths`); + // setAppointments(response.data.map(item => ({ ...item, date: new Date(item.date) }))); + // console.log('댓글 목록:', response.data); + // } catch (error) { + // console.error("Error fetching data:", error); + // } + // }; + + + }, []); const handleDateChange = (date) => { setSelectedDate(date); @@ -20,33 +57,40 @@ const HealthCare = () => { const addAppointment = async (type, e) => { setAppointments([...appointments, { date: selectedDate, type, memo }]); - // e.preventDefault(); // 새로고침 방지 const formData = new FormData(); const formattedDate = formatDate(selectedDate); - formData.append("pet", 1); - - if (type === "병원 방문일") { - formData.append("visitedDate", formattedDate); - } else if (type === "다음 방문일") { - formData.append("nextCheckupDate", formattedDate); - } else if (type === "건강 관리") { - formData.append("healthDate", formattedDate); - formData.append("notes", memo); // 메모 추가 - } - console.log("건강 :", formData); - + const userId = localStorage.getItem('userId'); + + console.log("userId :", userId); try { - const response = await axios.post("/healths", formData, { - // headers: { - // 'Content-Type': 'application/json' - // }, - }); - console.log("등록 data : ", response.data); + // petId 가져오기 + const response = await axios.get(`https://ureca.store/api/pets/pet/${userId}`); + const petId = response.data[0].petId; + console.log("petId :", petId); + + // petId를 포함하여 formData에 추가 + formData.append("pet", petId); + + // 선택된 타입에 따라 필요한 필드를 formData에 추가 + if (type === "병원 방문일") { + formData.append("visitedDate", formattedDate); + } else if (type === "다음 방문일") { + formData.append("nextCheckupDate", formattedDate); + } else if (type === "건강 관리") { + formData.append("healthDate", formattedDate); + formData.append("notes", memo); // 메모 추가 + } + console.log("formData 내용:", formData); + + // formData를 포함하여 POST 요청 전송 + const postResponse = await axios.post("/healths", formData); + console.log("등록 data : ", postResponse.data); alert("등록 성공"); setMemo(""); + } catch (error) { console.error("오류 발생:", error); - alert("오류 발생:"); + alert("오류 발생"); } }; @@ -101,16 +145,7 @@ const HealthCare = () => { } }; - // useEffect(()=>{ - // axios.get(`/healths`) - // .then((response) => { - // setAppointments(response.data.map(item => ({ ...item, date: new Date(item.date) }))); - // console.log('댓글 목록 :', response.data); - // }) - // .catch((error) => { - // console.error("Error fetching data:", error); - // }); - // },[]); + return ( @@ -220,7 +255,7 @@ const CalendarWrapper = styled.div` `; const StyledCalendar = styled(Calendar)` - width: 100%; + .react-calendar__tile { padding: 1em 0.5em; @@ -235,6 +270,8 @@ const StyledCalendar = styled(Calendar)` .react-calendar__tile--active { background-color: #fff3e8; color: black; + height: 5px; + width: 5px; } .calendar-tile { @@ -247,6 +284,10 @@ const StyledCalendar = styled(Calendar)` border-radius: 8px; } + .react-calendar__month-view__days__day--weekend { + color: #17a1fa; + } + .selected { background-color: #fff3e8; } @@ -334,7 +375,8 @@ const RegisterButton = styled(Button)` margin-left: 5px; &:hover { - background-color: #45a049; + background-color: #ec7a4f; + color: wheat; } `; diff --git a/src/pages/MyPage/RegisterMissing.jsx b/src/pages/MyPage/RegisterMissing.jsx index 2c0b18a..70a84a5 100644 --- a/src/pages/MyPage/RegisterMissing.jsx +++ b/src/pages/MyPage/RegisterMissing.jsx @@ -1,34 +1,30 @@ import React, { useState, useEffect } from 'react'; import styled from 'styled-components'; import { useNavigate } from 'react-router-dom'; +import { useParams } from 'react-router-dom'; import axios from '../../apis/AxiosInstance'; - const ScrollableContainer = styled.div` max-height: 100%; border: 1px solid #ddd; margin: 64px 0; width: 100%; `; - const Container = styled.div` display: flex; flex-direction: column; `; - const MapContainer = styled.div` width: 100%; height: 250px; margin-bottom: 30px; border: 1px solid #ddd; `; - const LocationContainer = styled.div` display: flex; flex-direction: column; margin-left: 5%; margin-right: 5%; `; - const SubTitle = styled.label` font-size: 15px; font-weight: bold; @@ -36,43 +32,38 @@ const SubTitle = styled.label` flex-grow: 1; margin-top: 5px; `; - const InputContainer = styled.div` position: relative; display: flex; align-items: center; margin-bottom: 5px; `; - const StyledInput = styled.input` width: 100%; padding: 10px 20px 10px 10px; - border: 1px solid #e4e4e4; + border: 1px solid #E4E4E4; border-radius: 5px; font-size: 11px; margin-bottom: 10px; `; - const AddressContainer = styled.div` display: flex; position: relative; flex-direction: column; margin-bottom: 10px; `; - const DateContainer = styled.div` display: flex; flex-direction: column; margin-bottom: 10px; `; - const EditButton = styled.button` position: absolute; right: 10px; top: 40%; transform: translateY(-50%); - background-color: #ffefef; - color: #ff6e00; + background-color: #FFEFEF; + color: #FF6E00; border: none; border-radius: 8px; cursor: pointer; @@ -82,16 +73,14 @@ const EditButton = styled.button` height: 22px; padding: 5px 10px; transition: background-color 0.3s; - &:hover { - background-color: #ffd3d3; + background-color: #FFD3D3; } `; - const ImageContainer = styled.div` width: 125px; height: 125px; - border: 1px solid #e4e4e4; + border: 1px solid #E4E4E4; border-radius: 8px; display: flex; align-items: center; @@ -99,15 +88,13 @@ const ImageContainer = styled.div` overflow: hidden; cursor: pointer; position: relative; - background-color: #f8f8f8; + background-color: #F8F8F8; `; - const PlaceholderText = styled.span` color: #888; font-size: 12px; text-align: center; `; - const PreviewImage = styled.img` position: absolute; width: 100%; @@ -115,39 +102,34 @@ const PreviewImage = styled.img` object-fit: cover; border-radius: 8px; `; - const StyledTextarea = styled.textarea` width: 100%; padding: 10px; - border: 1px solid #e4e4e4; + border: 1px solid #E4E4E4; border-radius: 5px; font-size: 11px; resize: none; height: 100px; `; - const RegisterButton = styled.button` display: flex; justify-content: center; align-items: center; - border: 1px solid #e4e4e4; + border: 1px solid #E4E4E4; width: 100%; height: 43px; text-align: center; border-radius: 8px; margin-top: 10px; - margin-bottom: 50px; - + margin-bottom: 70px; &:hover { - background-color: #ff6e00; + background-color: #FF6E00; color: white; } `; - const RegisterMissing = () => { const navigate = useNavigate(); - const userId = localStorage.getItem('userId'); - + const { userId, petId } = useParams(); const [petName, setPetName] = useState(''); const [date, setDate] = useState(''); const [address, setAddress] = useState(''); @@ -159,10 +141,25 @@ const RegisterMissing = () => { const [latitude, setLatitude] = useState(37.5665); const [longitude, setLongitude] = useState(126.978); const [previewImage, setPreviewImage] = useState(null); - - const today = new Date().toISOString().split('T')[0]; - - const handleImageChange = e => { + const [walkrouteId, setWalkrouteId] = useState(null); // walkrouteId 상태 추가 + const today = new Date().toISOString().split("T")[0]; + useEffect(() => { + const fetchWalkRouteId = async () => { + try { + const response = await axios.get(`/walkRoutes/user/${userId}`); // 사용자 ID에 따른 walkroute 조회 + if (response.status === 200) { + const walkRoutes = response.data; + if (walkRoutes.length > 0) { + setWalkrouteId(walkRoutes[0].walkrouteId); // 첫 번째 walkroute의 ID 설정 + } + } + } catch (error) { + console.error('Error fetching walk routes:', error); + } + }; + fetchWalkRouteId(); + }, [userId]); + const handleImageChange = (e) => { const file = e.target.files[0]; if (file) { const reader = new FileReader(); @@ -174,11 +171,11 @@ const RegisterMissing = () => { setPreviewImage(null); } }; - const handleSubmit = async () => { const formData = new FormData(); - formData.append('petId', 1); - formData.append('walkroute', 1); + formData.append('petId', petId); + formData.append('userId', userId); + formData.append('walkroute', walkrouteId); // 가져온 walkrouteId 사용 formData.append('location', locationInput); formData.append('alarmName', '고창준'); formData.append('missingDate', `${date}T00:00:00+09:00`); @@ -191,27 +188,23 @@ const RegisterMissing = () => { formData.append('contactNumber', phone); formData.append('missingDetails', description); formData.append('createdAt', new Date().toISOString()); - const imageInput = document.querySelector('input[type="file"]'); if (imageInput.files[0]) { formData.append('imageUrl', imageInput.files[0]); } - try { const response = await axios.post('/missings', formData, { headers: { 'Content-Type': 'multipart/form-data', }, }); - if (response.status === 201) { - const petId = 1; //일단 더미로 1로 지정 - if (petId) { + if (userId) { alert('실종등록이 완료되었습니다.'); navigate(`/myPage/${userId}/missingSave`); } else { - console.error('PetId not found in response'); - alert('반려동물 ID를 받아오는데 실패했습니다.'); + console.error('User ID not found in local storage'); + alert('사용자 ID를 받아오는데 실패했습니다.'); } } else { alert('등록 중 오류가 발생했습니다. 다시 시도해주세요.'); @@ -221,86 +214,68 @@ const RegisterMissing = () => { alert('서버와 통신 중 오류가 발생했습니다.'); } }; - useEffect(() => { const container = document.getElementById('map'); const options = { center: new window.kakao.maps.LatLng(latitude, longitude), level: 3, }; - const newMap = new window.kakao.maps.Map(container, options); setMap(newMap); - const newMarker = new window.kakao.maps.Marker({ position: new window.kakao.maps.LatLng(latitude, longitude), }); newMarker.setMap(newMap); setMarker(newMarker); - const geocoder = new window.kakao.maps.services.Geocoder(); - const searchAddrFromCoords = (coords, callback) => { geocoder.coord2Address(coords.getLng(), coords.getLat(), callback); }; - - window.kakao.maps.event.addListener(newMap, 'click', mouseEvent => { + window.kakao.maps.event.addListener(newMap, 'click', (mouseEvent) => { const clickedPosition = mouseEvent.latLng; newMarker.setPosition(clickedPosition); setLatitude(clickedPosition.getLat()); setLongitude(clickedPosition.getLng()); - - searchAddrFromCoords(clickedPosition, function (result, status) { + searchAddrFromCoords(clickedPosition, function(result, status) { if (status === window.kakao.maps.services.Status.OK) { const addr = result[0].road_address ? result[0].road_address.address_name : result[0].address.address_name; setLocationInput(`주소: ${addr}`); } }); }); - // 초기 위치의 주소 가져오기 - searchAddrFromCoords(new window.kakao.maps.LatLng(latitude, longitude), function (result, status) { + searchAddrFromCoords(new window.kakao.maps.LatLng(latitude, longitude), function(result, status) { if (status === window.kakao.maps.services.Status.OK) { const addr = result[0].road_address ? result[0].road_address.address_name : result[0].address.address_name; setLocationInput(`${addr}`); } }); }, [latitude, longitude]); - const getCurrentLocation = () => { if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition( - position => { - const { latitude, longitude } = position.coords; - setLatitude(latitude); - setLongitude(longitude); - - const geocoder = new window.kakao.maps.services.Geocoder(); - const coord = new window.kakao.maps.LatLng(latitude, longitude); - - geocoder.coord2Address(coord.getLng(), coord.getLat(), (result, status) => { - if (status === window.kakao.maps.services.Status.OK) { - const addr = result[0].road_address - ? result[0].road_address.address_name - : result[0].address.address_name; - setLocationInput(`주소: ${addr}`); - } - }); - }, - error => { - console.error('위치 정보에 접근할 수 없습니다.', error); - alert('위치 정보를 가져올 수 없습니다. 브라우저 설정을 확인해 주세요.'); - }, - ); + navigator.geolocation.getCurrentPosition((position) => { + const { latitude, longitude } = position.coords; + setLatitude(latitude); + setLongitude(longitude); + const geocoder = new window.kakao.maps.services.Geocoder(); + const coord = new window.kakao.maps.LatLng(latitude, longitude); + geocoder.coord2Address(coord.getLng(), coord.getLat(), (result, status) => { + if (status === window.kakao.maps.services.Status.OK) { + const addr = result[0].road_address ? result[0].road_address.address_name : result[0].address.address_name; + setLocationInput(`주소: ${addr}`); + } + }); + }, (error) => { + console.error("위치 정보에 접근할 수 없습니다.", error); + alert("위치 정보를 가져올 수 없습니다. 브라우저 설정을 확인해 주세요."); + }); } else { - alert('이 브라우저는 Geolocation을 지원하지 않습니다.'); + alert("이 브라우저는 Geolocation을 지원하지 않습니다."); } }; - - const handleDateChange = e => { + const handleDateChange = (e) => { const value = e.target.value.replace(/[^0-9]/g, ''); let formattedValue = ''; - if (value.length > 4) { formattedValue += value.substring(0, 4); formattedValue += '-'; @@ -314,14 +289,11 @@ const RegisterMissing = () => { } else { formattedValue += value; } - setDate(formattedValue); }; - - const handlePhoneChange = e => { + const handlePhoneChange = (e) => { const value = e.target.value.replace(/[^0-9]/g, ''); let formattedValue = ''; - if (value.length > 0) { formattedValue += value.substring(0, 3); } @@ -329,12 +301,10 @@ const RegisterMissing = () => { formattedValue += '-' + value.substring(3, 7); } if (value.length > 7) { - formattedValue += '-' + value.substring(7, 11); + formattedValue += '-' + value.substring(7,11); } - setPhone(formattedValue); }; - return ( @@ -354,7 +324,12 @@ const RegisterMissing = () => { 아이 사진 - + document.getElementById('imageUpload').click()}> {previewImage ? ( @@ -363,16 +338,11 @@ const RegisterMissing = () => { )} 상세정보 - setDescription(e.target.value)} - /> + setDescription(e.target.value)} /> 등록하기 ); }; - -export default RegisterMissing; +export default RegisterMissing; \ No newline at end of file diff --git a/src/pages/NanumPage/NanumDetail.jsx b/src/pages/NanumPage/NanumDetail.jsx index 948a23d..489027d 100644 --- a/src/pages/NanumPage/NanumDetail.jsx +++ b/src/pages/NanumPage/NanumDetail.jsx @@ -10,10 +10,11 @@ const PetItemDetailPage = () => { const { no } = useParams(); //URL에서 글 번호(no)를 가져옴 const [itemDetail, setItemDetail] = useState([]); const [comments, setComments] = useState([]); + const [refreshComments, setRefreshComments] = useState(false); useEffect(() => { axios - .get(`/petItems/${no}`) + .get(`https://ureca.store/api/petItems/${no}`) .then(response => { setItemDetail(response.data); console.log('나눔 상세 :', response.data); @@ -26,7 +27,7 @@ const PetItemDetailPage = () => { useEffect(() => { const fetchComments = async () => { try { - const response = await axios.get(`/petItemComments`); + const response = await axios.get(`https://ureca.store/api/petItemComments`); setComments(response.data); console.log('댓글 목록 :', response.data); } catch (error) { @@ -35,13 +36,13 @@ const PetItemDetailPage = () => { }; fetchComments(); - }, []); + }, [refreshComments]); // 좋아요 수 증가 함수 const good = () => { const updatedGood = itemDetail.good + 1; axios - .put(`/petItems/${no}`, { ...itemDetail, good: updatedGood }) + .put(`https://ureca.store/api/petItems/${no}`, { ...itemDetail, good: updatedGood }) .then(response => { console.log('좋아요 업데이트:', response.data); setItemDetail(prevDetail => ({ ...prevDetail, good: updatedGood })); @@ -59,21 +60,24 @@ const PetItemDetailPage = () => { data.petItem = no; data.user = user; axios - .post('/petItemComments', data) + .post('https://ureca.store/api/petItemComments', data) .then(response => { console.log('등록 : ', response.data); setComments(prevComments => [...prevComments, response.data]); console.log('등록 data : ', data); + alert('등록 성공!'); + setRefreshComments(prev => !prev); }) .catch(error => console.error('오류 발생:', error)); e.target.reset(); }; + return ( - + 1 / 5 @@ -241,14 +245,17 @@ const CommentST = styled.div` `; const CommentFrom = styled.form` width: 100%; + position: absolute; display: flex; justify-content: flex-end; + bottom: 0px; margin-top: auto; margin-bottom: 64px; `; const Container = styled.div` height: 100dvh; display: flex; + position: relative; flex-direction: column; `; const CommentCC = styled.input` diff --git a/src/pages/NanumPage/NanumList.jsx b/src/pages/NanumPage/NanumList.jsx index 90d207e..79c9d40 100644 --- a/src/pages/NanumPage/NanumList.jsx +++ b/src/pages/NanumPage/NanumList.jsx @@ -15,7 +15,7 @@ const PetItemListPage = () => { //게시글 목록 불러오기 useEffect(() => { axios - .get('/petItems') + .get('https://ureca.store/api/petItems') .then(response => { setPetItemList(response.data); // 응답 데이터 저장 console.log('게시글 목록:', response.data); @@ -32,7 +32,7 @@ const PetItemListPage = () => { const updatedGood = (item.good || 0) + 1; // 서버의 좋아요 수 업데이트 요청 axios - .put(`/petItems/${petItemId}`, { ...item, good: updatedGood }) + .put(`https://ureca.store/api/petItems/${petItemId}`, { ...item, good: updatedGood }) .then(response => { console.log('좋아요 업데이트:', response.data); }) @@ -49,7 +49,7 @@ const PetItemListPage = () => { // 댓글 목록 불러오기 useEffect(() => { axios - .get(`/petItemComments`) + .get(`https://ureca.store/api/petItemComments`) .then(response => { setComments(response.data); console.log('댓글 목록 :', response.data); @@ -94,7 +94,7 @@ const PetItemListPage = () => { e.preventDefault(); navigate(`/nanumList/detail/${item.petItemId}`); }}> - + {item.name} 작성자{item.user} diff --git a/src/pages/NanumPage/NanumWrite.jsx b/src/pages/NanumPage/NanumWrite.jsx index 31bdf1a..ffe2911 100644 --- a/src/pages/NanumPage/NanumWrite.jsx +++ b/src/pages/NanumPage/NanumWrite.jsx @@ -31,7 +31,7 @@ const PetItemPage = () => { formData.append('imageUrl', imageUrl); } try { - const response = await axios.post('/petItems', formData, { + const response = await axios.post('https://ureca.store/api/petItems', formData, { headers: { 'Content-Type': 'multipart/form-data', }, @@ -84,11 +84,6 @@ const PetItemPage = () => {
- {/* */} -
{uploadedImage ? (