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(web-domains/home): 알림탭에서 알림이 비어 있을 때 EmptyView 및 notification.additionalData null case 대응 #151

Merged
merged 4 commits into from
Aug 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type AlarmEventType = {
status: 'ACTIVE' | 'INACTIVE';
additionalData: {
handWavingId: number;
};
} | null;
createdAt: number;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { colors } from '@sds/theme';
import { ReactNode } from 'react';

import { EmptyView } from '@/common/components';
import { AlarmEventType } from '@/home/common/apis/schema/Notification.schema';

interface NotificationListProps {
Expand All @@ -9,6 +10,18 @@ interface NotificationListProps {
}

export const NotificationList = ({ notificationList, renderItem }: NotificationListProps) => {
if (notificationList?.length === 0) {
return (
<div
css={{
borderTop: `1px solid ${colors.grey400}`,
}}
>
<EmptyView title="아직 알림이 없어요!" style={{ height: 'calc(100vh - 142px)' }} />;
</div>
);
}

return (
<ul
css={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ import { NotificationList } from '../components/NotificationList';
import { useAlarmListService } from '../services/useAlarmListService';

export const AlarmListContainer = () => {
const { notficationList, meetingId, handWavingResponse } = useAlarmListService();
const { notificationList, meetingId, handWavingResponse } = useAlarmListService();

const renderNotification = (notifiaciton: AlarmEventType, meetingId?: number) => {
switch (notifiaciton.type) {
const renderNotification = (notification: AlarmEventType, meetingId?: number) => {
switch (notification.type) {
case 'HAND_WAVING_REQUESTED': {
const handWavingId = notifiaciton.additionalData.handWavingId;
const handWavingId = notification.additionalData?.handWavingId;

return (
<NotificationItem.AlarmItem
alarm={notifiaciton}
alarm={notification}
footer={
<div css={{ display: 'flex', marginTop: '12px' }}>
<Button
onClick={() => handWavingResponse({ meetingId: meetingId!, handWavingId })}
onClick={() => {
if (handWavingId && meetingId) {
handWavingResponse({ meetingId, handWavingId });
}
}}
variant="primary"
leftDecor={
<Icon
Expand All @@ -44,7 +48,11 @@ export const AlarmListContainer = () => {
나도 인사 건네기
</Button>
<Button
onClick={() => ignoreHandwaving({ meetingId: meetingId!, handWavingId })}
onClick={() => {
if (handWavingId && meetingId) {
ignoreHandwaving({ meetingId, handWavingId });
}
}}
variant="sub"
leftDecor={<Icon name="close-icon" size={15} />}
>
Expand All @@ -58,7 +66,7 @@ export const AlarmListContainer = () => {

case 'QUESTION_REGISTERED':
case 'TARGET_MEMBER':
return <NotificationItem.AlarmItem alarm={notifiaciton} />;
return <NotificationItem.AlarmItem alarm={notification} />;
}
};

Expand All @@ -70,8 +78,8 @@ export const AlarmListContainer = () => {
</Txt>
</header>
<NotificationList
notificationList={notficationList}
renderItem={(notfication) => renderNotification(notfication, meetingId)}
notificationList={notificationList}
renderItem={(notification) => renderNotification(notification, meetingId)}
/>
</section>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useAlarmListService = () => {

return {
meetingId,
notficationList: data?.contents ?? [],
notificationList: data?.contents ?? [],
myMemberId: myInfo?.meetingMemberId,
ignoreHandWaving,
handWavingResponse,
Expand Down