Skip to content

Commit

Permalink
revalidateNotice 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
yeolyi committed Sep 19, 2023
1 parent 0eda461 commit 8a02239
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
4 changes: 4 additions & 0 deletions actions/noticeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export const batchUnpin = async (ids: Set<number>) => {
return { error };
}
};

export const revalidateNotice = async () => {
revalidatePath('/community/notice');
};
1 change: 1 addition & 0 deletions app/[locale]/community/news/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function NewsCreatePage() {
tags={NewsTags}
showMainImage
showIsSlide
showIsImportant
actions={{
type: 'CREATE',
onComplete: handleComplete,
Expand Down
4 changes: 3 additions & 1 deletion app/[locale]/community/notice/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { useRouter } from 'next/navigation';

import { revalidateNotice } from '@/actions/noticeActions';

import { postNotice } from '@/apis/notice';

import PostEditor from '@/components/editor/PostEditor';
Expand Down Expand Up @@ -38,7 +40,7 @@ export default function NoticeCreatePage() {
},
attachments,
});

await revalidateNotice();
router.replace(noticePath);
};

Expand Down
40 changes: 14 additions & 26 deletions app/[locale]/reservations/[roomType]/[roomName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,21 @@ async function LoginedRoomReservationPage({ params, searchParams }: RoomReservat

const startOfWeek = getStartOfWeek(date);

try {
const reservations = await getWeeklyReservation({
roomId,
year: startOfWeek.getFullYear(),
month: startOfWeek.getMonth() + 1,
day: startOfWeek.getDate(),
});
const reservations = await getWeeklyReservation({
roomId,
year: startOfWeek.getFullYear(),
month: startOfWeek.getMonth() + 1,
day: startOfWeek.getDate(),
});

return (
<ReservationCalendar
startDate={startOfWeek}
selectedDate={date}
reservations={reservations}
roomId={roomId}
/>
);
} catch (e) {
if (e instanceof NetworkError && e.statusCode === 401) {
return (
<PageLayout titleType="big" titleMargin="mb-[2.25rem]">
권한이 없습니다.
</PageLayout>
);
} else {
throw e;
}
}
return (
<ReservationCalendar
startDate={startOfWeek}
selectedDate={date}
reservations={reservations}
roomId={roomId}
/>
);
}

const isValidRoomName = (roomName: string): roomName is keyof typeof roomNameToId => {
Expand Down
4 changes: 3 additions & 1 deletion components/layout/navbar/NavbarRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export default function NavbarRoot({
}

function SNULogo() {
const refreshPage = () => window.location.reload();
const refreshPage = () => {
window.location.href = '/';
};
return (
<button onClick={refreshPage}>
<SnuLogo className="fill-neutral-800" width="56" height="58" viewBox="0 0 45 47" />
Expand Down
3 changes: 3 additions & 0 deletions components/notice/EditNoticePageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { useRouter } from 'next/navigation';

import { revalidateNotice } from '@/actions/noticeActions';

import { deleteNotice, patchNotice } from '@/apis/notice';

import PostEditor from '@/components/editor/PostEditor';
Expand Down Expand Up @@ -61,6 +63,7 @@ export default function EditNoticePageContent({ id, data }: { id: number; data:
newAttachments: localAttachments,
});

await revalidateNotice();
router.replace(`${noticePath}/${id}`);
};

Expand Down

0 comments on commit 8a02239

Please sign in to comment.