From ef74c465506d231686ce28354cd6ceb5e873a876 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 10:58:54 +0000 Subject: [PATCH] Fix Job Card layout and tax display Refactor Job Card layout to a grid, and adjust tax display. --- src/components/JobCardDetails.tsx | 118 ++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 39 deletions(-) diff --git a/src/components/JobCardDetails.tsx b/src/components/JobCardDetails.tsx index de8697e..76d6107 100644 --- a/src/components/JobCardDetails.tsx +++ b/src/components/JobCardDetails.tsx @@ -69,42 +69,70 @@ const JobCardDetails: React.FC = ({ job }) => { } }; + const formatDateForInput = (dateString: string | null | undefined) => { + if (!dateString) return ''; + return new Date(dateString).toISOString().slice(0, 16); + }; + + const handleBlur = (fieldName: string) => { + const value = tempValues[fieldName]; + if (value !== (job[fieldName as keyof IndJob] || '')) { + handleFieldUpdate(fieldName, value); + } else { + setEditingField(null); + } + }; + + const handleClick = (fieldName: string, value: string | null, e: React.MouseEvent) => { + e.stopPropagation(); + if (value) { + setEditingField(fieldName); + setTempValues({ ...tempValues, [fieldName]: formatDateForInput(value) }); + } + }; + const DateField = ({ label, value, fieldName, icon }: { label: string; value: string | null; fieldName: string; icon: React.ReactNode }) => ( -
- {icon} - {label}: - {editingField === fieldName ? ( - setTempValues({ ...tempValues, [fieldName]: e.target.value })} - onBlur={() => handleFieldUpdate(fieldName, tempValues[fieldName])} - onKeyDown={(e) => handleKeyPress(fieldName, e)} - className="h-6 px-2 py-1 bg-gray-800 border-gray-600 text-white text-xs flex-1 min-w-0" - autoFocus - data-no-navigate - /> - ) : ( - handleFieldClick(fieldName, value, e)} - className="cursor-pointer hover:text-blue-400 flex-1 min-w-0 h-6 flex items-center" - title="Click to edit" - data-no-navigate - > - {formatDateTime(value)} - - )} -
+ <> +
+ {icon} + {label}: +
+
+ {editingField === fieldName ? ( + setTempValues({ ...tempValues, [fieldName]: e.target.value })} + onBlur={() => handleBlur(fieldName)} + onKeyDown={(e) => handleKeyPress(fieldName, e)} + className="h-6 px-2 py-1 bg-gray-800 border-gray-600 text-white text-sm w-full" + autoFocus + data-no-navigate + /> + ) : ( + handleClick(fieldName, value, e)} + className="cursor-pointer hover:text-blue-400 h-6 flex items-center text-white text-sm w-full" + title="Click to edit" + data-no-navigate + > + {formatDateTime(value)} + + )} +
+ ); return (
-
+
- Job ID: + Job ID: +
+
= ({ job }) => {
- Created: - {formatDateTime(job.created)} + Created: +
+
+ {formatDateTime(job.created)}
= ({ job }) => { }; return ( -
+
- Target Price: + Target Price: +
+
= ({ job }) => { {formatISK(targetPriceWithTax)} {copying === 'targetPrice' && } + {salesTax > 0 && ( + + (+{(salesTax * 100).toFixed(1)}%) + + )}
- Break-even: + Break-even: +
+
= ({ job }) => { {formatISK(breakEvenPriceWithTax)} {copying === 'breakEvenPrice' && } -
- -
- per unit {salesTax > 0 && `(+${(salesTax * 100).toFixed(1)}% tax)`} + {salesTax > 0 && ( + + (+{(salesTax * 100).toFixed(1)}%) + + )}
);