From 054627e80d8c2131850f0db03eb1395a12e36338 Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Sun, 23 Mar 2025 14:23:09 -0600
Subject: [PATCH] feat: add input-otp component for enhanced email verification
---
.../app/[locale]/license/success/page.tsx | 2 -
.../app/[locale]/reset-license/page.tsx | 45 +++++++-----
apps/website/app/layout.tsx | 2 +-
apps/website/components/ui/input-otp.tsx | 71 +++++++++++++++++++
apps/website/package.json | 1 +
pnpm-lock.yaml | 14 ++++
6 files changed, 116 insertions(+), 19 deletions(-)
create mode 100644 apps/website/components/ui/input-otp.tsx
diff --git a/apps/website/app/[locale]/license/success/page.tsx b/apps/website/app/[locale]/license/success/page.tsx
index 02ab589..596f73b 100644
--- a/apps/website/app/[locale]/license/success/page.tsx
+++ b/apps/website/app/[locale]/license/success/page.tsx
@@ -80,8 +80,6 @@ export default function LicenseSuccess() {
toast.success("Copied to clipboard");
};
- console.log(error);
-
return (
diff --git a/apps/website/app/[locale]/reset-license/page.tsx b/apps/website/app/[locale]/reset-license/page.tsx
index f898edb..b6be0d5 100644
--- a/apps/website/app/[locale]/reset-license/page.tsx
+++ b/apps/website/app/[locale]/reset-license/page.tsx
@@ -1,12 +1,14 @@
"use client";
import { Container } from "@/components/Container";
+import { SERVER_LICENSE_URL } from "@/components/pricing";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useState } from "react";
-
+import { toast } from "sonner";
export default function ResetLicensePage() {
const [email, setEmail] = useState("");
+ const [showOtp, setShowOtp] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
@@ -14,24 +16,35 @@ export default function ResetLicensePage() {
setIsLoading(true);
try {
- // Here you would add the API call to reset the license
- // For now, we'll just simulate a success response
- await new Promise((resolve) => setTimeout(resolve, 1500));
+ const result = await fetch(`${SERVER_LICENSE_URL}/license/verification`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ email }),
+ });
- // toast({
- // title: "Success!",
- // description:
- // "If an account exists with this email, you will receive instructions to reset your license.",
- // variant: "default",
- // });
+ const data = await result.json();
+ console.log(data);
- setEmail("");
+ if (data.error) {
+ toast.error(
+ "Error sending verification code. Please try again later.",
+ {
+ description: data.error,
+ },
+ );
+ } else {
+ toast.success(
+ "We've sent you a code to verify your email. Please check your email for the code.",
+ );
+ setShowOtp(true);
+ }
} catch (error) {
- // toast({
- // title: "Error",
- // description: "Something went wrong. Please try again later.",
- // variant: "destructive",
- // });
+ toast.error("Something went wrong. Please try again later.", {
+ duration: 15000,
+ description: error instanceof Error ? error.message : "Unknown error",
+ });
} finally {
setIsLoading(false);
}
diff --git a/apps/website/app/layout.tsx b/apps/website/app/layout.tsx
index 4624d6c..393afd6 100644
--- a/apps/website/app/layout.tsx
+++ b/apps/website/app/layout.tsx
@@ -64,7 +64,7 @@ export default async function RootLayout({
{children}
-
+