Skip to content

Commit

Permalink
오류수정20:59
Browse files Browse the repository at this point in the history
  • Loading branch information
dbstjs95 committed May 12, 2022
1 parent 2c56f1c commit 0ea9a87
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
26 changes: 20 additions & 6 deletions client/src/component/MypageCompo/FreeWriting.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,35 @@ function Writing() {
type: 'Free',
targetPoint: 0,
...textValues,
fileURL: fileName,
file: fileName,
},
config,
)
.then((res) => {
if (res.data.infoId) alert('글이 등록되었습니다.');
setTextValues({
title: null,
content: null,
});
setSelectedFile(null);
if (res.data.infoId) alert('글이 등록되었습니다.');
})
.catch((err) => alert('파일업로드 주소가 서버에 반영 안 됨.'));
.catch((err) => {
deleteFile(fileName);
alert('파일업로드 주소가 서버에 반영 안 됨.');
});
});
};

//파일 삭제
const deleteFile = (fileName) => {
const params = {
Bucket: S3_BUCKET,
Key: fileName,
};

myBucket.deleteObject(params, (err, data) => {
if (data) console.log('s3파일 삭제');
if (err) console.log('s3파일 삭제 실패');
});
};

Expand Down Expand Up @@ -203,9 +219,7 @@ function Writing() {
<textarea
name="content"
id="content"
// rows="10"
// cols="55"
placeholder="내용"
placeholder="첨부파일에 대한 설명을 적어주세요."
value={textValues.content}
onChange={(e) =>
setTextValues({ ...textValues, content: e.target.value })
Expand Down
2 changes: 1 addition & 1 deletion client/src/component/MypageCompo/MyPosts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import styled from 'styled-components';
import myPostData from '../../mockdata/myPostData';
import { useDispatch, useSelector } from 'react-redux';
import { selectUserInfo } from '../../store/slices/userInfo';
import axios from 'axios';
Expand Down Expand Up @@ -125,6 +124,7 @@ function MyPosts() {
//첫 렌더링: 내가 쓴 게시글 받아오기
useEffect(() => {
if (postList.length > offset) return;

axios
.get(
`${process.env.REACT_APP_SERVER_DEV_URL}/users/info?pages=${page}&limit=${LIMIT}`,
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/content/contentBoard/FreeBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function FreeBoard() {
pages: page,
limit: LIMIT,
like_type: order === '인기순',
lastId: list.pop()?.id,
lastId: list[list.length - 1]?.id,
};

const infoURL = `${process.env.REACT_APP_SERVER_DEV_URL}/info/free`;
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/content/contentBoard/PaidBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function PaidBoard() {
pages: page,
limit: LIMIT,
like_type: order === '인기순',
lastId: list.pop()?.id,
lastId: list[list.length - 1]?.id,
};

const infoURL = `${process.env.REACT_APP_SERVER_DEV_URL}/info/paid`;
Expand Down

0 comments on commit 0ea9a87

Please sign in to comment.