{formatDate(notice.createdDate)} |
{notice.category} |
- {notice.title}
- {notice.description}
+ {notice.title}
+ {notice.description}
|
-
+
|
@@ -48,6 +65,7 @@ export default function AdminNoticesPage() {
const { data: notices } = useQuery({
queryKey: [QUERY_KEYS.getAdminAllNotice],
queryFn: getAdminNotices,
+ staleTime: 1000 * 60 * 30,
});
return (
From 30a21824a0442fd38618bc41744b3a089695d296 Mon Sep 17 00:00:00 2001
From: Sohyun Park <124856726+ParkSohyunee@users.noreply.github.com>
Date: Wed, 27 Nov 2024 14:34:23 +0900
Subject: [PATCH 05/13] =?UTF-8?q?Feat:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?=
=?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EB=B3=B4=EB=82=B4=EA=B8=B0,=20=EA=B3=B5?=
=?UTF-8?q?=EA=B0=9C/=EB=B9=84=EA=B3=B5=EA=B0=9C=20=EC=88=98=EC=A0=95=20?=
=?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/_api/notice/sendNoticeAlarm.ts | 7 ++++
src/app/_api/notice/updateNoticePublic.ts | 7 ++++
src/app/admin/notice/page.css.ts | 12 +++----
src/app/admin/notice/page.tsx | 40 +++++++++++++++++++++--
4 files changed, 57 insertions(+), 9 deletions(-)
create mode 100644 src/app/_api/notice/sendNoticeAlarm.ts
create mode 100644 src/app/_api/notice/updateNoticePublic.ts
diff --git a/src/app/_api/notice/sendNoticeAlarm.ts b/src/app/_api/notice/sendNoticeAlarm.ts
new file mode 100644
index 00000000..d4720e5f
--- /dev/null
+++ b/src/app/_api/notice/sendNoticeAlarm.ts
@@ -0,0 +1,7 @@
+import axiosInstance from '@/lib/axios/axiosInstance';
+
+const sendNoticeAlarm = async (noticeId: number) => {
+ await axiosInstance.post(`/admin/notices/${noticeId}/alarm`);
+};
+
+export default sendNoticeAlarm;
diff --git a/src/app/_api/notice/updateNoticePublic.ts b/src/app/_api/notice/updateNoticePublic.ts
new file mode 100644
index 00000000..7e3b656b
--- /dev/null
+++ b/src/app/_api/notice/updateNoticePublic.ts
@@ -0,0 +1,7 @@
+import axiosInstance from '@/lib/axios/axiosInstance';
+
+const updateNoticePublic = async (noticeId: number) => {
+ await axiosInstance.patch(`/admin/notices/${noticeId}`);
+};
+
+export default updateNoticePublic;
diff --git a/src/app/admin/notice/page.css.ts b/src/app/admin/notice/page.css.ts
index f5c56bf5..ccbf73ab 100644
--- a/src/app/admin/notice/page.css.ts
+++ b/src/app/admin/notice/page.css.ts
@@ -61,6 +61,12 @@ export const rowText = style({
whiteSpace: 'nowrap',
});
+export const buttons = style({
+ display: 'flex',
+ justifyContent: 'center',
+ gap: '0.5rem',
+});
+
export const button = style({
padding: '0.5rem 1rem',
borderRadius: '4px',
@@ -71,9 +77,3 @@ export const button = style({
opacity: 0.7,
},
});
-
-export const editButtons = style({
- display: 'flex',
- justifyContent: 'center',
- gap: '0.5rem',
-});
diff --git a/src/app/admin/notice/page.tsx b/src/app/admin/notice/page.tsx
index 16191423..b4dad268 100644
--- a/src/app/admin/notice/page.tsx
+++ b/src/app/admin/notice/page.tsx
@@ -6,6 +6,8 @@ import * as styles from './page.css';
import getAdminNotices from '@/app/_api/notice/getAdminNotices';
import deleteNotice from '@/app/_api/notice/deleteNotice';
+import sendNoticeAlarm from '@/app/_api/notice/sendNoticeAlarm';
+import updateNoticePublic from '@/app/_api/notice/updateNoticePublic';
import { QUERY_KEYS } from '@/lib/constants/queryKeys';
import { AdminNoticeType } from '@/lib/types/noticeType';
@@ -27,10 +29,40 @@ function NoticeItem({ notice }: NoticeItemProps) {
},
});
+ const sendAlarmMutation = useMutation({
+ mutationFn: sendNoticeAlarm,
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.getAdminAllNotice] });
+ },
+ });
+
+ const updatePublicMutation = useMutation({
+ mutationFn: updateNoticePublic,
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.getAdminAllNotice] });
+ },
+ });
+
const handleDeleteNotice = () => {
deleteMutation.mutate(notice.id);
};
+ const handleSendAlarm = () => {
+ if (!notice.isExposed) {
+ alert('공개 게시물만 알림을 보낼 수 있어요.');
+ return;
+ }
+ if (notice.didSendAlarm) {
+ alert('이미 알림을 보낸 게시물입니다.');
+ return;
+ }
+ sendAlarmMutation.mutate(notice.id);
+ };
+
+ const handleTogglePublic = () => {
+ updatePublicMutation.mutate(notice.id);
+ };
+
return (
{formatDate(notice.createdDate)} |
@@ -39,7 +71,7 @@ function NoticeItem({ notice }: NoticeItemProps) {
{notice.title}
{notice.description}
-
+ |
|
- 알림보내기
+
+ 알림보내기
+
|
- |
-
-
-
+
+
+
|
From 64f14d7eb40384d3d77e3108ac3528aa1b1feb7c Mon Sep 17 00:00:00 2001
From: Sohyun Park <124856726+ParkSohyunee@users.noreply.github.com>
Date: Fri, 29 Nov 2024 15:53:33 +0900
Subject: [PATCH 09/13] =?UTF-8?q?Feat:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?=
=?UTF-8?q?=EC=95=8C=EB=A6=BC=EB=B3=B4=EB=82=B4=EA=B8=B0=20UI/UX=20?=
=?UTF-8?q?=EA=B0=9C=EC=84=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../notice/_components/NoticeItem.css.ts | 15 ++++++-
.../admin/notice/_components/NoticeItem.tsx | 40 +++++++++++--------
2 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/src/app/admin/notice/_components/NoticeItem.css.ts b/src/app/admin/notice/_components/NoticeItem.css.ts
index 48d3a0e3..1be24153 100644
--- a/src/app/admin/notice/_components/NoticeItem.css.ts
+++ b/src/app/admin/notice/_components/NoticeItem.css.ts
@@ -1,4 +1,4 @@
-import { style } from '@vanilla-extract/css';
+import { style, styleVariants } from '@vanilla-extract/css';
import { vars } from '@/styles/theme.css';
import { Label } from '@/styles/font.css';
@@ -37,7 +37,7 @@ export const buttons = style({
gap: '0.5rem',
});
-export const button = style({
+const button = style({
padding: '0.5rem 1rem',
borderRadius: '4px',
backgroundColor: vars.color.blue,
@@ -48,6 +48,17 @@ export const button = style({
},
});
+export const variantsButton = styleVariants({
+ default: [button],
+ disabled: [
+ button,
+ {
+ opacity: 0.7,
+ cursor: 'default',
+ },
+ ],
+});
+
export const modal = style({
width: '100%',
height: '100vh',
diff --git a/src/app/admin/notice/_components/NoticeItem.tsx b/src/app/admin/notice/_components/NoticeItem.tsx
index 9a8133cc..8c395275 100644
--- a/src/app/admin/notice/_components/NoticeItem.tsx
+++ b/src/app/admin/notice/_components/NoticeItem.tsx
@@ -36,53 +36,61 @@ function NoticeItem({ notice }: NoticeItemProps) {
const { deletNoticeMutation, sendNoticeAlarmMutation, updateNoticePublicMutation } = useNotice();
const { isOn, handleSetOn, handleSetOff } = useBooleanOutput();
+ const { id, title, description, didSendAlarm, isExposed, category, createdDate } = notice;
+
const handleDeleteNotice = () => {
- deletNoticeMutation.mutate(notice.id);
+ deletNoticeMutation.mutate(id);
};
const handleSendAlarm = () => {
- if (!notice.isExposed) {
+ if (!isExposed) {
alert('공개 게시물만 알림을 보낼 수 있어요.');
return;
}
- if (notice.didSendAlarm) {
+ if (didSendAlarm) {
alert('이미 알림을 보낸 게시물입니다.');
return;
}
- sendNoticeAlarmMutation.mutate(notice.id);
+ sendNoticeAlarmMutation.mutate(id, {
+ onSuccess: () => alert('알림을 보냈어요.'),
+ });
};
const handleTogglePublic = () => {
- updateNoticePublicMutation.mutate(notice.id);
+ updateNoticePublicMutation.mutate(id);
};
return (
<>
- {formatDate(notice.createdDate)} |
- {notice.category} |
+ {formatDate(createdDate)} |
+ {category} |
- {notice.title}
- {notice.description}
+ {title}
+ {description}
|
- 수정
-
+ 수정
+
삭제
|
-
+
미리보기
|
-
- 알림보내기
+
+ {`알림 ${didSendAlarm ? '완료' : '보내기'}`}
|
-
+
@@ -92,7 +100,7 @@ function NoticeItem({ notice }: NoticeItemProps) {
{isOn && (
)}
From eb970595702c2cf0588cd57a258031dc469b7e52 Mon Sep 17 00:00:00 2001
From: Sohyun Park <124856726+ParkSohyunee@users.noreply.github.com>
Date: Fri, 29 Nov 2024 16:01:43 +0900
Subject: [PATCH 10/13] =?UTF-8?q?Fix:=20build=20=EC=97=90=EB=9F=AC=20?=
=?UTF-8?q?=ED=95=B4=EA=B2=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/notices/mockdata.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/notices/mockdata.ts b/src/app/notices/mockdata.ts
index 516a6d8b..0cb59d1e 100644
--- a/src/app/notices/mockdata.ts
+++ b/src/app/notices/mockdata.ts
@@ -64,7 +64,7 @@ export const NOTICE_DETAIL_MOCKDATA: NoticeDetailType = {
category: '소식',
title: '서비스 점검 안내',
description: '서비스 점검이 10월 20일에 진행될 예정입니다.',
- content: [
+ contents: [
{
type: 'subtitle',
description: '점검 일정',
From 56a750a9cf7ae4c1c3183a9cd207d21adfdd8fb5 Mon Sep 17 00:00:00 2001
From: Sohyun Park <124856726+ParkSohyunee@users.noreply.github.com>
Date: Fri, 29 Nov 2024 17:05:16 +0900
Subject: [PATCH 11/13] =?UTF-8?q?Feat:=20=EC=BB=A4=EC=8A=A4=ED=85=80?=
=?UTF-8?q?=ED=9B=85=20useNotice=20=EB=B0=98=ED=99=98=20=EA=B0=92=20?=
=?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=A0=95=EC=9D=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/queries/useNotice.ts | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/hooks/queries/useNotice.ts b/src/hooks/queries/useNotice.ts
index 0c040fb4..9d2ab328 100644
--- a/src/hooks/queries/useNotice.ts
+++ b/src/hooks/queries/useNotice.ts
@@ -1,6 +1,6 @@
'use client';
-import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';
+import { useMutation, UseMutationOptions, UseMutationResult, useQueryClient } from '@tanstack/react-query';
import deleteNotice from '@/app/_api/notice/deleteNotice';
import sendNoticeAlarm from '@/app/_api/notice/sendNoticeAlarm';
@@ -23,8 +23,16 @@ const useNoticeMutation = 타입으로,
+// useNotice 훅이 반환하는 각 함수의 반환값(void), 에러, 변수 타입(number), context 타입을 정의해주었다.
+type UseNoticeReturnType = {
+ deletNoticeMutation: UseMutationResult;
+ sendNoticeAlarmMutation: UseMutationResult;
+ updateNoticePublicMutation: UseMutationResult;
+};
+
// React-query의 useMutation을 wrapping해주는 Notice 관련 custom hook
-const useNotice = () => {
+const useNotice = (): UseNoticeReturnType => {
const deletNoticeMutation = useNoticeMutation(deleteNotice);
const sendNoticeAlarmMutation = useNoticeMutation(sendNoticeAlarm);
const updateNoticePublicMutation = useNoticeMutation(updateNoticePublic);
From 6de26f02747ce343ec73d44326a7c37aa08734ed Mon Sep 17 00:00:00 2001
From: Sohyun Park <124856726+ParkSohyunee@users.noreply.github.com>
Date: Sun, 1 Dec 2024 20:47:12 +0900
Subject: [PATCH 12/13] =?UTF-8?q?Style:=20=ED=95=A8=EC=88=98=20=EC=98=A4?=
=?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/admin/notice/_components/NoticeItem.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/app/admin/notice/_components/NoticeItem.tsx b/src/app/admin/notice/_components/NoticeItem.tsx
index 8c395275..b18ba071 100644
--- a/src/app/admin/notice/_components/NoticeItem.tsx
+++ b/src/app/admin/notice/_components/NoticeItem.tsx
@@ -33,13 +33,13 @@ interface NoticeItemProps {
}
function NoticeItem({ notice }: NoticeItemProps) {
- const { deletNoticeMutation, sendNoticeAlarmMutation, updateNoticePublicMutation } = useNotice();
+ const { deleteNoticeMutation, sendNoticeAlarmMutation, updateNoticePublicMutation } = useNotice();
const { isOn, handleSetOn, handleSetOff } = useBooleanOutput();
const { id, title, description, didSendAlarm, isExposed, category, createdDate } = notice;
const handleDeleteNotice = () => {
- deletNoticeMutation.mutate(id);
+ deleteNoticeMutation.mutate(id);
};
const handleSendAlarm = () => {
From 1bceef0f80ea187f0a2cb3abd9c48fc4f9a5dbac Mon Sep 17 00:00:00 2001
From: Sohyun Park <124856726+ParkSohyunee@users.noreply.github.com>
Date: Sun, 1 Dec 2024 20:47:55 +0900
Subject: [PATCH 13/13] =?UTF-8?q?Style:=20useNotice=20=EC=BB=A4=EC=8A=A4?=
=?UTF-8?q?=ED=85=80=20=ED=9B=85=20=ED=95=A8=EC=88=98=20=EC=98=A4=ED=83=80?=
=?UTF-8?q?=20=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/queries/useNotice.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/hooks/queries/useNotice.ts b/src/hooks/queries/useNotice.ts
index 9d2ab328..f3c159fe 100644
--- a/src/hooks/queries/useNotice.ts
+++ b/src/hooks/queries/useNotice.ts
@@ -26,19 +26,19 @@ const useNoticeMutation = 타입으로,
// useNotice 훅이 반환하는 각 함수의 반환값(void), 에러, 변수 타입(number), context 타입을 정의해주었다.
type UseNoticeReturnType = {
- deletNoticeMutation: UseMutationResult;
+ deleteNoticeMutation: UseMutationResult;
sendNoticeAlarmMutation: UseMutationResult;
updateNoticePublicMutation: UseMutationResult;
};
// React-query의 useMutation을 wrapping해주는 Notice 관련 custom hook
const useNotice = (): UseNoticeReturnType => {
- const deletNoticeMutation = useNoticeMutation(deleteNotice);
+ const deleteNoticeMutation = useNoticeMutation(deleteNotice);
const sendNoticeAlarmMutation = useNoticeMutation(sendNoticeAlarm);
const updateNoticePublicMutation = useNoticeMutation(updateNoticePublic);
return {
- deletNoticeMutation,
+ deleteNoticeMutation,
sendNoticeAlarmMutation,
updateNoticePublicMutation,
};
| |