-
- A link has been sent to your email. Please check both your
+
+
+
Email sent!
+
+ We have sent a confirmation email to {fields.email}. Please check both
+ your
spam and your inbox.
-
- If our email is in your spam, do make sure you mark our email address
- as safe, then move it from your spam to your inbox.
-
{:else}
Create a free account
+ {#if submitError}
+
{submitError}
+ {/if}
@@ -126,12 +145,11 @@
{#if !success}
{/if}
diff --git a/src/utils/constants/authentication.js b/src/utils/constants/authentication.js
new file mode 100644
index 00000000..744491e2
--- /dev/null
+++ b/src/utils/constants/authentication.js
@@ -0,0 +1,6 @@
+export const SIGNUP_FIELDS = {
+ name: '',
+ email: '',
+ password: '',
+ confirmPassword: '',
+};
diff --git a/src/utils/functions/validator.js b/src/utils/functions/validator.js
new file mode 100644
index 00000000..a53661d9
--- /dev/null
+++ b/src/utils/functions/validator.js
@@ -0,0 +1,43 @@
+import z from 'zod';
+
+const validationSchema = z.object({
+ name: z.string().min(3, {
+ message: 'Must be 3 or more characters long',
+ invalid_type_error: 'Must not be empty',
+ }),
+ email: z.string().email({
+ message: 'Invalid email address',
+ invalid_type_error: 'Must not be empty',
+ }),
+ password: z.string().min(6, {
+ message: 'Must be 6 or more characters long',
+ invalid_type_error: 'Must not be empty',
+ }),
+});
+
+export const getConfirmPasswordError = ({ password, confirmPassword }) => {
+ return password > 6 && confirmPassword > 6 && password !== confirmPassword
+ ? 'Does not match password'
+ : null;
+};
+
+export const signUpValidation = (fields = {}) => {
+ const { error } = validationSchema.safeParse(fields);
+ const errors = {};
+
+ if (Array.isArray(error?.issues)) {
+ for (const issue of error.issues) {
+ const { message, path } = issue;
+ console.log(issue);
+ if (path.length) {
+ errors[path[0]] = message;
+ }
+ }
+ }
+
+ return errors;
+};
+
+export const getDisableSubmit = ({ password, confirmPassword }) => {
+ return !!(password && confirmPassword && password !== confirmPassword);
+};