Skip to content

Commit

Permalink
feat(#5):수정
Browse files Browse the repository at this point in the history
  • Loading branch information
EunSeok-222 committed Nov 5, 2024
1 parent 7166537 commit 723221e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/pages/CommunityPage/CommunityDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const CommunityDetail = () => {
e.preventDefault(); // 새로고침 방지
const formData = new FormData(e.target);
const data = Object.fromEntries(formData.entries()); //객체로 변환
const now = new Date().toISOString();
data.createdAt = now; // 현재 시간 추가
// const now = new Date().toISOString();
// data.createdAt = now; // 현재 시간 추가
data.post = no;
//글 등록
axios.post('http://localhost:8080/api/communityComments',data)
Expand Down Expand Up @@ -97,7 +97,7 @@ const CommunityDetail = () => {
{comments
.filter((item)=>item.post === postDetail.postId)
.map((item)=>(
<div key={item.commentId}>
<div key={item.communityCommentId}>
<User2><VscAccount1/>작성자: {item.length > 0 && item[0].user}
<ListDate key={item.communityCommentId}>
{new Date(item.createdAt).toLocaleDateString('ko-KR', {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/CommunityPage/CommunityWrite.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const CommunityWrite = () => {

// FormData 객체 생성
const formData = new FormData();
const createdAt = new Date().toISOString();
formData.append('createdAt', createdAt); // 현재 시간 추가
// const createdAt = new Date().toISOString();
// formData.append('createdAt', createdAt); // 현재 시간 추가
formData.append('title',title)
formData.append('contents',contents)
formData.append('user',user)
Expand Down
33 changes: 19 additions & 14 deletions src/pages/HealthCare/HealthCare.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import axios from 'axios';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import Calendar from 'react-calendar';
import 'react-calendar/dist/Calendar.css';
import styled from 'styled-components';

const HealthCare = () => {
const [selectedDate, setSelectedDate] = useState(new Date());
const [appointments, setAppointments] = useState([]);
const [showInput, setShowInput] = useState({ hospital: false, nextVisit: false, healthCare: false });
const [showInput, setShowInput] = useState({ hospital: true, nextVisit: false, healthCare: false });
const [memo, setMemo] = useState('');


// useEffect(()=>{

// axios.get(`http://localhost:8080/api/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);
// });
// },[]);

const handleDateChange = date => {
setSelectedDate(date);
};
Expand All @@ -28,13 +41,13 @@ const HealthCare = () => {
} else if (type === '건강 관리') {
formData.append('healthDate', formattedDate);
formData.append('notes',memo); // 메모 추가
}
}console.log("건강 :" ,formData)

try {
const response = await axios.post('http://localhost:8080/api/healths', formData, {
headers: {
'Content-Type': 'multipart/form-data'
},
// headers: {
// 'Content-Type': 'application/json'
// },
});
console.log("등록 data : ", response.data);
alert("등록 성공")
Expand Down Expand Up @@ -97,14 +110,6 @@ const HealthCare = () => {

return (
<Container>
<form >
<select name="pet">
<option value="C">C언어</option>
<option value="JAVA">JAVA</option>
<option value="HTML">HTML</option>
<option value="CSS">CSS</option>
</select>
</form>
<Legend>
<LegendItem>
<Dot color="#FB3737" /> 병원 방문일
Expand Down
13 changes: 11 additions & 2 deletions src/pages/NanumPage/NanumDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ const PetItemDetailPage = () => {
const [itemDetail, setItemDetail] = useState([]);
const [comments, setComments] = useState([]);

// useEffect(() => {
// const fetchUserData = async () => {
// const userId = localStorage.getItem('userId');
// if (!userId) {
// console.error('User ID not found in local storage');
// return;
// }
// );

useEffect(()=>{ // 상세정보 불러오기

axios.get(`http://localhost:8080/api/petItems/${no}`)
Expand Down Expand Up @@ -56,8 +65,8 @@ const PetItemDetailPage = () => {
e.preventDefault(); // 새로고침 방지
const formData = new FormData(e.target);
const data = Object.fromEntries(formData.entries()); //객체로 변환
const now = new Date().toISOString();
data.createdAt = now; // 현재 시간 추가
// const now = new Date().toISOString();
// data.createdAt = now; // 현재 시간 추가
data.petItem = no;
//글 등록
axios.post('http://localhost:8080/api/petItemComments',data)
Expand Down
6 changes: 3 additions & 3 deletions src/pages/NanumPage/NanumWrite.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const PetItemPage = () => {

// FormData 객체 생성
const formData = new FormData();
const createdAt = new Date().toISOString();
formData.append('createdAt', createdAt); // 현재 시간 추가
// const createdAt = new Date().toISOString();
// formData.append('createdAt', createdAt); // 현재 시간 추가
formData.append('name',name)
formData.append('description',description)
formData.append('price',price)
formData.append('user',user)
formData.append('sharing',sharing)
if (imageUrl){
formData.append('imageUrl', imageUrl);// 'imageUrl'는 Spring Boot에서 받을 필드 이름과 일치해야 합니다
formData.append('imageUrl', imageUrl);
}

try {
Expand Down

0 comments on commit 723221e

Please sign in to comment.