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(#246): 신고하기 #264

Merged
merged 3 commits into from
Apr 2, 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
21 changes: 21 additions & 0 deletions src/apis/report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { AxiosResponse } from 'axios';
import instance from './axiosInstance';
import { CreateReportRequestType } from '@/types/chat';

const REPORT = {
path: `/users`,

/** 유저 신고하기 api [post] */
async createUserReport(content: CreateReportRequestType): Promise<any> {
const result: AxiosResponse = await instance.post(
`${REPORT.path}/${content.userId}/reports`,
{
type: content.isCheck,
report: content.report,
},
);
return result;
},
};

export default REPORT;
166 changes: 54 additions & 112 deletions src/components/common/header/MainPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from 'next/link';
import Image from 'next/image';
import useModal from '@/hooks/useModal';
import LoginModal from '@/components/organisms/auth/LoginModal';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { useRecoilState, useRecoilValue } from 'recoil';
import { LoginStateAtom } from '@/recoil/atoms/LoginStateAtom';
import { useRouter } from 'next/router';
import AUTH from '@/apis/oauth';
Expand All @@ -14,14 +14,20 @@ import { UserIdAtom } from '@/recoil/atoms/UserIdAtom';
import CHAT from '@/apis/chat';
import { ChatRoomListType } from '@/types/chat';
import { ChatRoomListAtom } from '@/recoil/atoms/ChatRoomListAtom';
import {
FlexBox,
ToolTipContainer,
Tooltip,
TooltipImage,
} from '../globalStyled/styled';
import SideBarReactive from '@/components/molecules/side-bar-elements/SideBarReactive';

const MainPageHeader = () => {
const router = useRouter();
const isLogin = useRecoilValue(LoginStateAtom);
const [isLogin, setIsLogin] = useRecoilState(LoginStateAtom);
const { isOpenModal: beforeModal, handleModal: handleBeforeModal } =
useModal();
const [provider, setProvider] = useState('');
const setLoginState = useSetRecoilState(LoginStateAtom);
const [isSide, setIsSide] = useState(false);
const [myId, setMyId] = useRecoilState(UserIdAtom);
const [chatRoomList, setChatRoomList] =
Expand All @@ -32,11 +38,15 @@ const MainPageHeader = () => {
const handleLogoutApi = async () => {
const logout = confirm('정말로 로그아웃하시겠습니까?');
if (logout) {
await AUTH.handleLogout(provider);
window.localStorage.removeItem('accessToken');
window.localStorage.removeItem('provider');
setLoginState(false);
router.push(`/`);
try {
await AUTH.handleLogout(provider);
} catch {
} finally {
window.localStorage.removeItem('accessToken');
window.localStorage.removeItem('provider');
setIsLogin(false);
router.push(`/`);
}
}
};
/** 본인 id넘버 조회 api */
Expand All @@ -54,7 +64,6 @@ const MainPageHeader = () => {
const pageSize = 100;
const res = await CHAT.getChatRoomList(page, pageSize);
setChatRoomList(res.chatRooms);
console.log(chatRoomList);
}
};

Expand All @@ -64,7 +73,6 @@ const MainPageHeader = () => {
}, [isLogin]);

// 미완성
// 다음 작업 여기서부터!!!!
/** unreadMessage 있을 때 채팅 알람 아이콘으로 변경 */
// useEffect(() => {
// setShowNotificationIcon(true);
Expand Down Expand Up @@ -126,40 +134,45 @@ const MainPageHeader = () => {
</S.NavigateBox>
<S.IconBox>
{isLogin ? (
<div>
<FlexBox type="flex">
<Link
href={{
pathname: `/chat/home`,
}}>
<Image
src={
showNotificationIcon
? 'https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/chatIcon-notice.svg'
: 'https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/ChatIcon-orange.svg'
}
alt="ChatIcon"
width="24"
height="24"
style={{ marginRight: 30 }}
/>
<ToolTipContainer hoverBox="image">
<TooltipImage
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/ChatIcon-orange.svg"
alt="ChatIcon"
width="24"
height="24"
style={{ marginRight: 30 }}
/>
<Tooltip>채팅룸</Tooltip>
</ToolTipContainer>
</Link>
<Link href={{ pathname: `/mypage` }}>
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/User-orange.svg"
alt="UserIcon"
<ToolTipContainer hoverBox="image">
<TooltipImage
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/User-orange.svg"
alt="UserIcon"
width="24"
height="24"
style={{ marginRight: 30 }}
/>
<Tooltip>마이페이지</Tooltip>
</ToolTipContainer>
</Link>
<ToolTipContainer hoverBox="image">
<TooltipImage
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/Logout.svg"
alt="LogoutIcon"
width="24"
height="24"
style={{ marginRight: 30 }}
onClick={handleLogoutApi}
/>
</Link>
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/Logout.svg"
alt="LogoutIcon"
width="24"
height="24"
onClick={handleLogoutApi}
/>
</div>
<Tooltip>로그아웃</Tooltip>
</ToolTipContainer>
</FlexBox>
) : (
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/sign-inBtn.svg"
Expand All @@ -181,83 +194,12 @@ const MainPageHeader = () => {
)}
</S.IconBox>
</S.HeaderArea>
<S.SideArea>
<S.SideBarContainer isSide={isSide}>
<S.SideBarLogoContainer>
<Link
href={{
pathname: `/`,
}}>
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/MainLogo.svg"
alt="LogoIcon"
width={162}
height={47}
/>
</Link>
<div onClick={handleSideButton}>X</div>
</S.SideBarLogoContainer>
<S.SideBarNavigateContainer>
<Link href={`/mentor?filterId=1`}>
<span>멘토 찾기</span>
</Link>
<Link href={`/mentor/board?filterId=1`}>
<span>멘토 게시글</span>
</Link>
<Link href={`/help?filterId=1`}>
<span>도와주세요</span>
</Link>
<Link href={`/support`}>
<span>고객지원</span>
</Link>
{isLogin ? (
<div>
<Link
href={{
pathname: `chat/home`,
}}>
<Image
src={
showNotificationIcon
? 'https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/chatIcon-notice.svg'
: 'https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/ChatIcon-orange.svg'
}
alt="ChatIcon"
width="24"
height="24"
style={{ marginRight: 30 }}
/>
</Link>
<Link href={{ pathname: `/mypage` }}>
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/User-orange.svg"
alt="UserIcon"
width="24"
height="24"
style={{ marginRight: 30 }}
/>
</Link>
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/Logout.svg"
alt="LogoutIcon"
width="24"
height="24"
onClick={handleLogoutApi}
/>
</div>
) : (
<Image
src="https://menbosha-s3.s3.ap-northeast-2.amazonaws.com/public/mainpage/sign-inBtn.svg"
alt="sign-in"
width={24}
height={24}
onClick={handleBeforeModal}
/>
)}
</S.SideBarNavigateContainer>
</S.SideBarContainer>
{isSide && <S.SideBarBackBg onClick={handleSideButton} />}
</S.SideArea>
<SideBarReactive
handleLogoutApi={handleLogoutApi}
handleSideButton={handleSideButton}
isSide={isSide}
provider={provider}
/>
</S.HeaderContainer>
);
};
Expand Down
17 changes: 17 additions & 0 deletions src/components/common/report-list/reportList.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum type에 대해서 저희 둘 다 알아볼 필요가 있을 것 같네요

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const reportList = [
{
id: 2,
checkName: 'isHate',
description: '증오발언 및 혐오표현 게시글',
},
{
id: 3,
checkName: 'isIllegal',
description: '불법성 게시글 및 불법 촬영물',
},
{
id: 4,
checkName: 'isAdvertise',
description: '홍보성 게시글',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ const ChatRoomListBox = () => {
setSelectedRoomId(roomId);
}
};
// useEffect(() => {
// console.log('1231241241231');
// }, [chatRoomList]);

// 마우스 우클릭 시 삭제 모달 핸들러
const handleChatRoomDelete: React.MouseEventHandler<HTMLLIElement> = (e) => {
Expand All @@ -67,7 +64,6 @@ const ChatRoomListBox = () => {
const page = 1;
const pageSize = 100;
const res = await CHAT.getChatRoomList2(page, pageSize);
console.log(res);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const ChatSpaceFooter = (myId: MyIdType) => {
createdAt,
};

console.log(chatRoomId);
console.log(selectedRoomId);
// console.log(chatRoomId);
// console.log(selectedRoomId);

setChatContents((prevContents) => [
newChatMessage,
Expand Down
Loading