Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
- minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
mertthesamael committed Sep 13, 2023
1 parent ec4e7d0 commit 9e6aaf1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions actions/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export const signupHandler = async (formData: FormData) => {
};
} catch (err) {
console.log(err, "2313213123");
return {
fail:true
};
} finally {
prisma.$disconnect();
}
Expand Down
13 changes: 9 additions & 4 deletions components/Forms/SignupForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ const SignupForm: FC<SignupFormProps> = ({}) => {
const router = useRouter();
const clientAction = async (formData: FormData) => {
const data = await signupHandler(formData);
console.log(data,'annnnennn')

if (data?.error) {
toast.error(data.error.message);
if (data?.error||data.fail) {
data.error&&toast.error(data.error.message);
data.fail&&toast.error('Something went wrong.');
}
else if(data?.data?.user){
toast.success('Your account is created, please check your email.')
router.push("/auth/login");
};
}
data?.data.user && router.push("/auth/login");
};
return (
<form
action={clientAction}
Expand Down
2 changes: 1 addition & 1 deletion components/MobileMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const MobileMenu: FC<MobileMenuProps> = ({}) => {
<>
<li>
<Link
href={"/chcekout"}
href={"/checkout"}
className="text-black text-lg font-bold flex gap-4"
>
Basket{" "}
Expand Down
1 change: 1 addition & 0 deletions containers/product-page/item-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const ItemSection: FC<ItemSectionProps> = ({ item }) => {
},
});
if (data) {
toast.success(item.name+'Successfully added to your basket!')
return handleUser(data.result);
} else {
return toast.error("Something Went Wrong");
Expand Down

0 comments on commit 9e6aaf1

Please sign in to comment.