diff --git a/app/src/app/login/LoginClient.tsx b/app/src/app/login/LoginClient.tsx new file mode 100644 index 0000000..d46e98c --- /dev/null +++ b/app/src/app/login/LoginClient.tsx @@ -0,0 +1,94 @@ +"use client"; + +import Link from "next/link"; +import { useForm } from "react-hook-form"; +import { useRouter } from "next/navigation"; +import Cookies from "js-cookie"; +import { toast } from "sonner"; +import MusicLoader from "@/components/MusicLoader"; +import useAuthServices from "@/services/authService"; +import { LoginEmailPayload } from "@/types"; + +export default function LoginClient() { + const router = useRouter(); + const { useLoginEmail } = useAuthServices(); + const loginMutation = useLoginEmail(); + + const { + register, + handleSubmit, + formState: { errors, isSubmitting }, + } = useForm(); + + const onSubmit = async (data: LoginEmailPayload) => { + try { + const result = await loginMutation.mutateAsync(data); + Cookies.set("audioblocks_jwt", result.token); + toast.success("Logged in successfully!"); + router.push("/dashboard"); + } catch (err) { + // onError on the mutation already toasts the message + } + }; + + const isBusy = isSubmitting || loginMutation.isPending; + + return ( +
+
+
+

Log in

+

Welcome back to AudioBlocks.

+
+ +
+
+ + + {errors.email && ( + {errors.email.message} + )} +
+ +
+ + + {errors.password && ( + {errors.password.message} + )} +
+ + +
+ +

+ Don't have an account?{" "} + + Sign up + +

+
+
+ ); +} diff --git a/app/src/app/login/page.tsx b/app/src/app/login/page.tsx index 4f95396..3930f78 100644 --- a/app/src/app/login/page.tsx +++ b/app/src/app/login/page.tsx @@ -1,94 +1,12 @@ -"use client"; +import type { Metadata } from "next"; +import LoginClient from "./LoginClient"; -import Link from "next/link"; -import { useForm } from "react-hook-form"; -import { useRouter } from "next/navigation"; -import Cookies from "js-cookie"; -import { toast } from "sonner"; -import MusicLoader from "@/components/MusicLoader"; -import useAuthServices from "@/services/authService"; -import { LoginEmailPayload } from "@/types"; +export const metadata: Metadata = { + title: "Log in | AudioBlocks", + description: + "Log in to AudioBlocks to manage your music, earnings, and fan engagement from the artist dashboard.", +}; export default function LoginPage() { - const router = useRouter(); - const { useLoginEmail } = useAuthServices(); - const loginMutation = useLoginEmail(); - - const { - register, - handleSubmit, - formState: { errors, isSubmitting }, - } = useForm(); - - const onSubmit = async (data: LoginEmailPayload) => { - try { - const result = await loginMutation.mutateAsync(data); - Cookies.set("audioblocks_jwt", result.token); - toast.success("Logged in successfully!"); - router.push("/dashboard"); - } catch (err) { - // onError on the mutation already toasts the message - } - }; - - const isBusy = isSubmitting || loginMutation.isPending; - - return ( -
-
-
-

Log in

-

Welcome back to AudioBlocks.

-
- -
-
- - - {errors.email && ( - {errors.email.message} - )} -
- -
- - - {errors.password && ( - {errors.password.message} - )} -
- - -
- -

- Don't have an account?{" "} - - Sign up - -

-
-
- ); + return ; } diff --git a/app/src/app/signup/SignupClient.tsx b/app/src/app/signup/SignupClient.tsx new file mode 100644 index 0000000..93465f6 --- /dev/null +++ b/app/src/app/signup/SignupClient.tsx @@ -0,0 +1,120 @@ +"use client"; + +import Link from "next/link"; +import { useForm } from "react-hook-form"; +import { useRouter } from "next/navigation"; +import Cookies from "js-cookie"; +import { toast } from "sonner"; +import MusicLoader from "@/components/MusicLoader"; +import useAuthServices from "@/services/authService"; +import { RegisterEmailPayload } from "@/types"; + +type SignupFormValues = Omit; + +export default function SignupClient() { + const router = useRouter(); + const { useRegisterEmail } = useAuthServices(); + const registerMutation = useRegisterEmail(); + + const { + register, + handleSubmit, + formState: { errors, isSubmitting }, + } = useForm(); + + // This app is the artist dashboard, so every signup here is an artist account. + const onSubmit = async (data: SignupFormValues) => { + try { + const result = await registerMutation.mutateAsync({ ...data, role: "artist" }); + Cookies.set("audioblocks_jwt", result.token); + toast.success("Account created successfully!"); + router.push("/dashboard"); + } catch (err) { + // onError on the mutation already toasts the message + } + }; + + const isBusy = isSubmitting || registerMutation.isPending; + + return ( +
+
+
+

Create your artist account

+

Join AudioBlocks to upload and manage your music.

+
+ +
+
+ + +
+ +
+ + +
+ +
+ + + {errors.email && ( + {errors.email.message} + )} +
+ +
+ + + {errors.password && ( + {errors.password.message} + )} +
+ + +
+ +

+ Already have an account?{" "} + + Log in + +

+
+
+ ); +} diff --git a/app/src/app/signup/page.tsx b/app/src/app/signup/page.tsx index 12ffc87..a2a4e48 100644 --- a/app/src/app/signup/page.tsx +++ b/app/src/app/signup/page.tsx @@ -1,120 +1,12 @@ -"use client"; +import type { Metadata } from "next"; +import SignupClient from "./SignupClient"; -import Link from "next/link"; -import { useForm } from "react-hook-form"; -import { useRouter } from "next/navigation"; -import Cookies from "js-cookie"; -import { toast } from "sonner"; -import MusicLoader from "@/components/MusicLoader"; -import useAuthServices from "@/services/authService"; -import { RegisterEmailPayload } from "@/types"; - -type SignupFormValues = Omit; +export const metadata: Metadata = { + title: "Sign up | AudioBlocks", + description: + "Create an AudioBlocks artist account to upload music and manage your releases, earnings, and fans.", +}; export default function SignupPage() { - const router = useRouter(); - const { useRegisterEmail } = useAuthServices(); - const registerMutation = useRegisterEmail(); - - const { - register, - handleSubmit, - formState: { errors, isSubmitting }, - } = useForm(); - - // This app is the artist dashboard, so every signup here is an artist account. - const onSubmit = async (data: SignupFormValues) => { - try { - const result = await registerMutation.mutateAsync({ ...data, role: "artist" }); - Cookies.set("audioblocks_jwt", result.token); - toast.success("Account created successfully!"); - router.push("/dashboard"); - } catch (err) { - // onError on the mutation already toasts the message - } - }; - - const isBusy = isSubmitting || registerMutation.isPending; - - return ( -
-
-
-

Create your artist account

-

Join AudioBlocks to upload and manage your music.

-
- -
-
- - -
- -
- - -
- -
- - - {errors.email && ( - {errors.email.message} - )} -
- -
- - - {errors.password && ( - {errors.password.message} - )} -
- - -
- -

- Already have an account?{" "} - - Log in - -

-
-
- ); + return ; }