Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
cefe109103
commit
323e8c5ca1
@@ -6,7 +6,7 @@ import { Label } from "@/components/ui/label";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { supabase } from "@/integrations/supabase/client";
|
||||
import { useAuth } from "@/lib/auth";
|
||||
import { Plus, Trash2, Loader2, Receipt as ReceiptIcon, CheckCircle2, Undo2, Download } from "lucide-react";
|
||||
import { Plus, Trash2, Loader2, Receipt as ReceiptIcon, CheckCircle2, Undo2, Download, RefreshCw } from "lucide-react";
|
||||
import { formatCurrency, formatDate } from "@/lib/format";
|
||||
import { ensureMarkedInvoicedPlaceholder } from "@/lib/invoice-generation";
|
||||
import { toast } from "sonner";
|
||||
@@ -69,6 +69,18 @@ export function CaseExpensesTab({ caseId }: { caseId: string }) {
|
||||
return () => window.removeEventListener("expenses:changed", handler);
|
||||
}, [caseId]);
|
||||
|
||||
// Refresh when tab/window becomes visible again (covers Quick Add from another page)
|
||||
useEffect(() => {
|
||||
const onFocus = () => load();
|
||||
const onVis = () => { if (document.visibilityState === "visible") load(); };
|
||||
window.addEventListener("focus", onFocus);
|
||||
document.addEventListener("visibilitychange", onVis);
|
||||
return () => {
|
||||
window.removeEventListener("focus", onFocus);
|
||||
document.removeEventListener("visibilitychange", onVis);
|
||||
};
|
||||
}, [caseId]);
|
||||
|
||||
// Load case client_id for placeholder invoice creation
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
@@ -182,6 +194,9 @@ export function CaseExpensesTab({ caseId }: { caseId: string }) {
|
||||
<Stat label="Unbilled" value={formatCurrency(totals.unbilled)} />
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button variant="ghost" size="icon" onClick={load} title="Refresh">
|
||||
<RefreshCw className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button variant="outline" onClick={() => setShowImport(true)}>
|
||||
<Download className="h-4 w-4 mr-2" /> Import open expenses
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user