-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from shawakash/otp
feat: adding otp validation support
- Loading branch information
Showing
66 changed files
with
1,740 additions
and
461 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"use client"; | ||
import { SparklesCore } from "@/components/ui/sparklecore"; | ||
import React from "react"; | ||
|
||
interface SparklesProps { | ||
classname: string; | ||
background: string; | ||
minSize: number; | ||
maxSize: number; | ||
body: string; | ||
particleColor?: string | "#FFFFFF"; | ||
} | ||
|
||
const Sparkles = ({ | ||
classname, | ||
background, | ||
minSize, | ||
maxSize, | ||
particleColor, | ||
body, | ||
}: SparklesProps) => { | ||
return ( | ||
<div className="h-[40rem] w-full flex flex-col items-center justify-center overflow-hidden rounded-md"> | ||
<h1 className="md:text-7xl text-3xl lg:text-9xl font-bold text-center text-white relative z-20"> | ||
{body} | ||
</h1> | ||
<div className="w-[40rem] h-40 relative"> | ||
{/* Gradients */} | ||
<div className="absolute inset-x-20 top-0 bg-gradient-to-r from-transparent via-indigo-500 to-transparent h-[2px] w-3/4 blur-sm" /> | ||
<div className="absolute inset-x-20 top-0 bg-gradient-to-r from-transparent via-indigo-500 to-transparent h-px w-3/4" /> | ||
<div className="absolute inset-x-60 top-0 bg-gradient-to-r from-transparent via-sky-500 to-transparent h-[5px] w-1/4 blur-sm" /> | ||
<div className="absolute inset-x-60 top-0 bg-gradient-to-r from-transparent via-sky-500 to-transparent h-px w-1/4" /> | ||
|
||
{/* Core component */} | ||
<SparklesCore | ||
background={background} | ||
minSize={minSize} | ||
maxSize={maxSize} | ||
particleDensity={1200} | ||
className="w-full h-full" | ||
particleColor="#FFFFFF" | ||
/> | ||
|
||
<div className="absolute inset-0 w-full h-full bg-[04080F] [mask-image:radial-gradient(350px_200px_at_top,transparent_20%,white)]"></div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Sparkles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
"use client" | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod" | ||
import { useForm } from "react-hook-form" | ||
import { z } from "zod" | ||
|
||
import { Button } from "@/components/ui/button" | ||
import { | ||
Form, | ||
FormControl, | ||
FormDescription, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@/components/ui/form" | ||
import { | ||
InputOTP, | ||
InputOTPGroup, | ||
InputOTPSlot, | ||
InputOTPSeparator, | ||
} from "@/components/ui/input-otp" | ||
import { toast } from "@/components/ui/use-toast" | ||
import React from "react" | ||
import { AccountType, BACKEND_URL, OtpValid, responseStatus } from "@paybox/common" | ||
import { useSession } from "next-auth/react" | ||
|
||
|
||
export function OTPForm() { | ||
|
||
const session = useSession(); | ||
console.log(session, "session") | ||
const form = useForm<z.infer<typeof OtpValid>>({ | ||
resolver: zodResolver(OtpValid), | ||
defaultValues: { | ||
otp: "", | ||
}, | ||
}) | ||
|
||
const onSubmit = async (data: z.infer<typeof OtpValid>) => { | ||
const { status, msg, valid, walletId, account }: { status: responseStatus, msg: string, valid?: boolean, walletId?: string, account?: AccountType } = | ||
await fetch(`${BACKEND_URL}/client/valid?otp=${data.otp}`, { | ||
method: "PATCH", | ||
headers: { | ||
"Content-Type": "application/json", | ||
//@ts-ignore | ||
"Authorization": `Bearer ${session.data?.user?.jwt}` | ||
}, | ||
}).then((res) => res.json()); | ||
console.log(status, "valid") | ||
toast({ | ||
title: "Otp Validation Status", | ||
description: ( | ||
<h1>{msg}</h1> | ||
), | ||
}) | ||
} | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="w-2/3 space-y-6"> | ||
<FormField | ||
control={form.control} | ||
name="otp" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<InputOTP | ||
maxLength={6} | ||
render={({ slots }) => ( | ||
<InputOTPGroup className="gap-2"> | ||
{slots.map((slot, index) => ( | ||
<React.Fragment key={index}> | ||
<InputOTPSlot className="rounded-md border" {...slot} /> | ||
{index !== slots.length - 1 && <InputOTPSeparator />} | ||
</React.Fragment> | ||
))}{" "} | ||
</InputOTPGroup> | ||
)} | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormDescription> | ||
Please enter the six digit one-time passcode sent to your phone or email by @Paybox. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit">Submit</Button> | ||
</form> | ||
</Form> | ||
) | ||
} |
Oops, something went wrong.