Fix invoice delete race condition by seeding detail page from navigation state
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -108,7 +108,7 @@ export default function CreateInvoice() {
|
|||||||
await supabase.from('tasks').update({ invoiced: true }).in('id', taskIds);
|
await supabase.from('tasks').update({ invoiced: true }).in('id', taskIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(`/invoices/${invoice.id}`);
|
navigate(`/invoices/${invoice.id}`, { state: { invoice } });
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedCompany = companies.find(c => c.id === selectedCompanyId);
|
const selectedCompany = companies.find(c => c.id === selectedCompanyId);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useParams, useNavigate, Link } from 'react-router-dom';
|
import { useParams, useNavigate, useLocation, Link } from 'react-router-dom';
|
||||||
import Layout from '../../components/Layout';
|
import Layout from '../../components/Layout';
|
||||||
import { supabase } from '../../lib/supabase';
|
import { supabase } from '../../lib/supabase';
|
||||||
import { generateInvoicePDF } from '../../lib/invoice';
|
import { generateInvoicePDF } from '../../lib/invoice';
|
||||||
@@ -9,8 +9,9 @@ const statusColor = { draft: 'not_started', sent: 'in_progress', paid: 'client_a
|
|||||||
export default function InvoiceDetail() {
|
export default function InvoiceDetail() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { state } = useLocation();
|
||||||
|
|
||||||
const [invoice, setInvoice] = useState(null);
|
const [invoice, setInvoice] = useState(state?.invoice || null);
|
||||||
const [company, setCompany] = useState(null);
|
const [company, setCompany] = useState(null);
|
||||||
const [items, setItems] = useState([]);
|
const [items, setItems] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user