Skip to content

Commit

Permalink
Merge pull request #280 from JayJayleee/bugfix/#271-realtime-alert-re…
Browse files Browse the repository at this point in the history
…factor

실시간 알림  기능 및 UI 수정했습니다.
  • Loading branch information
JayJayleee authored May 1, 2024
2 parents b85dbb7 + 862170f commit 1f1e9fa
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/asset/image/notification-answer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/asset/image/notification-question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 31 additions & 16 deletions src/asset/sass/pages/myPage/premiumPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

.banner {
display: flex;
width: 100%;
width: 700px;
margin-left: -0.5rem;
}

.banner-text {
position: absolute;
display: flex;
flex-direction: column;
padding: 40px;
padding: 45px;
line-height: 1.4;
width: 100%;
&:nth-child(0) span,
Expand All @@ -31,17 +32,21 @@
}

.pay-agreement {
margin-top: 280px;
margin-top: 20rem;
display: flex;
width: 540px;
align-items: center;
justify-content: space-around;
justify-content: space-between;
img {
&:hover {
cursor: pointer;
}
}
}

.pay-check {
display: flex;
align-items: center;
}
.payment-button {
display: flex;
justify-content: center;
Expand All @@ -56,16 +61,18 @@

.tag {
border: 1px solid black;
padding: 5px;
width: 6.5rem;
padding: 0.3rem 2rem;
width: fit-content;
border-radius: 5px;
font-size: 12px;
font-size: 0.9rem;
margin-top: 4px;
font-family: Pretendard-Light;
letter-spacing: -1px;
}

.premium-container {
display: flex;
margin-top: 28px;
margin-top: 2px;
width: 100%;
flex-direction: column;
font-size: 15px;
Expand All @@ -79,6 +86,7 @@
flex-direction: column;
align-self: start;
color: #424242;
margin-top: 3rem;
}

.detail {
Expand Down Expand Up @@ -161,9 +169,9 @@
.unlimited-pass {
color: #000;
letter-spacing: -1.36px;
font:
600 17px Pretendard,
sans-serif;
font-family: Pretendard-ExtraBold;
font-size: 2.5rem;
letter-spacing: -1px;
}

.button-group {
Expand All @@ -174,6 +182,7 @@
color: #000;
font-weight: 300;
white-space: nowrap;
margin-top: 1rem;
}

.premium-info-wrapper {
Expand All @@ -195,26 +204,32 @@
.price-info {
display: flex;
justify-content: space-between;
gap: 20px;
gap: 43rem;
}

.label {
color: #909090;
@include pretendard-font;
font-size: 12px;
font-size: 1.5rem;
margin-bottom: 1rem;
}

.value {
color: #595656;
@include pretendard-font;
font-size: 12px;
font-size: 1.5rem;
width: max-content;
}

.duration-info {
@include flex-margin-8;
justify-content: space-evenly;
justify-content: space-between;
}

.icon-wrapper {
@include flex-margin-8;
}

.premium-arrow {
margin-left: 35rem;
}
8 changes: 6 additions & 2 deletions src/asset/sass/pages/notificationPage/notificationList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
margin-bottom: 10px;
font-family: Pretendard-SemiBold;
font-size: 2rem;
width: 22rem;
}

.notification-time {
Expand All @@ -40,7 +41,7 @@

.title-time {
display: flex;
margin-left: -40%;
margin-left: -20rem;
flex-direction: column;
letter-spacing: -1px;
}
Expand All @@ -50,7 +51,10 @@
font-family: pretendard-Light;
color: #333333;
font-size: 1.8rem;
// margin-right: 5%;
width: 5rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/global/utils/eventApiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export const initializeSSE = (queryClient) => {
}
: {}),
},
heartbeatTimeout: 3600000,
heartbeatTimeout: 3660000,
});

console.log(sse);
sse.addEventListener('connect', (event) => {
queryClient.invalidateQueries(['notifications']);

let data;
try {
data = JSON.parse(event.data);
Expand Down
6 changes: 4 additions & 2 deletions src/components/pages/notificationPage/notificationList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ function NotificationList({
fetchAPI('/api/notification', 'PATCH', [{ notificationId: index }])
.then(() => {
queryClient.invalidateQueries(['notifications']);
if (type !== 'DAILY' && uri) {
if (type === 'INQUIRY') {
navigate(uri, { state: { list: 'list' } });
} else if (type !== 'DAILY' && uri) {
navigate(uri);
} else {
console.log('붕어빵 획득 알림은 이동이 불가능합니다.');
queryClient.invalidateQueries(['notifications']);
}
})
.catch((error) => {
Expand Down
14 changes: 8 additions & 6 deletions src/components/pages/notificationPage/notificationPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { StyledPage, StyledHeader } from '../../../styledComponent';
import TitleHeader from '../../ui/header/titleHeader.tsx';
Expand All @@ -10,7 +10,7 @@ import { useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
import { useDispatch } from 'react-redux';
import { alertCount } from '../../../store/actions/alertActions.js';
import { showErrorToast } from '../../ui/toast/toast.tsx';

// import { initializeSSE } from '../../global/utils/eventApiUtils.js';
function fetchNotifications({ pageParam = '' }) {
return fetchAPI(`/api/notification${pageParam}`, 'GET');
}
Expand All @@ -37,13 +37,14 @@ function NotificationPage() {
return lastId ? `?lastId=${lastId}` : undefined;
},
});

const [noReadElements, setNoReadElements] = useState(0);
useEffect(() => {
if (data?.pages) {
const noReadElements = data.pages.reduce(
(total, page) => total + (page.data.noReadElements || 0),
0,
);
setNoReadElements(noReadElements);
dispatch(alertCount(noReadElements));
}
}, [data, dispatch]);
Expand Down Expand Up @@ -87,12 +88,13 @@ function NotificationPage() {
<StyledPage className="main-page-container">
<StyledHeader>
<TitleHeader pageTitle="알림" handleGoBack={handleGoBack} />
{/* <button onClick={() => initializeSSE(queryClient)}>
initializeSSE
</button> */}
<div className="notification-controls">
<div className="no-read">
읽지 않은 알림{' '}
<div className="no-read-count">
{data?.data?.noReadElements || 0}{' '}
</div>
<div className="no-read-count">{noReadElements || 0} </div>
</div>
<div className="all-read-btn" onClick={checkALLNotification}>
모두 읽음
Expand Down
52 changes: 29 additions & 23 deletions src/components/pages/premiumPage/premiumPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ import React, { useState } from 'react';

import styled from 'styled-components';
import '../../../asset/sass/pages/myPage/premiumPage.scss';
import VectorIcon from '../../../asset/image/vector.svg';
import CheckIcon from '../../../asset/image/check.svg';
import CheckIconRectangle from '../../../asset/image/check_orange.svg';
import TabBar from '../../ui/tabBar/tabBar';
import BannerImage from '../../ui/banner/bannerImage';
import { useNavigate } from 'react-router-dom';
import { useNavigate, Link } from 'react-router-dom';
import { SectionProps } from '../../../types';
import { StyledPage, StyledHeader } from '../../../styledComponent';
import TitleHeader from '../../ui/header/titleHeader';

const StatusBar = styled.div`
display: flex;
width: 505px;
justify-content: space-between;
border-bottom: 1px solid gray;
border-bottom: 5px solid gray;
margin-top: 10%;
margin-left: 15%;
font-family: pretendard-semibold;
`;

Expand All @@ -27,11 +28,18 @@ const StatusTab = styled.div<{ $current: boolean }>`
padding: 10px 0;
cursor: pointer;
color: gray;
border-bottom: 2px solid transparent;
border-bottom: 5px solid transparent;
margin-bottom: -5px;
transition:
border-bottom 0.3s ease-in-out,
color 0.3s ease-in-out;
${($current) => $current && 'color: black; border-bottom: 3px solid black;'}
${({ $current }) =>
$current &&
`
color: black;
border-bottom: 5px solid black;
`}
`;

const PremiumPage = () => {
Expand All @@ -49,11 +57,10 @@ const PremiumPage = () => {
navigate('/');
};

const URL =
'https://muddy-snowflake-048.notion.site/3065eafff7ec49acb4d45ca4261ba1cf?pvs=4';
return (
<StyledPage
className="main-page-container"
style={{ position: 'relative' }}
>
<StyledPage className="main-page-container">
<StyledHeader>
<TitleHeader pageTitle="문의하기" handleGoBack={handleGoBack} />
<TabBar />
Expand All @@ -63,7 +70,7 @@ const PremiumPage = () => {
$current={currentSection === 'buy'}
onClick={() => setCurrentSection('buy')}
>
구매하
구매하기
</StatusTab>
<StatusTab
$current={currentSection === 'myPremium'}
Expand All @@ -79,22 +86,21 @@ const PremiumPage = () => {
<div className="premium-wrapper">
<div className="premium-company">코버플로우</div>
<div className="price">9,900원</div>
<div className="point">포인트</div>
<div className="benefit">혜택 보기</div>
</div>
<div className="using-container">
<span>사용 불가</span>
<img loading="lazy" src={VectorIcon} />
</div>

<div className="pay-agreement">
<img
src={isChecked ? CheckIconRectangle : CheckIcon}
alt="check"
onClick={handleCheckClick}
/>
<div className="pay-check">
<img
src={isChecked ? CheckIconRectangle : CheckIcon}
alt="check"
onClick={handleCheckClick}
/>

<span>결제 정보 확인 및 정보 제공 동의</span>
{/* <span className="detail">자세히</span> */}
<span>결제 정보 확인 및 정보 제공 동의</span>
</div>
<Link to={URL} className="detail">
자세히
</Link>
</div>
<button
onClick={handlePaymentClick}
Expand Down
Loading

0 comments on commit 1f1e9fa

Please sign in to comment.