-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from boostcampwm2023/feature/invite-member
feat: 임시 초대 페이지 생성 및 참가 API 연결
Showing
13 changed files
with
137 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const STORAGE_KEY = { | ||
MEMBER: "member", | ||
REDIRECT: "redirect", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useLocation, useNavigate, useParams } from "react-router-dom"; | ||
import { checkAccessToken } from "../../apis/utils/authAPI"; | ||
import { ROUTER_URL } from "../../constants/path"; | ||
import { useEffect } from "react"; | ||
import { STORAGE_KEY } from "../../constants/storageKey"; | ||
import { postJoinProject } from "../../apis/api/projectAPI"; | ||
|
||
const InvitePage = () => { | ||
const { projectTitle, projectId: projectUUID } = useParams(); | ||
const { pathname } = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const handleJoinButtonClick = async () => { | ||
const response = await postJoinProject(projectUUID!); | ||
|
||
switch (response.status) { | ||
case 201: | ||
alert("프로젝트에 참여되었습니다."); | ||
navigate("/projects"); | ||
break; | ||
case 200: | ||
alert("이미 참여한 프로젝트입니다."); | ||
navigate(`/projects/${response.data.projectId}`); | ||
break; | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (!checkAccessToken()) { | ||
sessionStorage.setItem(STORAGE_KEY.REDIRECT, pathname); | ||
navigate(ROUTER_URL.LOGIN, { replace: true }); | ||
} | ||
|
||
return () => { | ||
if (checkAccessToken()) { | ||
sessionStorage.removeItem(STORAGE_KEY.REDIRECT); | ||
} | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="w-[100%] min-w-[720px] h-[600px] flex justify-center items-center"> | ||
<main> | ||
<p>프로젝트{projectTitle}에 초대되었습니다.</p> | ||
<p>{projectUUID}</p> | ||
<button | ||
type="button" | ||
className="w-[100px] h-[50px] bg-middle-green rounded text-white" | ||
onClick={handleJoinButtonClick} | ||
> | ||
참여하기 | ||
</button> | ||
</main> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InvitePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters