diff --git a/src/assets/SendButton_white.svg b/src/assets/SendButton_white.svg new file mode 100644 index 00000000..84559d91 --- /dev/null +++ b/src/assets/SendButton_white.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/common_components/auth/AuthUI.tsx b/src/common_components/auth/AuthUI.tsx index f9a5e2cb..df7bcb0f 100644 --- a/src/common_components/auth/AuthUI.tsx +++ b/src/common_components/auth/AuthUI.tsx @@ -1,5 +1,5 @@ "use client"; -import React, { FC, PropsWithChildren } from "react"; +import React, { FC, PropsWithChildren, useState } from "react"; import { Header } from "@/common_components/header/Header"; import SigninPage from "@/common_components/auth/signin/page"; import SignupPage from "@/common_components/auth/signup/page"; @@ -17,6 +17,7 @@ export const authModeAtom = atomWithHash<"signIn" | "signUp" | "resetPassword">( export const AuthUI: FC = ({ children }) => { const authMode = useAtomValue(authModeAtom); const authState = useAuthState(); + const [userEmail, setUserEmail] = useState(null); const path = usePathname(); if (path === "/") { @@ -36,7 +37,7 @@ export const AuthUI: FC = ({ children }) => { return ; case "signUp": - return ; + return ; case "resetPassword": return ; @@ -57,7 +58,7 @@ export const AuthUI: FC = ({ children }) => { ) : authState.user ? ( - <>{authState.user.emailVerified ? <>{children} : } + <>{authState.user.emailVerified ? <>{children} : } ) : ( )} diff --git a/src/common_components/auth/EmailVerification.tsx b/src/common_components/auth/EmailVerification.tsx index b6df2058..83c263c5 100644 --- a/src/common_components/auth/EmailVerification.tsx +++ b/src/common_components/auth/EmailVerification.tsx @@ -1,6 +1,6 @@ import { center } from "@styled-system/patterns"; import { css, cx } from "@styled-system/css"; -import SendButton from "@/assets/SendButton.svg?url"; +import SendButton from "@/assets/SendButton_white.svg?url"; import Image from "next/image"; import { sendEmailVerification } from "firebase/auth"; import { useAuthState } from "@/lib/firebase"; @@ -8,7 +8,11 @@ import { useState } from "react"; import toast from "react-hot-toast"; import { buttonStyle } from "@/recipes/button"; -export const EmailVerification = () => { +interface EmailVerificationProps { + userEmail: string | null; +} + +export const EmailVerification: React.FC = ({ userEmail }) => { const authState = useAuthState(); const [isSent, setIsSent] = useState(false); const handleResend = () => { @@ -60,7 +64,7 @@ export const EmailVerification = () => {
+ {userEmail && ( + + Outlook を開く(外部) + + )} {isSent && (

確認メールを再送しました diff --git a/src/common_components/auth/signup/SignupForm.tsx b/src/common_components/auth/signup/SignupForm.tsx index 7d7ee673..06c8351b 100644 --- a/src/common_components/auth/signup/SignupForm.tsx +++ b/src/common_components/auth/signup/SignupForm.tsx @@ -8,6 +8,7 @@ import { Button } from "@/common_components/Button"; import { getAuth, sendEmailVerification, signInWithEmailAndPassword } from "firebase/auth"; import { SignupSchema, SignupSchemaType } from "@/lib/valibot"; import { valibotResolver } from "@hookform/resolvers/valibot"; +import { Dispatch, SetStateAction } from "react"; let labelAndInputStyle = css({ display: "flex", @@ -16,7 +17,11 @@ let labelAndInputStyle = css({ width: "100%", }); -export const SignupForm = () => { +interface SignupFormProps { + setUserEmail: Dispatch>; +} + +export const SignupForm: React.FC = ({ setUserEmail }) => { const { register, handleSubmit, @@ -44,6 +49,7 @@ export const SignupForm = () => { if (res.status === 201) { const auth = getAuth(); signInWithEmailAndPassword(auth, data.email, data.password).then(() => { + setUserEmail(data.email); sendEmailVerification(auth.currentUser!); }); } else { @@ -124,7 +130,9 @@ export const SignupForm = () => {