Skip to content

Commit

Permalink
[#72] fix: Change category type string to num
Browse files Browse the repository at this point in the history
  • Loading branch information
rosieyeon committed Feb 10, 2022
1 parent ecd708b commit 3e2cd33
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/components/categorySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function CategorySelect(props) {
// console.log(selectedCategory);
useEffect(() => {
props.categoryseq(selectedCategory);
}, []);
}, [selectedCategory]);
const SelectBox = (props) => {
// console.log(props.options.category);
return (
Expand Down
7 changes: 3 additions & 4 deletions src/components/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export default function StudyDatePicker(props) {
const [startDate, setStartDate] = useState(addDays(new Date(), 7));

//yyyy-mm-dd 포맷 날짜 생성
function changeDateFormat() {
const d = startDate;
function changeDateFormat(d) {
return (
d.getFullYear() +
"-" +
Expand All @@ -27,8 +26,8 @@ export default function StudyDatePicker(props) {
);
}
useEffect(() => {
props.endDate(changeDateFormat());
}, []);
props.endDate(changeDateFormat(startDate));
}, [startDate]);

const months = [
"January",
Expand Down
3 changes: 2 additions & 1 deletion src/components/paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import "../statics/css/paginator.css";

export default function Paginator(props) {
const [page, setPage] = useState(1);

const handlePageChange = (page) => {
setPage(page);
};
useEffect(() => {
props.currentpage(page);
}, []);
}, [page]);
return (
<Pagination
activePage={page}
Expand Down
59 changes: 30 additions & 29 deletions src/pages/StudyRecruit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import "../statics/css/studyRecruit.css";
export default function StudyRecruit() {
const navigate = useNavigate();
const TOKEN = localStorage.getItem("accessToken");
const [category, setCategory] = useState("");
const [category, setCategory] = useState(0);
const [postData, setPostData] = useState([]);
const [searchInput, setSearchInput] = useState("");
const [currenPage, setCurrentPage] = useState(1);
// console.log(
// "page: ",
// currenPage,
// "search: ",
// searchInput,
// "category: ",
// category
// );
const [currentPage, setCurrentPage] = useState(1);

console.log(
"page: ",
currentPage,
"search: ",
searchInput,
"category: ",
category
);

const onChangeSearch = useCallback((event) => {
setSearchInput(event.target.value);
Expand All @@ -31,19 +32,11 @@ export default function StudyRecruit() {
const onClickSearch = useCallback(() => {
if (isLogin) {
axios
.get(
"/studies?page=" +
currenPage +
"&type=" +
category +
"&key=" +
searchInput,
{
headers: {
Authorization: `Bearer ${TOKEN}`,
},
}
)
.get("/studies?page=1&type=" + category + "&key=" + searchInput, {
headers: {
Authorization: `Bearer ${TOKEN}`,
},
})
.then((res) => {
const data = res.data.data;
setPostData((prevState) => ({
Expand All @@ -62,11 +55,19 @@ export default function StudyRecruit() {
useEffect(() => {
if (isLogin) {
axios
.get("/studies?page=1&type=0&key=", {
headers: {
Authorization: `Bearer ${TOKEN}`,
},
})
.get(
"/studies?page=" +
currentPage +
"&type=" +
category +
"&key=" +
searchInput,
{
headers: {
Authorization: `Bearer ${TOKEN}`,
},
}
)
.then((res) => {
// console.log(res);
const data = res.data.data;
Expand All @@ -76,7 +77,7 @@ export default function StudyRecruit() {
}));
});
}
}, []);
}, [currentPage]);
return (
<div className="studyrecruit">
<div className="studyrecruit-heading">
Expand Down
28 changes: 24 additions & 4 deletions src/pages/studyRecruitCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ export default function StudyRecruitCreate() {
const [studyShortDesc, setStudyShotrDesc] = useState("");
const [studyDesc, setStudyDesc] = useState("");
const [studyRecruitEnd, setStudyRecruitEnd] = useState("");
const [categorySeq, setCategorySeq] = useState("");
console.log(userSeq, studyTitle, studyShortDesc, studyDesc, studyRecruitEnd);
const [categorySeq, setCategorySeq] = useState(0);

// [TODO]: 스터디 상세정보 글자수 실시간으로 보여주기 (1000자 제한)
const onChangeStudyDesc = useCallback((event) => {
Expand Down Expand Up @@ -300,14 +299,26 @@ export default function StudyRecruitCreate() {
}
}, [isSunday, sunday]);

console.log(
userSeq,
typeof Number(categorySeq),
Number(categorySeq),
studyTitle,
studyShortDesc,
studyDesc,
studyRecruitEnd,
days,
studyDesc.length
);

const onSubmitStudy = useCallback(() => {
const TOKEN = localStorage.getItem("accessToken");
axios
.post(
"/studies",
{
hostSea: userSeq,
categorySeq: categorySeq,
categorySeq: Number(categorySeq),
studyTitle: studyTitle,
studyShortDesc: studyShortDesc,
studyDesc: studyDesc,
Expand All @@ -323,7 +334,16 @@ export default function StudyRecruitCreate() {
.then((res) => {
navigate("/studyrecruit");
});
}, []);
}, [
userSeq,
categorySeq,
studyTitle,
studyShortDesc,
studyDesc,
studyRecruitEnd,
days,
]);

// console.log(days);
// console.log(categorySeq);
return (
Expand Down
2 changes: 2 additions & 0 deletions src/statics/css/studyRecruitCreate.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/statics/css/studyRecruitCreate.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/statics/scss/studyRecruitCreate.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
margin-top: 5px;
padding-left: 8px;
font-size: 12px;
color: var(--textColor);
}
::placeholder {
font-size: 12px;
Expand Down Expand Up @@ -117,6 +118,7 @@
border: 1px solid var(--borderColor);
background-color: var(--bgColor);
padding: 12px;
color: var(--textColor);
}
}
}
Expand Down

0 comments on commit 3e2cd33

Please sign in to comment.