Skip to content

Commit

Permalink
Merge pull request #110 from KUSITMS-29th-TEAM-B/feat/#101
Browse files Browse the repository at this point in the history
feat: 자기소개서 조회
  • Loading branch information
hyo-4 authored May 19, 2024
2 parents 7996afb + 456207e commit 0115d79
Show file tree
Hide file tree
Showing 7 changed files with 663 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
"@types/d3": "^7.4.3",
"@types/react-datepicker": "^6.2.0",
"eslint": "^8.57.0"
}
},
"proxy": "https://isprogrammingfun.site"
}
4 changes: 4 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ProfilePage from "./pages/ProfilePage";
import ProfileEditPage from "./pages/ProfileEditPage";
import PrivateRoute from "./services/router/PrivateRoute";
import InfoPage from "./pages/InfoPage";
import JDWritePage from "./pages/JDWritePage";

const App: React.FC = () => {
return (
Expand All @@ -32,6 +33,9 @@ const App: React.FC = () => {
<Route element={<PrivateRoute />} path="/">
<Route path="/jd/edit/:jdId" element={<JDEditPage />} />
</Route>
<Route element={<PrivateRoute />} path="/">
<Route path="/jd/:jdId" element={<JDWritePage />} />
</Route>
<Route element={<PrivateRoute />} path="/">
<Route path="/jd/post" element={<JDPlusPage />} />
</Route>
Expand Down
10 changes: 9 additions & 1 deletion src/pages/JDDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ const JDDetailPage: React.FC = () => {
}
};

const handleNavigate = () => {
if (firstTime) {
nav(`/jd/${jdId}`);
} else {
nav(`/jd/edit/${jdId}`);
}
};

useEffect(() => {
window.scrollTo({
top: 0,
Expand Down Expand Up @@ -112,7 +120,7 @@ const JDDetailPage: React.FC = () => {
<img src={arrowLeft} alt="arrowicon" onClick={() => nav(-1)} />
공고 상세
</Title>
<TopButton onClick={() => nav(`/jd/edit/${jdId}`)}>
<TopButton onClick={handleNavigate}>
<TopButtonText>
{firstTime ? "자기소개서 작성" : "자기소개서 확인"}
<img src={arrowIcon} alt="icon" />
Expand Down
21 changes: 20 additions & 1 deletion src/pages/JDEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import DiscardModal from "../components/JD/DiscardModal";
import JDContainer from "../components/JD/JDContainer";
import ExperienceBox from "../components/JD/ExpContainer";
import { ApplyAPI } from "../types/type";
import { applypost } from "../services/jd";
import { applyget, applypost } from "../services/jd";
import { getCookie } from "../services/cookie";

const JDEditPage: React.FC = () => {
Expand All @@ -37,13 +37,17 @@ const JDEditPage: React.FC = () => {
const nav = useNavigate();
const jdId: string = useParams().jdId!; //공고 id
const user = getCookie("user"); //토큰 받아오기용
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
window.scrollTo({
top: 0,
behavior: "auto",
});
// console.log("token", user.token);
if (jdId) {
getApplyData(jdId, user.token);
}
}, []);

//모든 질문이 다 채워졌는지 검사
Expand Down Expand Up @@ -130,6 +134,21 @@ const JDEditPage: React.FC = () => {
}
};

const getApplyData = async (jdId: string, token: string) => {
try {
const response = await applyget(jdId, token);
const mappedData = response.data.applyContentList.map((apply: any) => ({
question: apply.question,
answer: apply.answer,
}));
setApplyData(mappedData);
} catch (error) {
console.error(error);
alert(JSON.stringify(error));
}
setIsLoading(false);
};

//자기소개서 post api 요청
const handleApplyPost = async (
applyData: ApplyAPI[],
Expand Down
Loading

0 comments on commit 0115d79

Please sign in to comment.