Skip to content

Commit

Permalink
Merge branch 'main' into fix/final/merge
Browse files Browse the repository at this point in the history
  • Loading branch information
suyeon1218 authored Sep 27, 2023
2 parents a543cb0 + 5cfb257 commit 12796fa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/components/PostPreview/PostHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
PostDetailInfoContainer,
UserContainer,
NameContainer,
IdContainer
IdContainer,
PostInfoContainer
} from './PostPreview.style';
import { Link } from '@components/Link';
import { UserId } from '@components/UserText';
Expand Down
11 changes: 4 additions & 7 deletions src/pages/layout/components/AlertButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useLocation } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';

import type { User } from '@/types';

import { getNotifications } from '@apis/notice';
import useSessionStorage from '@hooks/useSessionStorage';
import { Icon } from '@components/Icon';
Expand All @@ -29,23 +28,21 @@ const AlertButton = ({ handleClickAlert }: AlertButtonProps) => {
const { token } = userSessionData;
const [readStatus] = useRecoilState(readAlert);

const { data, isError } = useQuery({
const { data } = useQuery({
queryKey: ['headerAlert', pathname],
queryFn: async () => {
const data = await getNotifications(`Bearer ${token}`);
return data;
},

onError: () => {
console.log('헤더 알림 에러!');
},
enabled: token !== '' && !token && pathname !== '/notice',
refetchInterval: 5000,
cacheTime: 0,
staleTime: 0
});

if (isError) {
console.log('헤더 알림 에러!');
}

const alertStatus = data?.filter(({ seen }) => !seen).length > 0;

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/layout/components/SearchBody.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const SearchResultContainer = styled.div`
position: absolute;
top: 50px;
left: 0;
z-index: 1;
overflow-y: scroll;
z-index: 100;
`;

export const SearchResult = styled.div``;
Expand Down
11 changes: 8 additions & 3 deletions src/pages/notice/Notice.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useSetRecoilState } from 'recoil';

import { getNotifications, putNotifications } from '@apis/notice';
import { Button } from '@components/Button';
import useSessionStorage from '@hooks/useSessionStorage';
import { User } from '@/types/User';
import { Notification } from '@/types/Notification';
import { Button } from '@components/Button';
import NoticeList from './components/NoticeList/NoticeList';
import { NoticePage, Header, ReadButtonContainer } from './Notice.style';
import { readAlert } from './states/readAlert';
import { User, Notification } from '@/types';

const Notice = () => {
const [list, setList] = useState([]);
Expand All @@ -19,11 +20,15 @@ const Notice = () => {
}
);

const setReadStatus = useSetRecoilState(readAlert);

const fetchNotifications = async () => {
const res = await getNotifications(`Bearer ${userSessionData.token}`).then(
(res) => res.filter((item: Notification) => !item.seen)
);
setReadStatus(res.length > 0);
setList(res);

return res;
};

Expand Down
1 change: 1 addition & 0 deletions src/pages/postDetail/components/PostContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { deletePost, putPost } from '@apis/posts';
import { Button } from '@components/Button';
import { Confirm } from '@components/Confirm';
import { appendFormData, purifyContent } from '@pages/posting/utils';
import PostHeader from '@components/PostPreview/PostHeader';

interface PostContentProps {
author: User;
Expand Down

0 comments on commit 12796fa

Please sign in to comment.