From 1340a76fd8f48c2c948925469e4057a3bc738cdc Mon Sep 17 00:00:00 2001
From: HyunJinNo
Date: Wed, 17 Jul 2024 23:55:01 +0900
Subject: [PATCH] =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=83=81=EC=84=B8=20?=
=?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=82=A0=EC=A7=9C=20=ED=91=9C?=
=?UTF-8?q?=EC=8B=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/informations/write/page.tsx | 7 +++++++
.../informations/detail/InformationViewer.tsx | 4 ++--
src/containers/common/HeaderContainer.tsx | 12 ++++++------
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/app/informations/write/page.tsx b/src/app/informations/write/page.tsx
index 5cbb59cc..c8eba1a0 100644
--- a/src/app/informations/write/page.tsx
+++ b/src/app/informations/write/page.tsx
@@ -1,6 +1,8 @@
import PagePath from "@/components/common/PagePath";
import InformationEditorContainer from "@/containers/informations/write/InformationEditorContainer";
import { Metadata } from "next";
+import { cookies } from "next/headers";
+import { redirect } from "next/navigation";
export const metadata: Metadata = {
title: "정보 등록하기",
@@ -8,6 +10,11 @@ export const metadata: Metadata = {
};
export default function page() {
+ const cookie = cookies().get("access_token");
+ if (!cookie) {
+ redirect("/auth/signin");
+ }
+
return (
diff --git a/src/components/informations/detail/InformationViewer.tsx b/src/components/informations/detail/InformationViewer.tsx
index 56dc5981..6059019b 100644
--- a/src/components/informations/detail/InformationViewer.tsx
+++ b/src/components/informations/detail/InformationViewer.tsx
@@ -53,7 +53,7 @@ const InformationViewer = async ({ informationId }: Props) => {
{data.userPostingResponse.name}
- {`${data.createdDate}`}
+ {`${new Date(data.createdDate).toLocaleDateString()}`}
@@ -91,7 +91,7 @@ const InformationViewer = async ({ informationId }: Props) => {
{data.userPostingResponse.name}
- {`${data.createdDate}`}
+ {`${new Date(data.createdDate).toLocaleDateString()}`}
diff --git a/src/containers/common/HeaderContainer.tsx b/src/containers/common/HeaderContainer.tsx
index 24c60e5e..681bedfc 100644
--- a/src/containers/common/HeaderContainer.tsx
+++ b/src/containers/common/HeaderContainer.tsx
@@ -45,13 +45,13 @@ const HeaderContainer = () => {
// 자동 로그인
const login = async () => {
const data = await fetchWithAuth("/api/auth/user");
- if (data.status == 200) {
- data.json().then((res: userResponseDto) => {
- authStore.setUser(res);
- });
- }
+ if (data.status == 200) {
+ data.json().then((res: userResponseDto) => {
+ authStore.setUser(res);
+ });
+ }
};
- login();
+ login();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);