Skip to content

Commit

Permalink
feat: ExperienceApi - booked
Browse files Browse the repository at this point in the history
  • Loading branch information
hyo-4 committed May 22, 2024
1 parent 10bd086 commit 5ce21c5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const App: React.FC = () => {
</Route>
{/* 공고 상세 / JDDetailPage */}
<Route element={<PrivateRoute />} path="/">
<Route path="/jd/:id" element={<JDDetailPage />} />
<Route path="/jd/:jdId" element={<JDDetailPage />} />
</Route>
{/* 공고 수정 / JDEditPage*/}
<Route element={<PrivateRoute />} path="/">
Expand Down
10 changes: 7 additions & 3 deletions src/components/JD/ExperienceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Checkbox from "../common/Checkbox";
import { getAllExperienceList } from "../../services/JD/ExperienceApi";
import { getCookie } from "../../services/cookie";
import { getAllTags } from "../../services/JD/tagApi";
import { useParams } from "react-router-dom";

type TabType = "basic" | "my";

Expand All @@ -41,6 +42,7 @@ const ExperienceList: React.FC<ExperienceListProps> = ({
React.useState<TabType>("basic");
const user = getCookie("user");
const [experienceData, setExperienceData] = useState({});
const jdId = useParams().jdId;

const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
Expand All @@ -67,13 +69,15 @@ const ExperienceList: React.FC<ExperienceListProps> = ({
);

useEffect(() => {
// getExperienceList(user.token);
if (jdId) {
getExperienceList(jdId, user.token);
}
}, []);

//모든 경험리스트 불러오기
const getExperienceList = async (token: string) => {
const getExperienceList = async (jdId: string, token: string) => {
try {
const response = await getAllExperienceList(token);
const response = await getAllExperienceList(jdId, token);
console.log(response);
} catch (error) {
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/JDDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { pointer } from "d3";
const JDDetailPage: React.FC = () => {
const [active, setActive] = useState(false);
const [activebutton, setActivebutton] = useState("");
const jdId = useParams().id;
const jdId = useParams().jdId;
const nav = useNavigate();
const [detailId, setDetailId] = useRecoilState<number | string>(detailStore);
const [jdData, setJdData] = useState<JobDescriptionAPI>({
Expand Down
50 changes: 47 additions & 3 deletions src/services/JD/ExperienceApi.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
import client from "../client";

// 경험 목록 조회
export const getAllExperienceList = async (token: string) => {
return await client.get(`/api/experiences`, {
// 북마크 된 경험 목록 조회
export const getAllExperienceList = async (jdId: string, token: string) => {
return await client.get(`/api/experiences/bookmark/${jdId}`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
};

// 경험 목록 검색 - 텍스트 검색
export const searchTextExperienceList = async (
jdId: string,
searchText: string,
token: string
) => {
return await client.get(
`/api/experiences/bookmark/${jdId}?search=${searchText}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
};

// 경험 목록 검색 - 태그필터링
export const searchTagExperienceList = async (
jdId: string,
parentTag: string,
childTag: string | null,
token: string
) => {
if (childTag) {
return await client.get(
`/api/experiences/bookmark/${jdId}?parent-tag=${parentTag}&child-tag=${childTag}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
} else {
return await client.get(
`/api/experiences/bookmark/${jdId}?parent-tag=${parentTag}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
}
};

0 comments on commit 5ce21c5

Please sign in to comment.