Skip to content
This repository was archived by the owner on Aug 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function DashboardPage() {
const { data } = await supabase
.from('invoices')
.select('*')
.eq('originator', user.id)
.eq('originator_id', user.id)
.order('created_at', { ascending: false });
if (data) setInvoices(data as unknown as Invoice[]);
setLoading(false);
Expand Down
9 changes: 8 additions & 1 deletion src/components/invoices/InvoiceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function InvoiceForm({ onSuccess }: InvoiceFormProps) {

// Always mirror to Supabase for indexing / display
const { data: { user } } = await supabase.auth.getUser();
await supabase.from('invoices').insert({
const { error: insertError } = await supabase.from('invoices').insert({
id: invoiceId,
originator: publicKey,
originator_id: user?.id ?? null,
Expand All @@ -112,6 +112,13 @@ export function InvoiceForm({ onSuccess }: InvoiceFormProps) {
due_date: new Date(values.dueDate).toISOString(),
status: 'Pending',
});
if (insertError) {
throw new Error(
CONTRACT_OK
? `Invoice registered on-chain, but saving to the database failed: ${insertError.message}. It won't appear in lists until this is resolved.`
: `Saving the invoice failed: ${insertError.message}`,
);
}

toast({
title: CONTRACT_OK ? 'Invoice registered!' : 'Invoice saved!',
Expand Down