- {!showWelcome &&
}
- {showWelcome &&
}
-
+ );
}
diff --git a/frontend/src/pages/Register.tsx b/frontend/src/pages/Register.tsx
index aa711dd..feb75c7 100644
--- a/frontend/src/pages/Register.tsx
+++ b/frontend/src/pages/Register.tsx
@@ -14,170 +14,171 @@ import { ROUTES } from "../config/routes";
import { CryptoUtils } from "../utils/crypto";
const registerSchema = z
- .object({
- full_name: z.string().min(2, "Name must be at least 2 characters"),
- email: z.email("Please enter a valid email"),
- password: z.string().min(8, "Password must be at least 8 characters"),
- confirm_password: z.string(),
- })
- .refine((data) => data.password === data.confirm_password, {
- message: "Passwords don't match",
- path: ["confirm_password"],
- });
+ .object({
+ full_name: z.string().min(2, "Name must be at least 2 characters"),
+ email: z.email("Please enter a valid email"),
+ password: z.string().min(8, "Password must be at least 8 characters"),
+ confirm_password: z.string(),
+ })
+ .refine((data) => data.password === data.confirm_password, {
+ message: "Passwords don't match",
+ path: ["confirm_password"],
+ });
type RegisterInputs = z.infer
;
export default function Register() {
- const navigate = useNavigate();
- const [isLoading, setIsLoading] = useState(false);
- const [apiError, setApiError] = useState(null);
- const [saajanMessage, setSaajanMessage] = useState(
- "I didn't think I'd be here either.\nAnd yet, here we are.",
- );
+ const navigate = useNavigate();
+ const [isLoading, setIsLoading] = useState(false);
+ const [apiError, setApiError] = useState(null);
+ const [saajanMessage, setSaajanMessage] = useState(
+ "I didn't think I'd be here either.\nAnd yet, here we are.",
+ );
- const {
- register,
- handleSubmit,
- formState: { errors },
- } = useForm({
- resolver: zodResolver(registerSchema),
- });
+ const {
+ register,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(registerSchema),
+ });
- const onSubmit = async (data: RegisterInputs) => {
- setSaajanMessage("Good. I'll remember that.");
- setIsLoading(true);
- setApiError(null);
- try {
- // we generate the key bundle here to get the authHash (password) to be haSHed and stored in the db.
- const { authHash } = await CryptoUtils.deriveKeyBundle(
- data.password,
- data.email,
- );
+ const onSubmit = async (data: RegisterInputs) => {
+ setSaajanMessage("Good. I'll remember that.");
+ setIsLoading(true);
+ setApiError(null);
+ try {
+ // we generate the key bundle here to get the authHash (password) to be haSHed and stored in the db.
+ const { authHash } = await CryptoUtils.deriveKeyBundle(
+ data.password,
+ data.email,
+ );
- await publicApi.post(endpoints.REGISTER, {
- full_name: data.full_name,
- email: data.email,
- password: authHash,
- });
- navigate(ROUTES.VERIFY_EMAIL, { replace: true });
- } catch (err) {
- let message = "Registration failed. Please try again.";
- if (axios.isAxiosError(err)) {
- message = err.response?.data?.message || message;
- }
- setApiError(message);
- } finally {
- setIsLoading(false);
- }
- };
+ await publicApi.post(endpoints.REGISTER, {
+ full_name: data.full_name,
+ email: data.email,
+ password: authHash,
+ });
+ navigate(ROUTES.VERIFY_EMAIL, { replace: true });
+ } catch (err) {
+ let message = "Registration failed. Please try again.";
+ if (axios.isAxiosError(err)) {
+ message = err.response?.data?.message || message;
+ }
+ setApiError(message);
+ } finally {
+ setIsLoading(false);
+ }
+ };
- return (
-
-
-
-
+ );
}