Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #77

Merged
merged 6 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/assets/icons/promotion/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/assets/icons/promotion/profileImg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 15 additions & 12 deletions src/pages/Promotion/ApplyStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GroupSelectList from "../match/GroupSelectList";
import ShowApplyClub from "./promotion_components/ShowApplyClub";
import ShowRecruitmentClub from "./promotion_components/ShowRecruitmentClub";

import api from "../../apis/utils/api";
const WrapperContainer = styled.div`
position: fixed;
left: 0px;
Expand Down Expand Up @@ -116,7 +117,7 @@ const ContentContainer = styled.div`
overflow: auto;
display: flex;
flex-direction: column;
padding: 0 20px;
padding: 0 16px;
`;

const ApplyStatus = ({ isapplyStatusModal, closeApplyStatusModal }) => {
Expand Down Expand Up @@ -159,17 +160,19 @@ const ApplyStatus = ({ isapplyStatusModal, closeApplyStatusModal }) => {
<HeaderContainer>
<PreviousButton onClick={closeApplyStatusModal} />
<HeaderTitle>동아리 지원현황</HeaderTitle>
<SelectMyGroupContainer
onClick={() => setShowGroupSelectList(!showGroupSelectList)}
>
<SelectedGroup>
{selectedGroup ? selectedGroup.clubName : "동아리 선택"}
</SelectedGroup>
{showGroupSelectList && (
<GroupSelectList onSelect={handleGroupSelect} />
)}
<ArrowDownButton></ArrowDownButton>
</SelectMyGroupContainer>
{/* {showRecruitmentClub && (
<SelectMyGroupContainer
onClick={() => setShowGroupSelectList(!showGroupSelectList)}
>
<SelectedGroup>
{selectedGroup ? selectedGroup.clubName : "동아리 선택"}
</SelectedGroup>
{showGroupSelectList && (
<SelectListContiner onSelect={handleGroupSelect} />
)}
<ArrowDownButton></ArrowDownButton>
</SelectMyGroupContainer>
)} */}
</HeaderContainer>
<TabBar>
<TabItem
Expand Down
18 changes: 16 additions & 2 deletions src/pages/Promotion/ClubApply.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ClubApply = ({
clubId,
clubName,
sportsCategory,
recruitingPostId,
}) => {
const accessToken = localStorage.getItem("accessToken");
const [input, setInput] = useState({
Expand All @@ -25,23 +26,36 @@ const ClubApply = ({
});
const postClubApply = async () => {
try {
const requestBody = {
recruitingPostId: recruitingPostId,
answers: {
1: input["1"],
2: input["2"],
3: input["3"],
},
};
console.log("requestBody 테스트", requestBody);
const response = await axios.post(
`${process.env.REACT_APP_SERVER_URL}/v1/api/clubs/${clubId}`,
{ answers: input },
requestBody,
{
headers: {
"Content-Type": "application/json",
access: `${accessToken}`,
},
params: {
clubMemberId: clubId,
},
}
);
console.log("동아리 가입신청 완료", response.data);
alert("동아리 가입신청이 완료되었습니다!");
closeModal();
alert("동아리 가입신청이 완료되었습니다!");
} catch (err) {
console.error("에러 발생:", err);
}
};

const onChangeInput = (e) => {
const { name, value } = e.target;
setInput((prevInput) => ({
Expand Down
31 changes: 19 additions & 12 deletions src/pages/Promotion/Promotion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CountyOptions } from "../../components/FilterBar";
import ApplyStatus from "./ApplyStatus";

export const PromotionContext = createContext();
export const RefreshContext = createContext();

const Promotion = () => {
const [selectedTab, setSelectedTab] = useState("oncampus");
Expand Down Expand Up @@ -82,24 +83,30 @@ const Promotion = () => {
}
};

const [refresh, setRefresh] = useState(false);
const changeRefresh = () => {
setRefresh(!refresh);
};
useEffect(() => {
getAllPromotion();
}, []);
}, [refresh]);

return (
<>
<PromotionContext.Provider value={reset ? promotionData : filteredData}>
<FixedContainer>
<PromotionHeader setSelectedTab={setSelectedTab} />
<FilterBar
selected={selected}
setSelected={setSelected}
handleChange={handleChange}
/>
</FixedContainer>
<ContentContainer>
<Outlet />
</ContentContainer>
<RefreshContext.Provider value={changeRefresh}>
<FixedContainer>
<PromotionHeader setSelectedTab={setSelectedTab} />
<FilterBar
selected={selected}
setSelected={setSelected}
handleChange={handleChange}
/>
</FixedContainer>
<ContentContainer>
<Outlet />
</ContentContainer>
</RefreshContext.Provider>
</PromotionContext.Provider>
</>
);
Expand Down
5 changes: 4 additions & 1 deletion src/pages/Promotion/PromotionWrite.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useContext, useEffect, useState } from "react";
import arrowdown_icon from "../../assets/icons/group/arrow_down.svg";

import {
Expand All @@ -13,6 +13,7 @@ import {
import styled from "styled-components";
import { getUserClubs } from "../../apis/api/user";
import axios from "axios";
import { RefreshContext } from "./Promotion";
const AddQuestionInput = styled.input`
width: 100%;
height: 46px;
Expand Down Expand Up @@ -41,6 +42,7 @@ const PromotionWrite = ({ isOpen, closeModal }) => {
questions: {},
});
const accessToken = localStorage.getItem("accessToken");
const changeRefresh = useContext(RefreshContext);
const postPromotionAdd = async () => {
try {
const response = await axios.post(
Expand All @@ -56,6 +58,7 @@ const PromotionWrite = ({ isOpen, closeModal }) => {
console.log("홍보글 추가 완료", response.data);
alert("동아리 홍보글이 등록되었습니다!");
closeModal();
changeRefresh();
} catch (err) {
console.error("에러 발생:", err);
}
Expand Down
Loading