mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 10:12:09 +01:00
feat: complete development environment setup and code quality improvements
- Set up pre-commit hooks with husky and lint-staged for automated code quality - Improved TypeScript type safety by replacing 'any' types with proper generics - Fixed markdown linting violations (MD030 spacing) across all documentation - Fixed compound adjective hyphenation in technical documentation - Fixed invalid JSON union syntax in API documentation examples - Automated code formatting and linting on commit - Enhanced error handling with better type constraints - Configured biome and markdownlint for consistent code style - All changes verified with successful production build
This commit is contained in:
@ -156,7 +156,9 @@ function usePlatformDashboardState() {
|
||||
adminPassword: "",
|
||||
maxUsers: 10,
|
||||
});
|
||||
const [validationErrors, setValidationErrors] = useState<ValidationErrors>({});
|
||||
const [validationErrors, setValidationErrors] = useState<ValidationErrors>(
|
||||
{}
|
||||
);
|
||||
|
||||
return {
|
||||
dashboardData,
|
||||
@ -210,22 +212,23 @@ function useFormIds() {
|
||||
*/
|
||||
function validateEmail(email: string): string | undefined {
|
||||
if (!email) return undefined;
|
||||
|
||||
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
||||
|
||||
|
||||
const emailRegex =
|
||||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
||||
|
||||
if (!emailRegex.test(email)) {
|
||||
return "Please enter a valid email address";
|
||||
}
|
||||
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function validateUrl(url: string): string | undefined {
|
||||
if (!url) return undefined;
|
||||
|
||||
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
if (!['http:', 'https:'].includes(urlObj.protocol)) {
|
||||
if (!["http:", "https:"].includes(urlObj.protocol)) {
|
||||
return "URL must use HTTP or HTTPS protocol";
|
||||
}
|
||||
return undefined;
|
||||
@ -271,7 +274,7 @@ function renderCompanyFormFields(
|
||||
...prev,
|
||||
csvUrl: value,
|
||||
}));
|
||||
|
||||
|
||||
// Validate URL on change
|
||||
const error = validateUrl(value);
|
||||
setValidationErrors((prev) => ({
|
||||
@ -341,7 +344,7 @@ function renderCompanyFormFields(
|
||||
...prev,
|
||||
adminEmail: value,
|
||||
}));
|
||||
|
||||
|
||||
// Validate email on change
|
||||
const error = validateEmail(value);
|
||||
setValidationErrors((prev) => ({
|
||||
@ -683,13 +686,12 @@ export default function PlatformDashboard() {
|
||||
newCompanyData.adminEmail &&
|
||||
newCompanyData.adminName
|
||||
);
|
||||
|
||||
|
||||
// Check for validation errors
|
||||
const hasValidationErrors = !!(
|
||||
validationErrors.csvUrl ||
|
||||
validationErrors.adminEmail
|
||||
validationErrors.csvUrl || validationErrors.adminEmail
|
||||
);
|
||||
|
||||
|
||||
return hasRequiredFields && !hasValidationErrors;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user