Skip to content

Commit

Permalink
Merge pull request #1048 from 42organization/GGFE-261-출석모달버그
Browse files Browse the repository at this point in the history
[GGFE-261] 출석모달버그
  • Loading branch information
yoouyeon authored Sep 20, 2023
2 parents e710180 + c114b3b commit 35b0d52
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 33 deletions.
13 changes: 0 additions & 13 deletions components/modal/ModalProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { useEffect } from 'react';
import { useQueryClient } from 'react-query';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { reloadMatchState } from 'utils/recoil/match';
import { modalState, modalTypeState } from 'utils/recoil/modal';
import AdminModal from 'components/modal/modalType/AdminModal';
import NormalModal from 'components/modal/modalType/NormalModal';
import StoreModal from 'components/modal/modalType/StoreModal';
import { useUser } from 'hooks/Layout/useUser';
import styles from 'styles/modal/Modal.module.scss';

export default function ModalProvider() {
const [{ modalName }, setModal] = useRecoilState(modalState);
const setReloadMatch = useSetRecoilState(reloadMatchState);
const modalType = useRecoilValue(modalTypeState);
const queryClient = useQueryClient();
const user = useUser();

useEffect(() => {
setModalOutsideScroll();
Expand All @@ -28,15 +24,6 @@ export default function ModalProvider() {
if (e.target instanceof HTMLDivElement && e.target.id === 'modalOutside') {
if (modalName === 'MATCH-CANCEL') {
setReloadMatch(true);
} else if (
modalName === 'EVENT-ANNOUNCEMENT' &&
user &&
user.isAttended === false
) {
setModal({ modalName: 'EVENT-WELCOME' });
} else if (modalName === 'COIN-ANIMATION') {
queryClient.invalidateQueries('user');
setModal({ modalName: null });
} else {
setModal({ modalName: null });
}
Expand Down
13 changes: 7 additions & 6 deletions components/modal/event/AnnouncementModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function AnnouncementModal({
AnnouncementModalProps) {
const setModal = useSetRecoilState(modalState);
const [neverSeeAgain, setNeverSeeAgain] = useState<boolean>(false);
const user = useUser();
// const user = useUser();

const onCheck = () => {
setNeverSeeAgain((prev) => !prev);
Expand All @@ -42,11 +42,12 @@ AnnouncementModalProps) {
} else {
localStorage.removeItem('announcementTime');
}
if (user && user.isAttended === false) {
setModal({ modalName: 'EVENT-WELCOME' });
} else {
setModal({ modalName: null });
}
// if (user && user.isAttended === false) {
// setModal({ modalName: 'EVENT-WELCOME' });
// } else {
// setModal({ modalName: null });
// }
setModal({ modalName: null });
};

useEffect(() => {
Expand Down
10 changes: 5 additions & 5 deletions components/modal/event/WelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default function WelcomeModal() {
try {
setButtonState(true);
setIsLoading(true);
// const updatedcoin = await postCoinHandler();
const res = await instance.post(`/pingpong/users/attendance`);
const updatedcoin = res.data;
if (!updatedcoin) return;
Expand All @@ -66,12 +65,13 @@ export default function WelcomeModal() {
} catch (error: any) {
if (error.response.status === 409) {
alert('출석은 하루에 한 번만 가능합니다.');
setModal({ modalName: null });
queryClient.invalidateQueries('user');
return;
// queryClient.refetchQueries('user');
queryClient.refetchQueries('user').then(() => {
setModal({ modalName: null });
});
} else {
queryClient.invalidateQueries('user');
setError('SM01');
queryClient.refetchQueries('user');
}
} finally {
setIsLoading(false);
Expand Down
2 changes: 1 addition & 1 deletion components/modal/statChange/CoinChangeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function CoinChangeModal(coin: CoinResult) {

useEffect(() => {
return () => {
queryClient.invalidateQueries('user');
queryClient.refetchQueries('user');
};
}, []);

Expand Down
18 changes: 10 additions & 8 deletions hooks/Layout/useAnnouncementCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useAnnouncementCheck = (presentPath: string) => {
setModal({
modalName: 'EVENT-ANNOUNCEMENT',
announcement: data,
isAttended: user?.isAttended,
// isAttended: user?.isAttended,
});
},
err: 'RJ01',
Expand All @@ -41,16 +41,18 @@ const useAnnouncementCheck = (presentPath: string) => {
}
};

const attendedHandler = () => {
if (user && user.isAttended === false && presentPath === '/') {
setModal({ modalName: 'EVENT-WELCOME' });
}
};
// const attendedHandler = () => {
// if (user && user.isAttended === false && presentPath === '/') {
// setModal({ modalName: 'EVENT-WELCOME' });
// }
// };

useEffect(() => {
if (!user) return;
announcementHandler();
attendedHandler();
// attendedHandler();
if (user && user.isAttended === false && presentPath === '/') {
setModal({ modalName: 'EVENT-WELCOME' });
} else announcementHandler();
}, [user, presentPath]);
};

Expand Down

0 comments on commit 35b0d52

Please sign in to comment.