CEC-1965 Supplier update and approval (#162)

* CEC-1965 Supplier update and approval
Fix calling connectedcars for no VINs
Search sets table page to 0

* PR comments
This commit is contained in:
John Wu
2022-07-01 12:39:21 -07:00
committed by GitHub
parent d9cbf9ef23
commit fe40c26c56
23 changed files with 1883 additions and 82 deletions

View File

@@ -0,0 +1,37 @@
import validator from "email-validator";
export const validateSupplier = (supplier) => {
if (supplier == null) {
throw new Error("No supplier data");
}
validateEmail(supplier.email);
if (supplier.contact.length === 0) {
throw new Error("contact required");
}
if (supplier.company.length === 0) {
throw new Error("company required");
}
if (supplier.address.length === 0) {
throw new Error("address required");
}
if (supplier.telephone.length === 0) {
throw new Error("telephone required");
}
if (supplier.program.length === 0) {
throw new Error("program required");
}
if (supplier.ecus.length === 0) {
throw new Error("ecus required");
}
};
export const validateEmail = (email) => {
if (!validator.validate(email)) throw new Error("invalid email");
};