Making everything look pretty

This commit is contained in:
2019-10-01 20:39:21 -04:00
parent 07e9271132
commit c218081759
9 changed files with 274 additions and 260 deletions

View File

@@ -1,5 +1,4 @@
const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();

View File

@@ -6,4 +6,4 @@ module.exports = {
storageBucket: "twistter-e4649.appspot.com",
messagingSenderId: "20131817365",
appId: "1:20131817365:web:633c95fb08b16d4526b89c"
};
};

View File

@@ -1,36 +1,36 @@
const isEmpty = (str) => {
if (str.trim() === '') return true;
else return false;
const isEmail = (str) => {
const emailRegEx = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (str.match(emailRegEx)) return true;
else return false;
};
const isEmail = (str) => {
const emailRegEx = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (str.match(emailRegEx)) return true;
else return false;
}
const isEmpty = (str) => {
if (str.trim() === "") return true;
else return false;
};
exports.validateUpdateProfileInfo = (data) => {
let errors = {};
let profileData = {};
let errors = {};
let profileData = {};
// ?: Should users be able to change their handles and emails?
// ?: Should users be able to change their handles and emails?
// Only adds the key to the DB if the values are not empty
if (!isEmpty(data.firstName)) profileData.firstName = data.firstName.trim();
if (!isEmpty(data.lastName)) profileData.lastName = data.lastName.trim();
if (!isEmpty(data.bio)) profileData.bio = data.bio.trim();
// Only adds the key to the database if the values are not empty
if (!isEmpty(data.firstName)) profileData.firstName = data.firstName.trim();
if (!isEmpty(data.lastName)) profileData.lastName = data.lastName.trim();
if (!isEmpty(data.bio)) profileData.bio = data.bio.trim();
if (isEmpty(data.email)) {
errors.email = "Must not be empty.";
} else if (!isEmail(data.email)) {
errors.email = "Must be a valid email."
} else {
profileData.email = data.email;
}
if (isEmpty(data.email)) {
errors.email = "Must not be empty.";
} else if (!isEmail(data.email)) {
errors.email = "Must be a valid email.";
} else {
profileData.email = data.email;
}
return {
errors,
valid: Object.keys(errors).length === 0 ? true : false,
profileData
}
};
return {
errors,
valid: Object.keys(errors).length === 0 ? true : false,
profileData
};
};