feat: remove email verification toast

This commit is contained in:
DIYgod 2025-03-26 19:51:33 +08:00
parent 23df2bfeb0
commit 9bb723a33b
No known key found for this signature in database
2 changed files with 2 additions and 61 deletions

View File

@ -8,6 +8,7 @@
"1004": "No permission",
"1005": "Internal error",
"1006": "Email not verified",
"1007": "Captcha verification failed",
"1100": "Trial user max feed subscription exceeded",
"1101": "Trial user max list subscription exceeded",
"1102": "Trial user max inbox subscription exceeded",

View File

@ -1,12 +1,7 @@
import { cn } from "@follow/utils/utils"
import { lazy, Suspense, useEffect, useState } from "react"
import { useTranslation } from "react-i18next"
import { toast } from "sonner"
import { lazy, Suspense } from "react"
import { useWhoami } from "~/atoms/user"
import { WEB_URL } from "~/constants/env"
import { useAuthQuery } from "~/hooks/common/useBizQuery"
import { sendVerificationEmail } from "~/lib/auth"
import { settings } from "~/queries/settings"
const LazyNewUserGuideModal = lazy(() =>
@ -19,64 +14,9 @@ export function NewUserGuide() {
const isNewUser =
!isLoading && remoteSettings && Object.keys(remoteSettings.updated ?? {}).length === 0
useEffect(() => {
if (user?.email && !user.emailVerified) {
toast.error(<EmailVerificationToast user={user} />, {
id: "email-verification",
duration: Infinity,
closeButton: true,
})
}
}, [user?.emailVerified])
return user && isNewUser ? (
<Suspense>
<LazyNewUserGuideModal />
</Suspense>
) : null
}
function EmailVerificationToast({
user,
}: {
user: {
email: string
}
}) {
const { t } = useTranslation("settings")
const [isEmailVerificationSent, setIsEmailVerificationSent] = useState(false)
return (
<div data-content className="flex w-full flex-col gap-2">
<div data-title>
{t("profile.email.verify_email", {
email_address: user.email,
})}
</div>
<button
type="button"
data-button="true"
data-action="true"
className={cn(
"font-sans font-medium",
isEmailVerificationSent && "!cursor-progress opacity-50",
)}
disabled={isEmailVerificationSent}
onClick={async () => {
setIsEmailVerificationSent(true)
await sendVerificationEmail({
email: user.email,
callbackURL: `${WEB_URL}/login`,
})
toast.dismiss("email-verification")
// Wait for the toast to dismiss before showing the success toast
// To have a better user experience
setTimeout(() => {
toast.success(t("profile.email.verification_sent"))
}, 800)
}}
>
{t("profile.email.send_verification")}
</button>
</div>
)
}