Skip to content

Commit

Permalink
Merge pull request #115 from KUIT-Space/feat#99-chat-file
Browse files Browse the repository at this point in the history
feat: not selected space, user view modal
  • Loading branch information
Turtle-Hwan authored Aug 20, 2024
2 parents 8bf8e80 + 5b6115a commit c94a522
Showing 1 changed file with 42 additions and 21 deletions.
63 changes: 42 additions & 21 deletions src/pages/LoginPage/LoginModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,61 @@ export const LoginModal = ({ exceptionRouters }: { exceptionRouters: string[] })
const location = useLocation(); // ํ˜„์žฌ ๊ฒฝ๋กœ๋ฅผ ๊ฐ€์ ธ์˜ด

const [isModalOpen, setIsModalOpen] = useState(false);
const [isSpaceModalOpen, setIsSpaceModalOpen] = useState(false);

useEffect(() => {
if (exceptionRouters.includes(location.pathname)) {
return;
}

const token = localStorage.getItem("Authorization");
const spaceId = localStorage.getItem("spaceId");

if (!token) {
setIsModalOpen(true);
} else if (!spaceId) {
if ("/space" === location.pathname) {
return;
}
setIsSpaceModalOpen(true);
}
}, [navigate, location.pathname]);

const handleCloseModal = () => {
setIsModalOpen(false);
};
}, [navigate, location.pathname, exceptionRouters]);

return (
<StopModal
isOpen={isModalOpen}
onClose={handleCloseModal}
onConfirm={() => {
navigate("/login");
setIsModalOpen(false);
}}
title={"๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค."}
content={["๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜์‹œ๊ฒ ์–ด์š”?"]}
contentColor="#767681"
confirmButtonColor="#48FFBD"
cancelButtonText="์ทจ์†Œ"
confirmButtonText="ํ™•์ธ"
confirmButtonTextColor="#171719"
/>
); // ์กฐ๊ฑด์ด ์ถฉ์กฑ๋˜๋ฉด ์ž์‹ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋ง
<>
<StopModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
onConfirm={() => {
navigate("/login");
setIsModalOpen(false);
}}
title={"๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค."}
content={["๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜์‹œ๊ฒ ์–ด์š”?"]}
contentColor="#767681"
confirmButtonColor="#48FFBD"
cancelButtonText="์ทจ์†Œ"
confirmButtonText="ํ™•์ธ"
confirmButtonTextColor="#171719"
/>

<StopModal
isOpen={isSpaceModalOpen}
onClose={() => setIsSpaceModalOpen(false)}
onConfirm={() => {
navigate("/space");
setIsSpaceModalOpen(false);
}}
title={"Space ์„ ํƒ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค."}
content={["Space ์„ ํƒ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜์‹œ๊ฒ ์–ด์š”?"]}
contentColor="#767681"
confirmButtonColor="#48FFBD"
cancelButtonText="์ทจ์†Œ"
confirmButtonText="ํ™•์ธ"
confirmButtonTextColor="#171719"
/>
</>
);
};

export default LoginModal;

0 comments on commit c94a522

Please sign in to comment.