From 7caebd0dad36d5395b1954c9e310682e92fcb185 Mon Sep 17 00:00:00 2001 From: Divyanshgupta030 <145568562+Divyanshgupta030@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:50:03 +0530 Subject: [PATCH 01/16] add mail service --- apps/www/app/(auth)/sign-in/page.tsx | 5 ++--- apps/www/app/(auth)/sign-up/page.tsx | 4 ++-- .../components/custom/{Sign-In.tsx => signinComponent.tsx} | 2 +- .../components/custom/{Sign-up.tsx => signupComponent.tsx} | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) rename apps/www/components/custom/{Sign-In.tsx => signinComponent.tsx} (97%) rename apps/www/components/custom/{Sign-up.tsx => signupComponent.tsx} (98%) diff --git a/apps/www/app/(auth)/sign-in/page.tsx b/apps/www/app/(auth)/sign-in/page.tsx index 45b475f..3c16bea 100644 --- a/apps/www/app/(auth)/sign-in/page.tsx +++ b/apps/www/app/(auth)/sign-in/page.tsx @@ -1,10 +1,9 @@ -import SignIn from "@/components/custom/Sign-In"; +import SignInComponent from "@/components/custom/signinComponent"; export default function page() { return (
- {" "} - +
); } diff --git a/apps/www/app/(auth)/sign-up/page.tsx b/apps/www/app/(auth)/sign-up/page.tsx index 9354fcb..7a96bc3 100644 --- a/apps/www/app/(auth)/sign-up/page.tsx +++ b/apps/www/app/(auth)/sign-up/page.tsx @@ -1,9 +1,9 @@ -import SignUp from "../../../components/custom/Sign-up"; +import SignUpComponent from "@/components/custom/signupComponent"; export default function page() { return (
- +
); } diff --git a/apps/www/components/custom/Sign-In.tsx b/apps/www/components/custom/signinComponent.tsx similarity index 97% rename from apps/www/components/custom/Sign-In.tsx rename to apps/www/components/custom/signinComponent.tsx index 132f323..b958a64 100644 --- a/apps/www/components/custom/Sign-In.tsx +++ b/apps/www/components/custom/signinComponent.tsx @@ -21,7 +21,7 @@ const formSchema = z.object({ password: z.string().min(8), }); -export default function SignIn() { +export default function SignInComponent() { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { diff --git a/apps/www/components/custom/Sign-up.tsx b/apps/www/components/custom/signupComponent.tsx similarity index 98% rename from apps/www/components/custom/Sign-up.tsx rename to apps/www/components/custom/signupComponent.tsx index 56729a0..888387a 100644 --- a/apps/www/components/custom/Sign-up.tsx +++ b/apps/www/components/custom/signupComponent.tsx @@ -23,7 +23,7 @@ const formSchema = z.object({ password: z.string().min(8), }); -export default function SignUp() { +export default function SignUpComponent() { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { From 0e0003035e8280f8a0f910e82b4090dca6241836 Mon Sep 17 00:00:00 2001 From: Divyanshgupta030 <145568562+Divyanshgupta030@users.noreply.github.com> Date: Sun, 10 Nov 2024 15:02:13 +0530 Subject: [PATCH 02/16] fix error --- apps/www/app/(auth)/dashboard/page.tsx | 12 ++ apps/www/app/(auth)/sign-in/page.tsx | 8 ++ apps/www/app/(auth)/sign-up/page.tsx | 13 ++ apps/www/components/custom/Sign-In.tsx | 82 ++++++++++++ apps/www/components/custom/Sign-up.tsx | 98 ++++++++++++++ .../components/custom/account-switcher.tsx | 30 +++++ apps/www/components/ui/button.tsx | 26 ++-- apps/www/components/ui/form.tsx | 121 ++++++++++++++++++ apps/www/components/ui/label.tsx | 21 +++ apps/www/lib/auth-client.ts | 9 ++ apps/www/lib/server.ts | 8 ++ apps/www/middleware.ts | 24 ++++ apps/www/package.json | 7 + 13 files changed, 446 insertions(+), 13 deletions(-) create mode 100644 apps/www/components/custom/Sign-In.tsx create mode 100644 apps/www/components/custom/Sign-up.tsx create mode 100644 apps/www/middleware.ts diff --git a/apps/www/app/(auth)/dashboard/page.tsx b/apps/www/app/(auth)/dashboard/page.tsx index bb407d0..7c2a04f 100644 --- a/apps/www/app/(auth)/dashboard/page.tsx +++ b/apps/www/app/(auth)/dashboard/page.tsx @@ -2,6 +2,7 @@ import AccountSwitcher from "@/components/custom/account-switcher"; import { getMultipleSessions, getSession } from "@/lib/server"; export default async function page() { +<<<<<<< HEAD const session = await getSession(); const multipleSessions = await getMultipleSessions(); return ( @@ -11,4 +12,15 @@ export default async function page() { {/*
{JSON.stringify(multipleSessions,null,2)}
*/} ); +======= + const session = await getSession() + const multipleSessions = await getMultipleSessions() + return ( +
+ +
{JSON.stringify(session,null,1)}
+ {/*
{JSON.stringify(multipleSessions,null,2)}
*/} +
+ ) +>>>>>>> 5b4aadf (add better-auth in hono) } diff --git a/apps/www/app/(auth)/sign-in/page.tsx b/apps/www/app/(auth)/sign-in/page.tsx index 3c16bea..1436750 100644 --- a/apps/www/app/(auth)/sign-in/page.tsx +++ b/apps/www/app/(auth)/sign-in/page.tsx @@ -1,3 +1,4 @@ +<<<<<<< HEAD import SignInComponent from "@/components/custom/signinComponent"; export default function page() { @@ -7,3 +8,10 @@ export default function page() { ); } +======= +import SignIn from "@/components/custom/Sign-In"; + +export default function page() { + return
+} +>>>>>>> 5b4aadf (add better-auth in hono) diff --git a/apps/www/app/(auth)/sign-up/page.tsx b/apps/www/app/(auth)/sign-up/page.tsx index 7a96bc3..e509f83 100644 --- a/apps/www/app/(auth)/sign-up/page.tsx +++ b/apps/www/app/(auth)/sign-up/page.tsx @@ -1,3 +1,4 @@ +<<<<<<< HEAD import SignUpComponent from "@/components/custom/signupComponent"; export default function page() { @@ -7,3 +8,15 @@ export default function page() { ); } +======= +import SignUp from "../../../components/custom/Sign-up"; + + +export default function page() { + return ( +
+ +
+ ) +} +>>>>>>> 5b4aadf (add better-auth in hono) diff --git a/apps/www/components/custom/Sign-In.tsx b/apps/www/components/custom/Sign-In.tsx new file mode 100644 index 0000000..f83b9c5 --- /dev/null +++ b/apps/www/components/custom/Sign-In.tsx @@ -0,0 +1,82 @@ +"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, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { authClient } from "@/lib/auth-client"; + +const formSchema = z.object({ + email: z.string().email(), + password: z.string().min(8), +}); + +export default function SignIn() { + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + email: "", + password: "", + }, + }); + const onSubmit = async (SignInData: z.infer) => { + const { data, error } = await authClient.signIn.email( + { + email: SignInData.email, + password: SignInData.password, + callbackURL: "/dashboard" + }, + { + onRequest: (ctx) => {}, + onSuccess: (ctx) => {}, + onError: (ctx) => { + alert(ctx.error.message); + }, + } + ); + }; + + return ( +
+ + ( + + email + + + + + + )} + /> + ( + + password + + + + + + )} + /> + + + + ); +} diff --git a/apps/www/components/custom/Sign-up.tsx b/apps/www/components/custom/Sign-up.tsx new file mode 100644 index 0000000..0f0eda7 --- /dev/null +++ b/apps/www/components/custom/Sign-up.tsx @@ -0,0 +1,98 @@ +"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 { Input } from "@/components/ui/input"; +import { authClient } from "@/lib/auth-client"; + +const formSchema = z.object({ + name: z.string(), + email: z.string().email(), + password: z.string().min(8), +}); + +export default function SignUp() { + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + email: "", + password: "", + }, + }); + const onSubmit = async(SignInData: z.infer) => { + const { data, error } = await authClient.signUp.email({ + name: SignInData.name, + email: SignInData.email, + password: SignInData.password + }, { + onRequest: (ctx) => { + + }, + onSuccess: (ctx) => { + + }, + onError: (ctx) => { + alert(ctx.error.message); + }, + }); + }; + + return ( +
+ + ( + + name + + + + + + )} + /> + ( + + email + + + + + + )} + /> + ( + + password + + + + + + )} + /> + + + + ); +} diff --git a/apps/www/components/custom/account-switcher.tsx b/apps/www/components/custom/account-switcher.tsx index be794c9..170d1a7 100644 --- a/apps/www/components/custom/account-switcher.tsx +++ b/apps/www/components/custom/account-switcher.tsx @@ -1,9 +1,14 @@ "use client"; +<<<<<<< HEAD import { authClient } from "../../lib/auth-client"; +======= +import { authClient } from "@/lib/auth-client"; +>>>>>>> 5b4aadf (add better-auth in hono) import { Session } from "@repo/auth"; import { useRouter } from "next/navigation"; interface Props { session: Session[]; +<<<<<<< HEAD activeSession: Session; } export default function AccountSwitcher({ session, activeSession }: Props) { @@ -35,3 +40,28 @@ export default function AccountSwitcher({ session, activeSession }: Props) { ); } +======= + activeSession : Session; +} +export default function AccountSwitcher({session,activeSession}:Props) { + const router = useRouter() + const onSelect = async (sessionId: string) => { + console.log(sessionId) + const active = await authClient.multiSession.setActive({ + sessionId: sessionId, + }); + + console.log(active) + router.refresh(); + }; + return ( +
+ +
+ ) +} +>>>>>>> 5b4aadf (add better-auth in hono) diff --git a/apps/www/components/ui/button.tsx b/apps/www/components/ui/button.tsx index d09a695..65d4fcd 100644 --- a/apps/www/components/ui/button.tsx +++ b/apps/www/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react"; -import { Slot } from "@radix-ui/react-slot"; -import { cva, type VariantProps } from "class-variance-authority"; +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" -import { cn } from "@/lib/utils"; +import { cn } from "@/lib/utils" const buttonVariants = cva( "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", @@ -31,27 +31,27 @@ const buttonVariants = cva( variant: "default", size: "default", }, - }, -); + } +) export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { - asChild?: boolean; + asChild?: boolean } const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button"; + const Comp = asChild ? Slot : "button" return ( - ); - }, -); -Button.displayName = "Button"; + ) + } +) +Button.displayName = "Button" -export { Button, buttonVariants }; +export { Button, buttonVariants } diff --git a/apps/www/components/ui/form.tsx b/apps/www/components/ui/form.tsx index c3daa38..cf2a56d 100644 --- a/apps/www/components/ui/form.tsx +++ b/apps/www/components/ui/form.tsx @@ -1,8 +1,16 @@ +<<<<<<< HEAD "use client"; import * as React from "react"; import * as LabelPrimitive from "@radix-ui/react-label"; import { Slot } from "@radix-ui/react-slot"; +======= +"use client" + +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { Slot } from "@radix-ui/react-slot" +>>>>>>> 5b4aadf (add better-auth in hono) import { Controller, ControllerProps, @@ -10,6 +18,7 @@ import { FieldValues, FormProvider, useFormContext, +<<<<<<< HEAD } from "react-hook-form"; import { cn } from "@/lib/utils"; @@ -31,6 +40,29 @@ const FormFieldContext = React.createContext( const FormField = < TFieldValues extends FieldValues = FieldValues, TName extends FieldPath = FieldPath, +======= +} from "react-hook-form" + +import { cn } from "@/lib/utils" +import { Label } from "@/components/ui/label" + +const Form = FormProvider + +type FormFieldContextValue< + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +> = { + name: TName +} + +const FormFieldContext = React.createContext( + {} as FormFieldContextValue +) + +const FormField = < + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +>>>>>>> 5b4aadf (add better-auth in hono) >({ ...props }: ControllerProps) => { @@ -38,6 +70,7 @@ const FormField = < +<<<<<<< HEAD ); }; @@ -53,6 +86,23 @@ const useFormField = () => { } const { id } = itemContext; +======= + ) +} + +const useFormField = () => { + const fieldContext = React.useContext(FormFieldContext) + const itemContext = React.useContext(FormItemContext) + const { getFieldState, formState } = useFormContext() + + const fieldState = getFieldState(fieldContext.name, formState) + + if (!fieldContext) { + throw new Error("useFormField should be used within ") + } + + const { id } = itemContext +>>>>>>> 5b4aadf (add better-auth in hono) return { id, @@ -61,6 +111,7 @@ const useFormField = () => { formDescriptionId: `${id}-form-item-description`, formMessageId: `${id}-form-item-message`, ...fieldState, +<<<<<<< HEAD }; }; @@ -71,26 +122,52 @@ type FormItemContextValue = { const FormItemContext = React.createContext( {} as FormItemContextValue, ); +======= + } +} + +type FormItemContextValue = { + id: string +} + +const FormItemContext = React.createContext( + {} as FormItemContextValue +) +>>>>>>> 5b4aadf (add better-auth in hono) const FormItem = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => { +<<<<<<< HEAD const id = React.useId(); +======= + const id = React.useId() +>>>>>>> 5b4aadf (add better-auth in hono) return (
+<<<<<<< HEAD ); }); FormItem.displayName = "FormItem"; +======= + ) +}) +FormItem.displayName = "FormItem" +>>>>>>> 5b4aadf (add better-auth in hono) const FormLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => { +<<<<<<< HEAD const { error, formItemId } = useFormField(); +======= + const { error, formItemId } = useFormField() +>>>>>>> 5b4aadf (add better-auth in hono) return (
); -======= - const session = await getSession() - const multipleSessions = await getMultipleSessions() - return ( -
- -
{JSON.stringify(session,null,1)}
- {/*
{JSON.stringify(multipleSessions,null,2)}
*/} -
- ) ->>>>>>> 5b4aadf (add better-auth in hono) } diff --git a/apps/www/app/(auth)/sign-in/page.tsx b/apps/www/app/(auth)/sign-in/page.tsx index 1436750..3c16bea 100644 --- a/apps/www/app/(auth)/sign-in/page.tsx +++ b/apps/www/app/(auth)/sign-in/page.tsx @@ -1,4 +1,3 @@ -<<<<<<< HEAD import SignInComponent from "@/components/custom/signinComponent"; export default function page() { @@ -8,10 +7,3 @@ export default function page() { ); } -======= -import SignIn from "@/components/custom/Sign-In"; - -export default function page() { - return
-} ->>>>>>> 5b4aadf (add better-auth in hono) diff --git a/apps/www/app/(auth)/sign-up/page.tsx b/apps/www/app/(auth)/sign-up/page.tsx index e509f83..7a96bc3 100644 --- a/apps/www/app/(auth)/sign-up/page.tsx +++ b/apps/www/app/(auth)/sign-up/page.tsx @@ -1,4 +1,3 @@ -<<<<<<< HEAD import SignUpComponent from "@/components/custom/signupComponent"; export default function page() { @@ -8,15 +7,3 @@ export default function page() { ); } -======= -import SignUp from "../../../components/custom/Sign-up"; - - -export default function page() { - return ( -
- -
- ) -} ->>>>>>> 5b4aadf (add better-auth in hono) diff --git a/apps/www/app/sign-in/[[...sign-in]]/layout.tsx b/apps/www/app/sign-in/[[...sign-in]]/layout.tsx deleted file mode 100644 index 6425796..0000000 --- a/apps/www/app/sign-in/[[...sign-in]]/layout.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { SiteFooter } from "@/components/custom/site/footer"; -import { SiteHeader } from "@/components/custom/site/header"; - -interface AppLayoutProps { - children: React.ReactNode; -} - -export default function AppLayout({ children }: AppLayoutProps) { - return ( -
- -
{children}
- -
- ); -} diff --git a/apps/www/app/sign-in/[[...sign-in]]/page.tsx b/apps/www/app/sign-in/[[...sign-in]]/page.tsx deleted file mode 100644 index 76e5c85..0000000 --- a/apps/www/app/sign-in/[[...sign-in]]/page.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { Button } from "@/components/ui/button"; -import { PiGithubLogoBold } from "react-icons/pi"; -import { SiDiscord } from "react-icons/si"; -import { FcGoogle } from "react-icons/fc"; -import { Input } from "@/components/ui/input"; -import Link from "next/link"; -export default function SignInPage() { - return ( -
-
-
-
-

- Transform how you work. -

-
- Log In Your Plura Account -
-
-
-
- - - -
-
-
-
- - Email - - - - - already a member - -
-
- {/* experiment here*/} -
-
-
- ); -} diff --git a/apps/www/components/custom/Sign-In.tsx b/apps/www/components/custom/Sign-In.tsx deleted file mode 100644 index f83b9c5..0000000 --- a/apps/www/components/custom/Sign-In.tsx +++ /dev/null @@ -1,82 +0,0 @@ -"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, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { authClient } from "@/lib/auth-client"; - -const formSchema = z.object({ - email: z.string().email(), - password: z.string().min(8), -}); - -export default function SignIn() { - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - email: "", - password: "", - }, - }); - const onSubmit = async (SignInData: z.infer) => { - const { data, error } = await authClient.signIn.email( - { - email: SignInData.email, - password: SignInData.password, - callbackURL: "/dashboard" - }, - { - onRequest: (ctx) => {}, - onSuccess: (ctx) => {}, - onError: (ctx) => { - alert(ctx.error.message); - }, - } - ); - }; - - return ( -
- - ( - - email - - - - - - )} - /> - ( - - password - - - - - - )} - /> - - - - ); -} diff --git a/apps/www/components/custom/Sign-up.tsx b/apps/www/components/custom/Sign-up.tsx deleted file mode 100644 index 0f0eda7..0000000 --- a/apps/www/components/custom/Sign-up.tsx +++ /dev/null @@ -1,98 +0,0 @@ -"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 { Input } from "@/components/ui/input"; -import { authClient } from "@/lib/auth-client"; - -const formSchema = z.object({ - name: z.string(), - email: z.string().email(), - password: z.string().min(8), -}); - -export default function SignUp() { - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - email: "", - password: "", - }, - }); - const onSubmit = async(SignInData: z.infer) => { - const { data, error } = await authClient.signUp.email({ - name: SignInData.name, - email: SignInData.email, - password: SignInData.password - }, { - onRequest: (ctx) => { - - }, - onSuccess: (ctx) => { - - }, - onError: (ctx) => { - alert(ctx.error.message); - }, - }); - }; - - return ( -
- - ( - - name - - - - - - )} - /> - ( - - email - - - - - - )} - /> - ( - - password - - - - - - )} - /> - - - - ); -} From b322450bb0e5dcad5b6f99b1096643f2e5a76e26 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 10 Nov 2024 11:06:58 +0000 Subject: [PATCH 10/16] chore: format code with Prettier --- apps/api/app/api/[[...route]]/mail.ts | 8 +- apps/api/app/api/[[...route]]/route.ts | 2 +- apps/www/app/(auth)/sign-up/page.tsx | 2 +- .../components/custom/account-switcher.tsx | 38 ++++-- apps/www/components/ui/button.tsx | 26 ++-- apps/www/components/ui/form.tsx | 103 +++++++------- apps/www/components/ui/label.tsx | 20 +-- apps/www/lib/auth-client.ts | 12 +- apps/www/lib/server.ts | 2 +- pnpm-lock.yaml | 128 +----------------- 10 files changed, 112 insertions(+), 229 deletions(-) diff --git a/apps/api/app/api/[[...route]]/mail.ts b/apps/api/app/api/[[...route]]/mail.ts index b70582d..48b8ddd 100644 --- a/apps/api/app/api/[[...route]]/mail.ts +++ b/apps/api/app/api/[[...route]]/mail.ts @@ -14,7 +14,7 @@ app { message: "Email sent failed", }, - 400 + 400, ); } return c.json( @@ -22,7 +22,7 @@ app message: "Email sent successfully", data, }, - 200 + 200, ); }) .get((c) => { @@ -41,7 +41,7 @@ app { message: "Email sent failed", }, - 400 + 400, ); } return c.json( @@ -49,7 +49,7 @@ app message: "All Email sent successfully", data, }, - 200 + 200, ); }) .get((c) => { diff --git a/apps/api/app/api/[[...route]]/route.ts b/apps/api/app/api/[[...route]]/route.ts index 0d9dbfc..be4f596 100644 --- a/apps/api/app/api/[[...route]]/route.ts +++ b/apps/api/app/api/[[...route]]/route.ts @@ -30,7 +30,7 @@ app.use( exposeHeaders: ["Content-Length"], maxAge: 600, credentials: true, - }) + }), ); app.options("/auth/**", (c) => { const origin = c.req.raw.headers.get("origin") ?? ""; diff --git a/apps/www/app/(auth)/sign-up/page.tsx b/apps/www/app/(auth)/sign-up/page.tsx index 7a96bc3..b6dcfaf 100644 --- a/apps/www/app/(auth)/sign-up/page.tsx +++ b/apps/www/app/(auth)/sign-up/page.tsx @@ -1,4 +1,4 @@ -import SignUpComponent from "@/components/custom/signupComponent"; +import SignUpComponent from "@/components/custom/signupComponent"; export default function page() { return ( diff --git a/apps/www/components/custom/account-switcher.tsx b/apps/www/components/custom/account-switcher.tsx index b321595..be794c9 100644 --- a/apps/www/components/custom/account-switcher.tsx +++ b/apps/www/components/custom/account-switcher.tsx @@ -4,26 +4,34 @@ import { Session } from "@repo/auth"; import { useRouter } from "next/navigation"; interface Props { session: Session[]; - activeSession : Session; + activeSession: Session; } -export default function AccountSwitcher({session,activeSession}:Props) { - const router = useRouter() +export default function AccountSwitcher({ session, activeSession }: Props) { + const router = useRouter(); const onSelect = async (sessionId: string) => { - console.log(sessionId) + console.log(sessionId); const active = await authClient.multiSession.setActive({ - sessionId: sessionId, + sessionId: sessionId, }); - - console.log(active) - router.refresh(); - }; + + console.log(active); + router.refresh(); + }; return (
- +
- ) + ); } diff --git a/apps/www/components/ui/button.tsx b/apps/www/components/ui/button.tsx index 65d4fcd..d09a695 100644 --- a/apps/www/components/ui/button.tsx +++ b/apps/www/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", @@ -31,27 +31,27 @@ const buttonVariants = cva( variant: "default", size: "default", }, - } -) + }, +); export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { - asChild?: boolean + asChild?: boolean; } const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button" + const Comp = asChild ? Slot : "button"; return ( - ) - } -) -Button.displayName = "Button" + ); + }, +); +Button.displayName = "Button"; -export { Button, buttonVariants } +export { Button, buttonVariants }; diff --git a/apps/www/components/ui/form.tsx b/apps/www/components/ui/form.tsx index b6daa65..c3daa38 100644 --- a/apps/www/components/ui/form.tsx +++ b/apps/www/components/ui/form.tsx @@ -1,8 +1,8 @@ -"use client" +"use client"; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" +import * as React from "react"; +import * as LabelPrimitive from "@radix-ui/react-label"; +import { Slot } from "@radix-ui/react-slot"; import { Controller, ControllerProps, @@ -10,27 +10,27 @@ import { FieldValues, FormProvider, useFormContext, -} from "react-hook-form" +} from "react-hook-form"; -import { cn } from "@/lib/utils" -import { Label } from "@/components/ui/label" +import { cn } from "@/lib/utils"; +import { Label } from "@/components/ui/label"; -const Form = FormProvider +const Form = FormProvider; type FormFieldContextValue< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TName extends FieldPath = FieldPath, > = { - name: TName -} + name: TName; +}; const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) + {} as FormFieldContextValue, +); const FormField = < TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TName extends FieldPath = FieldPath, >({ ...props }: ControllerProps) => { @@ -38,21 +38,21 @@ const FormField = < - ) -} + ); +}; const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState, formState } = useFormContext() + const fieldContext = React.useContext(FormFieldContext); + const itemContext = React.useContext(FormItemContext); + const { getFieldState, formState } = useFormContext(); - const fieldState = getFieldState(fieldContext.name, formState) + const fieldState = getFieldState(fieldContext.name, formState); if (!fieldContext) { - throw new Error("useFormField should be used within ") + throw new Error("useFormField should be used within "); } - const { id } = itemContext + const { id } = itemContext; return { id, @@ -61,36 +61,36 @@ const useFormField = () => { formDescriptionId: `${id}-form-item-description`, formMessageId: `${id}-form-item-message`, ...fieldState, - } -} + }; +}; type FormItemContextValue = { - id: string -} + id: string; +}; const FormItemContext = React.createContext( - {} as FormItemContextValue -) + {} as FormItemContextValue, +); const FormItem = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => { - const id = React.useId() + const id = React.useId(); return (
- ) -}) -FormItem.displayName = "FormItem" + ); +}); +FormItem.displayName = "FormItem"; const FormLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => { - const { error, formItemId } = useFormField() + const { error, formItemId } = useFormField(); return (