From dac24b6b4ad924813d321837012a9edaf60d59ca Mon Sep 17 00:00:00 2001 From: Ola Bekkevold Date: Tue, 7 Apr 2026 15:18:11 +0200 Subject: [PATCH] feat: compare date instead of strings when editing return date convert the selected date to a date to correctly compare with the loan start date Refs: #79 --- labman/src/components/loans/EditLoan.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/labman/src/components/loans/EditLoan.tsx b/labman/src/components/loans/EditLoan.tsx index 8d902fb..5727dc8 100644 --- a/labman/src/components/loans/EditLoan.tsx +++ b/labman/src/components/loans/EditLoan.tsx @@ -149,9 +149,9 @@ export default function EditLoan({loan, setLoans}: EditLoanProps) { min={formData.startDate.toISOString().split("T")[0]} className="side-form-input" onChange={(e) => { - const selected = e.target.value; - if (selected < formData.startDate.toLocaleDateString()) return; - setFormData({...formData, endDate: new Date(selected)}); + const selected = new Date(e.target.value); + if (selected < formData.startDate) return; + setFormData({...formData, endDate: selected}); }} />