From 64cf47f2a972002a666ce52618164d1e6b171cf9 Mon Sep 17 00:00:00 2001 From: Takaharu Nakamura Date: Tue, 30 Apr 2024 12:58:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20applicationPeriod=E3=81=AEatom?= =?UTF-8?q?=E3=82=92=E4=BD=BF=E3=81=86=E3=81=B9=E3=81=8D=E5=A0=B4=E9=9D=A2?= =?UTF-8?q?=E3=81=A7=E4=BD=BF=E3=82=8F=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/register/page.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx index 74934121..f736c6f2 100644 --- a/src/app/register/page.tsx +++ b/src/app/register/page.tsx @@ -8,7 +8,8 @@ import { RegistrationProgress } from "@/common_components/RegistrationProgress"; import useSWR from "swr"; import { useRouter } from "next/navigation"; import { assignType } from "@/lib/openapi"; -import dayjs from "dayjs"; +import { useAtomValue } from "jotai/react/useAtomValue"; +import { projectApplicationPeriodAtom } from "@/lib/projectApplicationPeriod"; const RegisterPage = () => { const { data: userRes, isLoading: userIsLoading, error: userError } = useSWR("/users/me"); @@ -19,14 +20,12 @@ const RegisterPage = () => { isLoading: isApplicationPeriodLoading, error: applicationPeriodError, } = useSWR("/project-application-period"); + const applicationPeriod = useAtomValue(projectApplicationPeriodAtom); if (userIsLoading || isApplicationPeriodLoading) return; if (userError || applicationPeriodError) return

エラーが発生しました

; if (user.owned_project_id) { router.push("/dashboard"); } - const applicationPeriod = assignType("/project-application-period", _applicationPeriod); - const isInApplicationPeriod = - dayjs().isBefore(applicationPeriod.end_at) && dayjs().isAfter(applicationPeriod.start_at); return (
{ marginY: 8, })}> 企画登録 - {isInApplicationPeriod ? ( + {applicationPeriod.isIn ? ( <>
Date: Tue, 30 Apr 2024 13:02:28 +0900 Subject: [PATCH 2/3] fix: jotai --- src/app/register/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx index f736c6f2..577b84a1 100644 --- a/src/app/register/page.tsx +++ b/src/app/register/page.tsx @@ -8,7 +8,7 @@ import { RegistrationProgress } from "@/common_components/RegistrationProgress"; import useSWR from "swr"; import { useRouter } from "next/navigation"; import { assignType } from "@/lib/openapi"; -import { useAtomValue } from "jotai/react/useAtomValue"; +import { useAtomValue } from "jotai"; import { projectApplicationPeriodAtom } from "@/lib/projectApplicationPeriod"; const RegisterPage = () => { From e31a2f746b6001ad4eb01ed1832c09bd359a5424 Mon Sep 17 00:00:00 2001 From: Takaharu Nakamura Date: Tue, 30 Apr 2024 13:19:12 +0900 Subject: [PATCH 3/3] refactor: removed unused codes --- src/app/register/page.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx index 577b84a1..03b23924 100644 --- a/src/app/register/page.tsx +++ b/src/app/register/page.tsx @@ -15,14 +15,9 @@ const RegisterPage = () => { const { data: userRes, isLoading: userIsLoading, error: userError } = useSWR("/users/me"); const router = useRouter(); const user = assignType("/users/me", userRes); - const { - data: _applicationPeriod, - isLoading: isApplicationPeriodLoading, - error: applicationPeriodError, - } = useSWR("/project-application-period"); const applicationPeriod = useAtomValue(projectApplicationPeriodAtom); - if (userIsLoading || isApplicationPeriodLoading) return; - if (userError || applicationPeriodError) return

エラーが発生しました

; + if (userIsLoading) return; + if (userError) return

エラーが発生しました

; if (user.owned_project_id) { router.push("/dashboard"); }