Skip to content

Commit

Permalink
Fixed sign-up page (#140)
Browse files Browse the repository at this point in the history
* fix: added necessary fixes to fix the deployment

* feat: added addtl. user information for the user management endpoint

* feat: added addtl. user information for the user management endpoint

* fix: fixed signup page

* refactor: changed the label for confirm password
  • Loading branch information
SchadenKai authored Sep 24, 2024
1 parent 74d1738 commit 4fac85d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
5 changes: 2 additions & 3 deletions web/src/app/auth/login/LoginText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ export const LoginText = () => {
return (
<div>
<h1 className="my-2 text-2xl xl:text-3xl font-bold text-center text-dark-900">
Welcome Back to Arnold Ai
Welcome Back to {settings.workspaces?.workspace_name || "Arnold Ai"}
</h1>
<p className="text-center text-sm text-subtle">
Welcome back to ! Please enter your details Welcome back! Please enter
your details.
Welcome back! Please enter your details.
</p>
</div>
);
Expand Down
37 changes: 11 additions & 26 deletions web/src/app/auth/signup/SignupForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { Label } from "@/components/ui/label";
export function SignupForms({ shouldVerify }: { shouldVerify?: boolean }) {
const router = useRouter();
const { toast } = useToast();
const [isWorking, setIsWorking] = useState(false);
const [isLoading, setIsLoading] = useState(false);

return (
<>
{isWorking && <Spinner />}
{isLoading && <Spinner />}
<Formik
initialValues={{
full_name: "",
Expand All @@ -39,14 +39,15 @@ export function SignupForms({ shouldVerify }: { shouldVerify?: boolean }) {
.oneOf([Yup.ref("password")], "Passwords must match"),
})}
onSubmit={async (values) => {
setIsWorking(true);
setIsLoading(true);
const response = await basicSignup(
values.full_name,
values.company_name,
values.email,
values.password
);
if (!response.ok) {
setIsLoading(false);
const errorDetail = (await response.json()).detail;

let errorMsg = "Unknown error";
Expand All @@ -60,28 +61,6 @@ export function SignupForms({ shouldVerify }: { shouldVerify?: boolean }) {
});
return;
}
const loginResponse = await basicLogin(values.email, values.password);
if (loginResponse.ok) {
if (shouldVerify) {
await requestEmailVerification(values.email);
router.push("/auth/waiting-on-verification");
} else {
router.push("/");
}
} else {
setIsWorking(false);
const errorDetail = (await loginResponse.json()).detail;

let errorMsg = "Unknown error";
if (errorDetail === "LOGIN_BAD_CREDENTIALS") {
errorMsg = "Invalid email or password";
}
toast({
title: "Error",
description: `Failed to login - ${errorMsg}`,
variant: "destructive",
});
}
}}
>
{({ isSubmitting, values }) => (
Expand All @@ -92,6 +71,12 @@ export function SignupForms({ shouldVerify }: { shouldVerify?: boolean }) {
type="text"
placeholder="Enter your full name"
/>
<TextFormField
name="company_name"
label="Company Name"
type="text"
placeholder="Enter your company name"
/>
<TextFormField
name="email"
label="Email"
Expand All @@ -105,7 +90,7 @@ export function SignupForms({ shouldVerify }: { shouldVerify?: boolean }) {
placeholder="Enter your password"
/>
<TextFormField
name="retype_password"
name="confirm_password"
label="Retype Password"
type="password"
placeholder="Enter your password"
Expand Down

0 comments on commit 4fac85d

Please sign in to comment.