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

feat: 자기소개서 조회 #110

Merged
merged 1 commit into from
May 19, 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: 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