// DEPLOY_CONFIG: {"triggers": [{"name": "high_bill_alert", "on": "collection.add", "collection": "bills", "actions": [{"type": "notification", "title": "Unusually high bill detected", "body": "A newly added bill is more than 50% above the average."}, {"type": "email", "to": "alerts@deplixo.app", "subject": "Alert: Unusually high bill detected", "body": "A newly added bill is more than 50% above the average."}]}]} import { useMemo, useState } from 'react'; import { useAuth, useCollection, exportCSV, exportJSON } from '@deplixo/sdk'; import { Dashboard } from './components/Dashboard.jsx'; import { BillForm } from './components/BillForm.jsx'; import { BillList } from './components/BillList.jsx'; import { Comparison } from './components/Comparison.jsx'; function App() { const { user, loading, logout } = useAuth(); const { items: bills = [] } = useCollection('bills', { personal: true }); const [activeTab, setActiveTab] = useState('dashboard'); const [editingBill, setEditingBill] = useState(null); const [showForm, setShowForm] = useState(false); const [showExportPanel, setShowExportPanel] = useState(false); const [exportFormat, setExportFormat] = useState('csv'); const [exportScope, setExportScope] = useState('all'); const [exportMessage, setExportMessage] = useState(''); const tabs = [ { id: 'dashboard', label: 'Dashboard', icon: '๐Ÿ“Š' }, { id: 'bills', label: 'Bills', icon: '๐Ÿงพ' }, { id: 'comparison', label: 'Compare', icon: '๐Ÿ“ˆ' }, ]; const handleEdit = (bill) => { setEditingBill(bill); setShowForm(true); }; const handleCloseForm = () => { setShowForm(false); setEditingBill(null); }; const billData = useMemo(() => { return bills.map((bill) => ({ id: bill.id ?? '', type: bill.type ?? bill.category ?? '', provider: bill.provider ?? '', amount: bill.amount ?? '', date: bill.date ?? '', notes: bill.notes ?? '', createdAt: bill.createdAt ?? '', updatedAt: bill.updatedAt ?? '', })); }, [bills]); const getFilteredExportData = () => { if (exportScope === 'all') return billData; if (activeTab === 'bills') { const billListElement = document.querySelector('.bill-list'); if (!billListElement) return billData; } return billData; }; const handleExport = () => { const records = getFilteredExportData(); const filenameBase = `bill-tracker-${exportScope}-${new Date().toISOString().slice(0, 10)}`; if (exportFormat === 'csv') { exportCSV(records, { filename: `${filenameBase}.csv`, columns: ['id', 'type', 'provider', 'amount', 'date', 'notes', 'createdAt', 'updatedAt'], }); setExportMessage(`Exported ${records.length} record${records.length === 1 ? '' : 's'} to CSV.`); } else { exportJSON(records, { filename: `${filenameBase}.json` }); setExportMessage(`Exported ${records.length} record${records.length === 1 ? '' : 's'} to JSON.`); } setShowExportPanel(false); }; if (loading) { return
Signing in...
; } if (!user) { return (
โšก

Bill Tracker

Sign in with Google to view and manage your household bills, analytics, comparisons, and exports.

You must be authenticated to access household data.
); } return (
โšก

Bill Tracker

{user.name}
{showExportPanel && (

Export Data

Download household bills as CSV or JSON from the browser.

Filtered view exports the currently available bills in the app.
{exportMessage &&
{exportMessage}
}
)}
{activeTab === 'dashboard' && } {activeTab === 'bills' && { setEditingBill(null); setShowForm(true); }} />} {activeTab === 'comparison' && }
{showForm && }
); } ReactDOM.createRoot(document.getElementById("root")).render();