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

알람 버튼 클릭시 버블링을 막고 알럿이 뜨도록 한다 #132

Merged
merged 6 commits into from
Nov 19, 2021
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
9 changes: 6 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useRef } from 'react';
import { Route, Switch, useLocation } from 'react-router-dom';
import { Route, Switch, useLocation, Redirect } from 'react-router-dom';
import styles from '@src/App.module.scss';
import LandingPage from '@src/pages/LandingPage';
import LoginPage from '@src/pages/LoginPage';
import JoinPage from '@src/pages/JoinPage';
import IdeaPage from '@src/pages/IdeaPage';
Expand All @@ -16,6 +15,8 @@ import SideReadPage from '@src/pages/SideReadPage';
import AlertModal from '@src/components/modals/AlertModal';
import { useAppDispatch, useUiState, hideGlobalAlert } from '@src/store';

const PATH_CHECK = ['login', 'join', 'idea', 'side', 'mypage'];

const App = () => {
const { isGlobalAlertVisible, globalAlertMessage } = useUiState();
const dispatch = useAppDispatch();
Expand All @@ -38,7 +39,6 @@ const App = () => {
<Sidebar pathname={pathname} />
</div>
<div className={styles.content} ref={pageRef}>
<Route exact path="/" component={LandingPage} />
<AuthRoute
path="/login"
component={LoginPage}
Expand Down Expand Up @@ -72,6 +72,9 @@ const App = () => {
redirectPath="/login"
render={(props) => <MyPage {...props} handleToTop={handleToTop} />}
/>
{pathname && !PATH_CHECK.some((each) => pathname.includes(each)) && (
<Redirect to="/side" />
)}
</div>
{isGlobalAlertVisible && (
<AlertModal
Expand Down
8 changes: 7 additions & 1 deletion src/components/AlarmCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ const AlarmCard = ({
{postType}
</Typography>
</div>
<Close className={cn(styles.closeIconContainer)} onClick={onClose} />
<Close
className={cn(styles.closeIconContainer)}
onClick={(e) => {
e.stopPropagation();
onClose();
}}
/>
</div>
<div className={styles.alarmCardContentArea}>
<Typography
Expand Down
23 changes: 21 additions & 2 deletions src/components/AlarmCardContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import AlarmCard from '@src/components/AlarmCard';
import useModalControl from '@src/hooks/useModalControl';
import IdeaModal from '@src/components/modals/IdeaModal';
import { Alarm } from '@src/models';
import { showGlobalAlert, useAppDispatch } from '@src/store';
import { GuideText } from '@src/constant/enums';

const AlarmCardContainer = (props: Alarm) => {
const {
isModalVisible: isIdeaVisible,
showModal: showIdea,
hideModal: hideIdea,
} = useModalControl();

const dispatch = useAppDispatch();
const history = useHistory();

const deleteAlarmMutation = useDeleteAlarm();
Expand All @@ -33,7 +35,24 @@ const AlarmCardContainer = (props: Alarm) => {
<div>
<AlarmCard
onClick={handleClick}
onClose={() => deleteAlarmMutation.mutate(props.id)}
onClose={() =>
deleteAlarmMutation.mutate(props.id, {
onSuccess: () => {
dispatch(
showGlobalAlert({
globalAlertMessage: '댓글 알림을 삭제하였습니다.',
}),
);
},
onError: () => {
dispatch(
showGlobalAlert({
globalAlertMessage: GuideText.ERROR,
}),
);
},
})
}
{...props}
/>
{isIdeaVisible && props.id && (
Expand Down
6 changes: 0 additions & 6 deletions src/pages/LandingPage/LandingPage.module.scss

This file was deleted.

41 changes: 0 additions & 41 deletions src/pages/LandingPage/index.tsx

This file was deleted.

8 changes: 1 addition & 7 deletions src/pages/SidePage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import cn from 'classnames';

import styles from './SidePage.module.scss';
Expand All @@ -23,18 +23,12 @@ import Typography from '@src/components/common/Typography';
import { setSide, useAppDispatch, useSideState } from '@src/store';
import Input, { ParentRef } from '@src/components/common/Input';
import { useAuth } from '@src/hooks/useUserQuery';
import { useLocation } from 'react-router-dom';
import { GuideText } from '@src/constant/enums';

interface SidePageProps {
handleToTop?: () => void;
}

const SidePage = ({ handleToTop }: SidePageProps) => {
const location = useLocation();

const status = useMemo(() => location.state as string, [location]);

// 첫 화면 렌더링시 애니메이션 실행 안되도록 처리함
const [init, setInit] = useState(false);
const [isFilterOpen, setIsFilterOpen] = useState(false);
Expand Down