Enhance ESLint configuration and improve code consistency
- Added '@typescript-eslint/no-unused-vars' rule to ESLint configuration for better variable management in TypeScript files. - Updated database.ts to ensure consistent logging format. - Refactored AuthController and CashflowController to improve variable naming and maintainability. - Added spacing for better readability in multiple controller methods. - Adjusted error handling in middleware and repository files for improved clarity. - Enhanced various service and repository methods to ensure consistent return types and error handling. - Made minor formatting adjustments across frontend components for improved user experience.
This commit is contained in:
@@ -35,6 +35,7 @@ export default function AddAssetDialog({open, onOpenChange}: Props) {
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useState} from 'react';
|
||||
import {useState, useEffect} from 'react';
|
||||
import {Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle} from '@/components/ui/dialog';
|
||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/components/ui/select';
|
||||
import {Button} from '@/components/ui/button';
|
||||
@@ -11,6 +11,10 @@ interface Props {
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}
|
||||
|
||||
function getDefaultDueDate(): string {
|
||||
return new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
export default function AddInvoiceDialog({open, onOpenChange}: Props) {
|
||||
const dispatch = useAppDispatch();
|
||||
const {clients} = useAppSelector(state => state.invoices);
|
||||
@@ -18,9 +22,17 @@ export default function AddInvoiceDialog({open, onOpenChange}: Props) {
|
||||
clientId: '',
|
||||
description: '',
|
||||
amount: '',
|
||||
dueDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0]
|
||||
dueDate: getDefaultDueDate()
|
||||
});
|
||||
|
||||
// Reset form with fresh due date when dialog opens
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional pattern for form dialog
|
||||
setForm(prev => ({...prev, dueDate: getDefaultDueDate()}));
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const now = new Date().toISOString();
|
||||
@@ -52,7 +64,7 @@ export default function AddInvoiceDialog({open, onOpenChange}: Props) {
|
||||
})
|
||||
);
|
||||
onOpenChange(false);
|
||||
setForm({clientId: '', description: '', amount: '', dueDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0]});
|
||||
setForm({clientId: '', description: '', amount: '', dueDate: getDefaultDueDate()});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -20,8 +20,10 @@ export default function EditAssetDialog({open, onOpenChange, asset}: Props) {
|
||||
const [form, setForm] = useState({name: '', type: '', value: ''});
|
||||
const [errors, setErrors] = useState({name: '', value: ''});
|
||||
|
||||
// Sync form state when asset changes - intentional pattern for controlled form dialogs
|
||||
useEffect(() => {
|
||||
if (asset) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional pattern for form dialog
|
||||
setForm({
|
||||
name: asset.name,
|
||||
type: asset.type,
|
||||
@@ -47,6 +49,7 @@ export default function EditAssetDialog({open, onOpenChange, asset}: Props) {
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@ export default function EditClientDialog({open, onOpenChange, client}: Props) {
|
||||
});
|
||||
const [errors, setErrors] = useState({name: '', email: '', phone: ''});
|
||||
|
||||
// Sync form state when client changes - intentional pattern for controlled form dialogs
|
||||
useEffect(() => {
|
||||
if (client) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional pattern for form dialog
|
||||
setForm({
|
||||
name: client.name,
|
||||
email: client.email,
|
||||
@@ -58,6 +60,7 @@ export default function EditClientDialog({open, onOpenChange, client}: Props) {
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@ export default function EditLiabilityDialog({open, onOpenChange, liability}: Pro
|
||||
const [form, setForm] = useState({name: '', type: '', balance: ''});
|
||||
const [errors, setErrors] = useState({name: '', balance: ''});
|
||||
|
||||
// Sync form state when liability changes - intentional pattern for controlled form dialogs
|
||||
useEffect(() => {
|
||||
if (liability) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional pattern for form dialog
|
||||
setForm({
|
||||
name: liability.name,
|
||||
type: liability.type,
|
||||
@@ -47,6 +49,7 @@ export default function EditLiabilityDialog({open, onOpenChange, liability}: Pro
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ export default function InvoiceDetailsDialog({open, onOpenChange, invoice, clien
|
||||
const dispatch = useAppDispatch();
|
||||
const [selectedStatus, setSelectedStatus] = useState<Invoice['status']>('draft');
|
||||
|
||||
// Sync status when invoice changes - intentional pattern for controlled form dialogs
|
||||
useEffect(() => {
|
||||
if (invoice) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional pattern for form dialog
|
||||
setSelectedStatus(invoice.status);
|
||||
}
|
||||
}, [invoice]);
|
||||
|
||||
@@ -27,6 +27,7 @@ export default function LoginDialog({open, onOpenChange, onSwitchToSignUp}: Prop
|
||||
|
||||
if (!form.email || !form.password) {
|
||||
setError('Please enter your email and password');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,8 +42,9 @@ export default function LoginDialog({open, onOpenChange, onSwitchToSignUp}: Prop
|
||||
|
||||
onOpenChange(false);
|
||||
setForm({email: '', password: ''});
|
||||
} catch (err: any) {
|
||||
setError(err || 'Login failed. Please check your credentials.');
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
setError(message || 'Login failed. Please check your credentials.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
@@ -29,11 +29,13 @@ export default function SignUpDialog({open, onOpenChange, onSwitchToLogin}: Prop
|
||||
|
||||
if (form.password !== form.confirmPassword) {
|
||||
setError('Passwords do not match');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (form.password.length < 8) {
|
||||
setError('Password must be at least 8 characters');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,8 +51,9 @@ export default function SignUpDialog({open, onOpenChange, onSwitchToLogin}: Prop
|
||||
|
||||
onOpenChange(false);
|
||||
setForm({name: '', email: '', password: '', confirmPassword: ''});
|
||||
} catch (err: any) {
|
||||
setError(err || 'Registration failed. Please try again.');
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
setError(message || 'Registration failed. Please try again.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user