diff --git a/src/components/JobCardDetails.tsx b/src/components/JobCardDetails.tsx index 111fc9e..e7a9e51 100644 --- a/src/components/JobCardDetails.tsx +++ b/src/components/JobCardDetails.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { Calendar, Factory, Clock, Copy } from 'lucide-react'; import { Input } from '@/components/ui/input'; import { IndJob } from '@/lib/types'; @@ -164,9 +164,16 @@ interface MinPriceDisplayProps { const MinPriceDisplay: React.FC = ({ job }) => { const { copying, copyToClipboard } = useClipboard(); + const [salesTax, setSalesTax] = useState(() => parseFloat(localStorage.getItem('salesTax') || '0') / 100); - // Get sales tax from localStorage (default 0%) - const salesTax = parseFloat(localStorage.getItem('salesTax') || '0') / 100; + // Listen for storage changes to update tax rate + useEffect(() => { + const handleStorageChange = () => { + setSalesTax(parseFloat(localStorage.getItem('salesTax') || '0') / 100); + }; + window.addEventListener('storage', handleStorageChange); + return () => window.removeEventListener('storage', handleStorageChange); + }, []); const minPricePerUnit = job.projectedRevenue / job.produced; const minPriceWithTax = minPricePerUnit * (1 + salesTax); diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 02562ee..b4dbcc8 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -262,7 +262,27 @@ const Index = () => { - -