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

@@ -1,13 +1,14 @@
export const ts2DateTime = (timestamp) => {
return new Date(timestamp * 1000);
}
};
export const tsLocalDateTimeString = (timestamp) => {
const date = ts2DateTime(timestamp);
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
}
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
};
export const LocalDateTimeString = (datestring) => {
const date = new Date(datestring.replace(' ', 'T'));
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
}
if (!datestring) return "";
const date = new Date(datestring.replace(" ", "T"));
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
};

View File

@@ -5,6 +5,7 @@ export const Roles = {
CREATE: "efcc3025-e2d8-4212-8227-805c7be39d2c",
DELETE: "8f78dce7-f5f9-4033-a10c-c9c7408bfcfe",
CERTIFICATES: "746f34b0-9ba0-4b5d-8d84-0256a9c8e390",
APPROVESUPPLIERS: "a6c9805e-80b2-42b2-bfbb-9df52e5504d8",
};
export const hasRoleToken = (roles, token) => {

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");
};