diff --git a/resources/views/components/⚡draft-invoices.blade.php b/resources/views/components/⚡draft-invoices.blade.php new file mode 100644 index 0000000..dbc9201 --- /dev/null +++ b/resources/views/components/⚡draft-invoices.blade.php @@ -0,0 +1,90 @@ +loadInvoices(); + } + + public function loadInvoices(): void + { + $this->invoices = Cache::remember('draft_invoices', now()->addMinutes(15), function () { + return Invoice::where('status', InvoiceStatus::DRAFT) + ->with('client') + ->orderBy('created_at', 'desc') + ->limit(10) + ->get() + ->map(fn($invoice) => [ + 'uuid' => $invoice->uuid, + 'invoice_number' => $invoice->invoice_number, + 'client_name' => $invoice->client?->abbreviation ?? $invoice->client?->name ?? 'Unknown', + 'total' => $invoice->total, + 'created_at' => $invoice->created_at->format('M j'), + ]) + ->toArray(); + }); + } + + #[On('invoice-created')] + public function clearCache(): void + { + Cache::forget('draft_invoices'); + $this->loadInvoices(); + } + + public function refresh(): void + { + Cache::forget('draft_invoices'); + $this->loadInvoices(); + } +}; +?> + +
No draft invoices
+|
+ {{ $invoice['invoice_number'] }}
+ {{ $invoice['client_name'] }}
+ |
+
+ ${{ number_format($invoice['total'], 0) }}
+ {{ $invoice['created_at'] }}
+ |
+ + + Edit + + | +
Cached for 15 min
+No payments yet
+|
+ {{ $payment['client_name'] }}
+ {{ $payment['invoice_number'] }}
+ |
+
+ ${{ number_format($payment['amount'], 2) }}
+ {{ $payment['payment_date'] }}
+ |
+
+ |
+
Cached for 15 min
+