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

[GGFE-28] Admin - Noti #788

Merged
merged 4 commits into from
May 30, 2023
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
8 changes: 1 addition & 7 deletions components/admin/notification/CreateNotiButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ export default function CreateNotiButton() {
return (
<>
<div className={style.container}>
<button
className={style.createAllButton}
onClick={() => setModal({ modalName: 'ADMIN-NOTI_ALL' })}
>
All
</button>
<button
className={style.createSomeoneButton}
onClick={() => setModal({ modalName: 'ADMIN-NOTI_USER' })}
>
User
μ•Œλ¦Ό 보내기
</button>
</div>
</>
Expand Down
32 changes: 16 additions & 16 deletions components/admin/notification/NotificationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ const tableTitle: { [key: string]: string } = {
notiId: 'ID',
roleType: 'κΆŒν•œ',
intraId: 'Intra ID',
slotId: '슬둯 ID',
type: 'μ’…λ₯˜',
message: 'λ‚΄μš©',
createdTime: '생성일',
createdAt: '생성일',
isChecked: '확인 μ—¬λΆ€',
};

interface INotification {
notiId: number;
intraId: string;
slotId: number;
message: string;
type: string;
createdTime: Date;
createdAt: Date;
isChecked: boolean;
}

Expand All @@ -60,21 +58,21 @@ export default function NotificationTable() {
const getUserNotifications = useCallback(async () => {
try {
const res = await instanceInManage.get(
`/notifications?q=${intraId}&page=${currentPage}&size=10`
`/notifications?intraId=${intraId}&page=${currentPage}&size=10`
);
setIntraId(intraId);
setNotificationInfo({
notiList: res.data.notiList.map((noti: INotification) => {
const { year, month, date, hour, min } = getFormattedDateToString(
new Date(noti.createdTime)
new Date(noti.createdAt)
);
return {
...noti,
createdTime: `${year}-${month}-${date} ${hour}:${min}`,
createdAt: `${year}-${month}-${date} ${hour}:${min}`,
};
}),
totalPage: res.data.totalPage,
currentPage: res.data.currentPage,
currentPage: currentPage,
});
} catch (e) {
console.error('MS00');
Expand All @@ -95,15 +93,15 @@ export default function NotificationTable() {
setNotificationInfo({
notiList: res.data.notiList.map((noti: INotification) => {
const { year, month, date, hour, min } = getFormattedDateToString(
new Date(noti.createdTime)
new Date(noti.createdAt)
);
return {
...noti,
createdTime: `${year}-${month}-${date} ${hour}:${min}`,
createdAt: `${year}-${month}-${date} ${hour}:${min}`,
};
}),
totalPage: res.data.totalPage,
currentPage: res.data.currentPage,
currentPage: currentPage,
});
} catch (e) {
console.error('MS01');
Expand All @@ -130,8 +128,10 @@ export default function NotificationTable() {
<div className={styles.notificationWrap}>
<div className={styles.header}>
<span className={styles.title}>μ•Œλ¦Ό 관리</span>
<AdminSearchBar initSearch={initSearch} />
<CreateNotiButton />
<div className={styles.searchWrap}>
<AdminSearchBar initSearch={initSearch} />
<CreateNotiButton />
</div>
</div>
<TableContainer className={styles.tableContainer} component={Paper}>
<Table className={styles.table} aria-label='customized table'>
Expand All @@ -154,11 +154,11 @@ export default function NotificationTable() {
(columnName: string, index: number) => {
return (
<TableCell className={styles.tableBodyItem} key={index}>
{columnName === 'createdTime' ? (
{columnName === 'createdAt' ? (
<div>
{notification.createdTime.toString().slice(0, 4)}
{notification.createdAt.toString().slice(0, 4)}
<br />
{notification.createdTime.toString().slice(5, 10)}
{notification.createdAt.toString().slice(5, 10)}
</div>
) : notification[
columnName as keyof INotification
Expand Down
2 changes: 0 additions & 2 deletions components/modal/ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import AfterGameModal from './afterGame/AfterGameModal';
import StatChangeModal from './statChange/StatChangeModal';
import AdminProfileModal from './admin/AdminProfileModal';
import AdminPenaltyModal from './admin/AdminPenaltyModal';
import AdminNotiAllModal from './admin/AdminNotiAllModal';
import AdminNotiUserModal from './admin/AdminNotiUserModal';
import AdminCheckFeedback from './admin/AdminFeedbackCheckModal';
import AdminSeasonEdit from './admin/SeasonEdit';
Expand Down Expand Up @@ -58,7 +57,6 @@ export default function ModalProvider() {
'ADMIN-PENALTY_DELETE': intraId ? (
<DeletePenaltyModal intraId={intraId} />
) : null,
'ADMIN-NOTI_ALL': <AdminNotiAllModal />,
'ADMIN-NOTI_USER': <AdminNotiUserModal />,
'ADMIN-SEASON_EDIT': ISeason ? <AdminSeasonEdit {...ISeason} /> : null,
'ADMIN-CHECK_FEEDBACK': feedback ? (
Expand Down
107 changes: 0 additions & 107 deletions components/modal/admin/AdminNotiAllModal.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion components/modal/admin/AdminNotiUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function AdminNotiUserModal() {
return;
}
try {
const res = await instanceInManage.post(`/notifications/${keyword}`, {
const res = await instanceInManage.post(`/notifications`, {
keyword,
message: notiContent.current?.value
? notiContent.current?.value
Expand Down
7 changes: 7 additions & 0 deletions styles/admin/notification/NotificationTable.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
font-size: $giant-font;
line-height: 150%;
}
.searchWrap {
display: flex;
align-items: center;
:nth-child(2) {
margin: 0 0 0 20px;
}
}
}

.tableContainer {
Expand Down
1 change: 0 additions & 1 deletion types/modalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type AdminModal =
| 'PROFILE'
| 'PENALTY'
| 'PENALTY_DELETE'
| 'NOTI_ALL'
| 'NOTI_USER'
| 'CHECK_FEEDBACK'
| 'DETAIL_CONTENT'
Expand Down