Skip to content

Commit

Permalink
cleaned up auth slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnafnafee committed Mar 7, 2022
1 parent deff3e2 commit 96670f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
18 changes: 14 additions & 4 deletions components/SignIn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import {
Button,
Flex,
FormControl,
FormErrorMessage,
FormLabel,
Expand All @@ -12,15 +11,26 @@ import {
import { useFormik } from "formik";
import * as Yup from "yup";
import { useRouter } from "next/router";
import { useSignIn } from "@clerk/clerk-react";
import { supabaseClient } from "../lib/client";
import { useToast } from "@chakra-ui/react";

export default function SignIn() {
const router = useRouter();
const [show, setShow] = React.useState(false);
const [isFocused, setIsFocused] = React.useState(false);
const toast = useToast();
const handleClick = () => setShow(!show);

const toastMsg = (desc) => {
return toast({
title: "Failed",
description: desc,
status: "error",
duration: 1000,
isClosable: true,
});
};

const {
touched,
errors,
Expand Down Expand Up @@ -58,12 +68,12 @@ export default function SignIn() {
password: values.password,
});
if (error) {
toastMsg(error.message);
console.log(error);
}
} catch (error) {
console.log(error);
console.log("Error", error);
}
// router.push("/library");
},
});

Expand Down
29 changes: 13 additions & 16 deletions components/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { useFormik } from "formik";
import * as Yup from "yup";
import { useRouter } from "next/router";
import { useSignUp } from "@clerk/clerk-react";
import { useToast } from "@chakra-ui/react";
import { supabaseClient } from "../lib/client";
import { useState } from "react";

Expand All @@ -23,6 +23,17 @@ export default function SignUp() {
const handleClick = () => setShow(!show);
const [isLoading, setIsLoading] = useState(false);
const [isSubmitted, setIsSubmitted] = useState(false);
const toast = useToast();

const toastMsg = (desc) => {
return toast({
title: "Failed",
description: desc,
status: "error",
duration: 1000,
isClosable: true,
});
};

const {
touched,
Expand Down Expand Up @@ -69,8 +80,8 @@ export default function SignUp() {
}
);
if (error) {
toastMsg(error.message);
console.log(error);
setError(error.message);
} else {
setIsSubmitted(true);
}
Expand All @@ -80,20 +91,6 @@ export default function SignUp() {
} finally {
setIsLoading(false);
}
// await signUp
// .create({
// firstName: values.name,
// lastName: "",
// emailAddress: values.email,
// password: values.password,
// })
// .then(() => {
// console.log("Success");
// })
// .catch((error) => {
// console.log(error);
// });
// router.push("/library");
},
});

Expand Down

1 comment on commit 96670f0

@vercel
Copy link

@vercel vercel bot commented on 96670f0 Mar 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks for Deployment have failed

Please sign in to comment.