Skip to content

Commit

Permalink
(24/05/11 - 3) 클로즈 베타 테스트 버전 배포합니다.
Browse files Browse the repository at this point in the history
 (24/05/11 - 3) 클로즈 베타 테스트 버전 배포합니다.
  • Loading branch information
fakerdeft authored May 11, 2024
2 parents 9f66461 + 445cdd9 commit 473c703
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 65 deletions.
52 changes: 19 additions & 33 deletions src/components/pages/postPage/questionDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,14 @@ function QuestionDetailPage() {
// 답변 내용이 비어있을 경우 에러 던지기
if (answerRef.current?.value === '') {
throw new Error('크기가 1에서 500 사이여야 합니다');

}

const answerResponse = await fetchAPI('/api/answer', 'POST', requestData);

if (!answerResponse.ok){
if (!answerResponse.ok) {
if (answerResponse.status === 400) {
showErrorToast('질문 작성자는 답변 작성이 불가능합니다.')
}
showErrorToast('질문 작성자는 답변 작성이 불가능합니다.');
}
}
if (answerResponse.statusCode === 'CREATED' && answerRef.current) {
setPostAnswer(answerRef.current?.value);
Expand Down Expand Up @@ -219,9 +218,6 @@ function QuestionDetailPage() {
};

const handleClickEdit = async () => {
if (answerCount > 0){
showErrorToast('답변이 있는 글은 수정할 수 없습니다.')
}else{
try {
const pathSegments = window.location.pathname.split('/');
const companyId = pathSegments[2];
Expand Down Expand Up @@ -252,37 +248,27 @@ function QuestionDetailPage() {
} catch (error) {
if (error instanceof Error) showErrorToast(error.message);
}
};}
};
const handleClickDelete = async () => {
if (answerCount > 0){
showErrorToast('답변이 있는 글은 삭제할 수 없습니다.')
}else{
try {
const response = await fetchAPI(`/api/question/${questionId}`, 'DELETE');

if (response.error) {
console.log(response)
if (response.status === 409) {
showErrorToast('답변이 달린 게시물은 삭제할 수 없습니다. ');
return;
}
throw new Error('요청 처리 중 오류가 발생했습니다.');
} else if (confirm('삭제하시겠습니까?')) {
showSuccessToast('질문이 삭제되었습니다.');
const pathSegments = window.location.pathname.split('/');
const companyId = pathSegments[2];
navigate(`/company-info/${companyId}`);
}
const response = await fetchAPI(`/api/question/${questionId}`, 'DELETE');


if (response.error) {
if (response.status === 409) {
showErrorToast('답변이 달린 게시물은 삭제할 수 없습니다. ');
return;
}
throw new Error('요청 처리 중 오류가 발생했습니다.');
} else if (confirm('삭제하시겠습니까?')) {
showSuccessToast('질문이 삭제되었습니다.');
const pathSegments = window.location.pathname.split('/');
const companyId = pathSegments[2];
navigate(`/company-info/${companyId}`);
}
} catch (error) {
if (error instanceof Error)

showErrorToast(error.message);
console.log(error)
if (error instanceof Error) showErrorToast(error.message);
}
};}

};

const handleReportSubmit = async () => {
toggleReportPopup();
Expand Down
2 changes: 0 additions & 2 deletions src/components/pages/searchPage/searchResultPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ function SearchResultPage() {
);
const data = await response.json();
setSearchData(data.data.companyList);

console.log('페이지 내 결과', data.data);
} catch (error) {
showErrorToast(`오류 발생: ${error}`);
setSearchData([]);
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/adminSelection/companySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function CompanySelection() {
})
.then((response) => response.json())
.then((data: ApiResponse) => {
console.log(data);
// console.log(data);
setCompanies(data.data.companies);
setTotalPages(data.data.totalPages);
seTtotalCompanyCount(data.data.totalElements);
Expand All @@ -118,11 +118,12 @@ export default function CompanySelection() {
})
.then((response) => response.json())
.then((data: ApiResponse) => {
console.log(data);
// console.log(data);
setCompanies(data.data.companies);
setIsLoading(false);
})
.catch((error) => {
// console.error('Error:', error);
console.error('Error:', error);
setIsLoading(false);
});
Expand Down
48 changes: 26 additions & 22 deletions src/components/ui/adminSelection/memberSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@ import React from 'react';
import './memberSelection.scss';
import AdminSearch from '../../../asset/image/admin-search.svg';
import Button from '../button/Button/Button';
import { ACCESS_TOKEN, BASE_URL } from '../../global/constants';
// import { ACCESS_TOKEN, BASE_URL } from '../../global/constants';
import Calendar from '../calendar/calendar';

export default function MemberSelection() {
const fetchMember = (pageNo: number) => {
const queryParams = new URLSearchParams({
pageNo: pageNo.toString(),
criterion: 'createdAt',
});
const url = `${BASE_URL}/api/member/admin?${queryParams.toString()}`;
fetch(url, {
headers: {
Authorization: `Bearer ${localStorage.getItem(ACCESS_TOKEN)}`,
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((data: Response) => {
console.log(data);
})
.catch((error) => {
console.error('Error:', error);
});
};
console.log(fetchMember(0));
// const [isLoading, setIsLoading] = useState(false);

// const fetchMember = (pageNo: number) => {
// const queryParams = new URLSearchParams({
// pageNo: pageNo.toString(),
// criterion: 'createdAt',
// });
// const url = `${BASE_URL}/api/member/admin?${queryParams.toString()}`;
// fetch(url, {
// headers: {
// Authorization: `Bearer ${localStorage.getItem(ACCESS_TOKEN)}`,
// 'Content-Type': 'application/json',
// },
// })
// .then((response) => response.json())
// .then((data: Response) => {
// // console.log(data);
// })
// .catch((error) => {
// console.error('Error:', error);
// setIsLoading(false);
// });
// };
// // console.log(fetchMember(0));
// fetchMember;

return (
<div className="ad-memberSelection-container">
Expand Down
8 changes: 2 additions & 6 deletions src/components/ui/question/answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ function AnswerModule({
setIsAdopted,
fetchData,
anyAdopted,
answererTag,
}: AnswerDetailProps) {
const [questionerTag, setQuestionerTag] = useState('');
const { myNickname } = useSelector((state: AppState) => state.user);

console.log(setQuestionerTag); //

const [isShowEdit, setIsShowEdit] = useState(false);

const [isShowReport, setIsShowReport] = useState(false);
Expand All @@ -148,8 +146,6 @@ function AnswerModule({
}
};

console.log(answerId);

const handleClickEdit = async () => {
try {
await fetchAPI(`/api/question/${answerId}`, 'PATCH');
Expand Down Expand Up @@ -227,7 +223,7 @@ function AnswerModule({
<div className="answer-container-info">
<NameContainer>
<ImageContainer
src={questionerTag === '취준생' ? Leaf : Tree}
src={answererTag === '취준생' ? Leaf : Tree}
alt=""
/>
<AnswerName>{answererNickname}</AnswerName>
Expand Down

0 comments on commit 473c703

Please sign in to comment.