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

로그아웃 모달 추가 #159

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 24 additions & 5 deletions apps/company/src/components/modal/editModal/editModal.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
// EditModal.tsx
"use client";

import React from "react";
import React, { useState, useEffect } from "react";
import * as S from "./style";
import { Text } from "@jobis/ui";
import { themes } from "@jobis/design-token";
import Link from "next/link";
import { useMyCompanyInfo } from "@/hooks/apis/useCompanyApi";
import { useEffect } from "react";
import Modal from "..";
import LogoutModal from "../logout/logoutModal";

interface PropsType {
closeModal: () => void;
}

const EditModal: React.FC<PropsType> = () => {
const { data: myCompanyInfo } = useMyCompanyInfo();
const [isLogoutModalOpen, setIsLogoutModalOpen] = useState(false);

useEffect(() => {
document.body.style.overflow = "auto";
return () => {
document.body.style.overflow = "auto";
};
}, []);

const handleLogoutClick = () => {
setIsLogoutModalOpen(true);
};

const handleCloseModal = () => {
setIsLogoutModalOpen(false);
};

return (
<S.Container>
<Link
Expand All @@ -33,9 +45,16 @@ const EditModal: React.FC<PropsType> = () => {
</Text>
</S.Box>
</Link>
<Text fontSize="caption" color={themes.Color.grayScale[60]}>
로그아웃
</Text>
<S.Box onClick={handleLogoutClick}>
<Text fontSize="caption" color={themes.Color.grayScale[60]}>
로그아웃
</Text>
</S.Box>
{isLogoutModalOpen && (
<Modal width={379} onClose={handleCloseModal}>
<LogoutModal />
</Modal>
)}
</S.Container>
);
};
Expand Down
5 changes: 5 additions & 0 deletions apps/company/src/components/modal/editModal/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const Container = styled.div`
box-shadow: 0 4px 20px 0 rgb(112 144 176 / 12%);
`;

export const Wrapper = styled.div`
width: 100%;
height: 100%;
`;

export const Box = styled.div`
display: flex;
justify-content: center;
Expand Down
55 changes: 55 additions & 0 deletions apps/company/src/components/modal/logout/logoutModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use client";

import React from "react";
import * as S from "./style";
import { Text, Button } from "@jobis/ui";
import { themes } from "@jobis/design-token";
import { useModal } from "@/hooks/useModal";
import { Cookies } from "react-cookie";

const LogoutModal = () => {
const { closeModal } = useModal();
const cookies = new Cookies();

const handleLogout = () => {
cookies.remove("access_token");
cookies.remove("refresh_token");

window.location.href = "/";

closeModal();
};
return (
<S.Container>
<S.TextWrapper>
<Text fontSize="body1" fontWeight="bold">
로그아웃
</Text>
<Text
fontSize="body2"
fontWeight="regular"
color={themes.Color.grayScale[60]}
>
로그아웃 시 다음 접속 때 로그인 해야합니다.
</Text>
</S.TextWrapper>
<S.ButtonWrapper>
<Button
onClick={closeModal}
style={{ width: "112px", height: "48px" }}
variant="outline"
>
취소
</Button>
<Button
onClick={handleLogout}
style={{ width: "112px", height: "48px" }}
>
확인
</Button>
</S.ButtonWrapper>
</S.Container>
);
};

export default LogoutModal;
26 changes: 26 additions & 0 deletions apps/company/src/components/modal/logout/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import styled from "styled-components";

export const Container = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 203px;
padding: 24px;
border-radius: 8px;

background-color: white;
`;

export const TextWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 8px;
`;

export const ButtonWrapper = styled.div`
display: flex;
margin-top: 32px;
gap: 8px;
`;
1 change: 1 addition & 0 deletions apps/company/src/store/modalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ModalType =
| "EDIT_RECRUIT_AREA"
| "ADD_RECRUIT_AREA"
| "EDIT_COMPANY_INFO"
| "LOGOUT_AREA"
| "";

export interface IModalState {
Expand Down