-
Notifications
You must be signed in to change notification settings - Fork 3
[Feat/#20] 사용자 / 관리자 알림 페이지 퍼블리싱 #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9fd1d1e
feat: 리스트 구현을 위한 어드민 알림 뷰 constant 세팅
sinji2102 2ef734e
feat: NotificationItem 배경색, 폰트 색, 아이콘 제외 퍼블리싱
sinji2102 69c9757
design: 세팅에 없는 색 추가 및 svg 경로 수정
sinji2102 ef43f12
feat: 명세서에 맞춰 타입 수정
sinji2102 6b44332
feat: 알림 타입 const, 시간 계산 함수 추가
sinji2102 9310a13
design: 디자인 시스템 네이밍 밀린 거 수정
sinji2102 2172329
feat: 알림 상태별 색상 지정
sinji2102 042a73e
feat: 유저 알림 퍼블리싱 및 타입 오류 해결
sinji2102 d8fd4b0
rename: 컨벤션에 맞도록 NotificationItem 컴포넌트 경로 수정
sinji2102 9983543
Merge branch 'develop' of https://github.com/billilge/frontend into f…
sinji2102 3e65c7e
feat: 알림 페이지 헤더 적용 및 헤더 높이 수정
sinji2102 1c66fe9
fix: svg 오류 해결
sinji2102 dc76da6
comment: 주석 제거
sinji2102 d00f1bf
style: const 띄어쓰기 오타 수정
sinji2102 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| @tailwind utilities; | ||
|
|
||
| :root { | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| :root { | ||
| --background: #0a0a0a; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import MobileLayout from '@/components/mobile/layout'; | ||
| import NotificationItem from '@/components/mobile/NotificationItem'; | ||
| import Header from '@/components/mobile/Header'; | ||
| import { elapsedTime } from '@/utils/elapsedTime'; | ||
| import { NotificationProps } from '@/types/notificationType'; | ||
|
|
||
| const NotificationDetail: AdminNotificationType[] = [ | ||
| { | ||
| notificationId: 0, | ||
| message: '메시지 1입니다', | ||
| link: '/desktop/login', | ||
| isRead: false, | ||
| status: 'ADMIN_RENTAL_APPLY', | ||
| createdAt: '2025-02-16T08:44:45.476Z', | ||
| }, | ||
| { | ||
| notificationId: 1, | ||
| message: '메시지 2입니다', | ||
| link: '/mobile', | ||
| isRead: true, | ||
| status: 'ADMIN_RENTAL_CANCEL', | ||
| createdAt: '2025-02-16T06:44:45.476Z', | ||
| }, | ||
| { | ||
| notificationId: 2, | ||
| message: | ||
| '메시지 두 줄 테스트입니다 두 줄 테스트 두 줄 테스트 두 줄 테스트 두 줄 테스트', | ||
| link: '/mobile', | ||
| isRead: true, | ||
| status: 'ADMIN_RETURN_APPLY', | ||
| createdAt: '2025-02-12T05:44:45.476Z', | ||
| }, | ||
| ]; | ||
|
|
||
| type AdminNotificationType = NotificationProps; | ||
|
|
||
| export default function Notification() { | ||
| return ( | ||
| <MobileLayout> | ||
| <Header title="관리자 알림" /> | ||
| {NotificationDetail.map((item) => ( | ||
| <NotificationItem | ||
| key={item.notificationId} | ||
| message={item.message} | ||
| link={item.link} | ||
| isRead={item.isRead} | ||
| status={item.status} | ||
| createdAt={elapsedTime(item.createdAt)} | ||
| /> | ||
| ))} | ||
| </MobileLayout> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import MobileLayout from '@/components/mobile/layout'; | ||
| import NotificationItem from '@/components/mobile/NotificationItem'; | ||
| import Header from '@/components/mobile/Header'; | ||
| import { elapsedTime } from '@/utils/elapsedTime'; | ||
| import { NotificationProps } from '@/types/notificationType'; | ||
|
|
||
| const NotificationDetail: UserNotificationType[] = [ | ||
| { | ||
| notificationId: 0, | ||
| message: '메시지 1입니다', | ||
| link: '/desktop/login', | ||
| isRead: false, | ||
| status: 'USER_RENTAL_APPLY', | ||
| createdAt: '2025-02-16T08:44:45.476Z', | ||
| }, | ||
| { | ||
| notificationId: 1, | ||
| message: '메시지 2입니다', | ||
| link: '/mobile', | ||
| isRead: true, | ||
| status: 'USER_RENTAL_REJECTED', | ||
| createdAt: '2025-02-16T06:44:45.476Z', | ||
| }, | ||
| { | ||
| notificationId: 2, | ||
| message: | ||
| '메시지 두 줄 테스트입니다 두 줄 테스트 두 줄 테스트 두 줄 테스트 두 줄 테스트', | ||
| link: '/mobile', | ||
| isRead: true, | ||
| status: 'USER_RETURN_APPLY', | ||
| createdAt: '2025-02-12T05:44:45.476Z', | ||
| }, | ||
| ]; | ||
|
|
||
| type UserNotificationType = NotificationProps; | ||
|
|
||
| export default function Notification() { | ||
| return ( | ||
| <MobileLayout> | ||
| <Header title="알림" /> | ||
| {NotificationDetail.map((item) => ( | ||
| <NotificationItem | ||
| key={item.notificationId} | ||
| message={item.message} | ||
| link={item.link} | ||
| isRead={item.isRead} | ||
| status={item.status} | ||
| createdAt={elapsedTime(item.createdAt)} | ||
| /> | ||
| ))} | ||
| </MobileLayout> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| 'use client'; | ||
|
|
||
| import Link from 'next/link'; | ||
| import { cn } from '@/lib/utils'; | ||
| import { | ||
| AdminNotificationText, | ||
| AdminNotificationTypes, | ||
| UserNotificationText, | ||
| } from '@/constants/notificationStatus'; | ||
| import { NotificationProps } from '@/types/notificationType'; | ||
| import IconBell from 'public/assets/icon-bell.svg'; | ||
|
|
||
| export default function NotificationItem({ | ||
| message, | ||
| link, | ||
| isRead, | ||
| status, | ||
| createdAt, | ||
| }: NotificationProps) { | ||
| const isAdminStatus = ( | ||
| notificationStatus: string, | ||
| ): notificationStatus is AdminNotificationTypes => | ||
| notificationStatus.startsWith('ADMIN'); | ||
|
|
||
| return ( | ||
| <Link className="w-full" href={link}> | ||
| <section | ||
| className={cn( | ||
| 'flex w-full gap-2.5 p-5', | ||
| isRead ? '' : 'bg-main-tertiary', | ||
| )} | ||
| > | ||
| <div className="flex h-4 w-4"> | ||
| <IconBell /> | ||
| </div> | ||
|
|
||
| <section className="flex w-full flex-col items-start gap-2.5 text-sm font-medium"> | ||
| <section className="flex w-full justify-between text-xs"> | ||
| <div | ||
| className={cn( | ||
| 'font-medium', | ||
| /REJECTED|CANCEL/.test(status) | ||
| ? 'text-return-red' | ||
| : 'text-return-blue', | ||
| )} | ||
| > | ||
| {isAdminStatus(status) | ||
| ? AdminNotificationText[status] | ||
| : UserNotificationText[status]} | ||
| </div> | ||
| <div className="font-medium text-gray-secondary">{createdAt}</div> | ||
| </section> | ||
| {message} | ||
| </section> | ||
| </section> | ||
| </Link> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| export const ADMIN_NOTIFICATION_STATUS = { | ||
| ADMIN_RENTAL_APPLY: 'ADMIN_RENTAL_APPLY', | ||
| ADMIN_RENTAL_CANCEL: 'ADMIN_RENTAL_CANCEL', | ||
| ADMIN_RETURN_APPLY: 'ADMIN_RETURN_APPLY', | ||
| ADMIN_RETURN_CANCEL: 'ADMIN_RETURN_CANCEL', | ||
| } as const; | ||
|
|
||
| export const USER_NOTIFICATION_STATUS = { | ||
| USER_RENTAL_APPLY: 'USER_RENTAL_APPLY', | ||
| USER_RENTAL_APPROVED: 'USER_RENTAL_APPROVED', | ||
| USER_RENTAL_REJECTED: 'USER_RENTAL_REJECTED', | ||
| USER_RETURN_APPLY: 'USER_RETURN_APPLY', | ||
| USER_RETURN_COMPLETED: 'USER_RETURN_COMPLETED', | ||
| } as const; | ||
|
|
||
| export type AdminNotificationStatus = | ||
| (typeof ADMIN_NOTIFICATION_STATUS)[keyof typeof ADMIN_NOTIFICATION_STATUS]; | ||
|
|
||
| export type UserNotificationStatus = | ||
| (typeof USER_NOTIFICATION_STATUS)[keyof typeof USER_NOTIFICATION_STATUS]; | ||
|
|
||
| export const AdminNotificationText: Record<AdminNotificationStatus, string> = { | ||
| [ADMIN_NOTIFICATION_STATUS.ADMIN_RENTAL_APPLY]: '대여 신청', | ||
| [ADMIN_NOTIFICATION_STATUS.ADMIN_RENTAL_CANCEL]: '대여 취소', | ||
| [ADMIN_NOTIFICATION_STATUS.ADMIN_RETURN_APPLY]: '반납 신청', | ||
| [ADMIN_NOTIFICATION_STATUS.ADMIN_RETURN_CANCEL]: '반납 취소', | ||
| } as const; | ||
|
|
||
| export const UserNotificationText: Record<UserNotificationStatus, string> = { | ||
| [USER_NOTIFICATION_STATUS.USER_RENTAL_APPLY]: '대여 신청', | ||
| [USER_NOTIFICATION_STATUS.USER_RENTAL_APPROVED]: '대여 승인', | ||
| [USER_NOTIFICATION_STATUS.USER_RENTAL_REJECTED]: '대여 반려', | ||
| [USER_NOTIFICATION_STATUS.USER_RETURN_APPLY]: '반납 신청', | ||
| [USER_NOTIFICATION_STATUS.USER_RETURN_COMPLETED]: '반납 완료', | ||
| } as const; | ||
|
|
||
| export type AdminNotificationTypes = keyof typeof AdminNotificationText; | ||
| export type UserNotificationTypes = keyof typeof UserNotificationText; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { | ||
| AdminNotificationStatus, | ||
| UserNotificationStatus, | ||
| } from '@/constants/notificationStatus'; | ||
|
|
||
| export interface NotificationProps { | ||
| notificationId?: number; | ||
| message: string; | ||
| link: string; | ||
| isRead: boolean; | ||
| status: AdminNotificationStatus | UserNotificationStatus; | ||
| createdAt: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| export const elapsedTime = (date: string): string => { | ||
| const start = new Date(date); | ||
| const end = new Date(); | ||
|
|
||
| const seconds = Math.floor((end.getTime() - start.getTime()) / 1000); | ||
| if (seconds < 60) return '방금 전'; | ||
|
|
||
| const minutes = seconds / 60; | ||
| if (minutes < 60) return `${Math.floor(minutes)}분 전`; | ||
|
|
||
| const hours = minutes / 60; | ||
| if (hours < 24) return `${Math.floor(hours)}시간 전`; | ||
|
|
||
| const days = hours / 24; | ||
| if (days < 7) return `${Math.floor(days)}일 전`; | ||
|
|
||
| return start.toLocaleDateString(); // 날짜를 'yyyy-MM-dd' 형식으로 반환 | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이미 AdminNotificationStatus 타입이 AdminNotificationText의 키값과 동일해서 아래와 같이 적어도 되지 않을까용? (user도!)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
허거덩 가독성 측면에서는 이렇게 수정하는 게 더 좋을 수도 있겠네요!!
다만 제가 걱정하는 부분은 수민 오빠가 물론 잘 처리해 주었겠지만... 만약 새로운 상태가 추가된다면
방식으로 처리한다면 존재하지 않는 키가 타입으로 포함될 위험이 있다고 생각했어요! 때문에 keyof typeof를 사용해서 실제로 존재하는 키만 정의하고 혹여나 추가되거나 삭제될 때 자동으로 타입을 맞췄으면... 해서 저렇게 정의했습니당!
그리구 AdminNotificationText는 텍스트 매핑에 사용되는 키 값들의 타입이구 AdminNotificationStatus는 알림의 상태값 자체라서 지금대로 유지하는 게 개인적으로 더 명시적이라구 생각해요!
쪼금 뜨거운 감자...... 가 될 수 잇는 여지가 잇긴 하네용... 생각해보니까 굳이? 인 거 같기도 하고... 넘 어렵따 좋은 의견 있으면 남겨주세요!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하 그렇군용😮
저는 상태가 정해져있고, AdminNotificationStatus 타입을 기반으로 AdminNotificationText가 만들어 졌기 때문에 keyof typeof 연산을 추가로 하지 않아도 되지 않을까하는 생각이었답니다 히히
근데 새로운 상태가 추가 될 수 있고 그에 따른 위험이 생길 수 있다는 점을 생각하면 기존의 코드대로 진행하는 것이 좋을 거 같습니다!!
신지 완전 야무진 머쨍이 개발자😎👍