bugfix - better routing

This commit is contained in:
James Wyndham 2024-06-05 10:06:50 +08:00
parent 0ba99e14eb
commit 2157edd2f0
4 changed files with 61 additions and 20 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
Backend/.DS_Store vendored

Binary file not shown.

View File

@ -1,3 +1,5 @@
"use client";
import React from "react"; import React from "react";
import Icon from "@/components/Icons/Icon"; import Icon from "@/components/Icons/Icon";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
@ -5,9 +7,11 @@ import { yupResolver } from "@hookform/resolvers/yup";
import { signInValidationSchema } from "@/utils/form"; import { signInValidationSchema } from "@/utils/form";
import { login } from "@/app/actions"; import { login } from "@/app/actions";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
import pb from "@/lib/pocketbase"; import { useRouter } from "next/navigation";
function ModalSignIn() { function ModalSignIn() {
const router = useRouter();
const { const {
register, register,
handleSubmit, handleSubmit,
@ -25,6 +29,7 @@ function ModalSignIn() {
) { ) {
reset(); reset();
document.getElementById("sign-in-modal")?.click(); document.getElementById("sign-in-modal")?.click();
router.push("/account");
} }
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
@ -96,14 +101,31 @@ function ModalSignIn() {
</div> </div>
<div className="flex flex-row w-full justify-between"> <div className="flex flex-row w-full justify-between">
<button <div className="flex flex-row gap-x-4">
disabled={isSubmitting} <button
type="submit" disabled={isSubmitting}
className="btn btn-primary" type="submit"
> className="btn btn-primary"
Sign In >
{isSubmitting && <div className="loading"></div>} Sign In
</button> {isSubmitting && <div className="loading"></div>}
</button>
<div className=" text-xs w-28 block">
<span className="whitespace-normal">
Dont have an account?{" "}
</span>
<span
onClick={() => {
document.getElementById("sign-in-modal")?.click();
document.getElementById("sign-up-modal")?.click();
}}
className="text-primary hover:text-primary/60 cursor-pointer "
>
Sign up
</span>
</div>
</div>
<button <button
onClick={() => onClick={() =>
document.getElementById("password-reset-modal")?.click() document.getElementById("password-reset-modal")?.click()

View File

@ -79,7 +79,9 @@ function ModalSignUp({
setUser(user as User); setUser(user as User);
console.log("price", price); console.log("price", price);
console.log("type", type); console.log("type", type);
price && generateCheckoutPage(JSON.parse(price), type ?? ""); price
? generateCheckoutPage(JSON.parse(price), type ?? "")
: router.push("/account");
} }
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
@ -128,10 +130,10 @@ function ModalSignUp({
<div className="flex flex-grow flex-col h-[30rem] lg:h-full overflow-y-scroll"> <div className="flex flex-grow flex-col h-[30rem] lg:h-full overflow-y-scroll">
<div className="w-[100%] bg-gradient-to-r from-primary to-secondary px-6 mt-3 pb-6 rounded-lg text-primary-content"> <div className="w-[100%] bg-gradient-to-r from-primary to-secondary px-6 mt-3 pb-6 rounded-lg text-primary-content">
<h3 className="pb-1 text-3xl font-bold md:text-3xl pt-6"> <h3 className="pb-1 text-3xl font-bold md:text-3xl pt-6">
We Are Growing Fast, and We Want You To Join The Party! Want to 10X Your Content Game?
</h3> </h3>
<p className="text-sm md:text-base"> <p className="text-sm md:text-base">
Excited to see what we&apos;ve got! Signup and get started! Signup and get started using YoutubeTo.Social!
</p> </p>
</div> </div>
<form onSubmit={handleSubmit(onSubmit)} className="w-full pl-1"> <form onSubmit={handleSubmit(onSubmit)} className="w-full pl-1">
@ -244,14 +246,31 @@ function ModalSignUp({
</div> </div>
</div> </div>
<button <div className="flex flex-row items-center gap-x-4">
disabled={isSubmitting} <button
type="submit" disabled={isSubmitting}
className="btn btn-primary" type="submit"
> className="btn btn-primary"
Sign Up >
{isSubmitting && <div className="loading"></div>} Sign Up
</button> {isSubmitting && <div className="loading"></div>}
</button>
<div className=" text-xs w-28 block">
<span className="whitespace-normal">
Already have an account?{" "}
</span>
<span
onClick={() => {
document.getElementById("sign-up-modal")?.click();
document.getElementById("sign-in-modal")?.click();
}}
className="text-primary hover:text-primary/60 cursor-pointer "
>
Sign in
</span>
</div>
</div>
</form> </form>
</div> </div>
</label> </label>