Skip to content

Commit ca44e89

Browse files
Add Leadership Dashboard with KPIs, debtor activity reports, debt buyer portal, enhanced portfolio management, and universal ListView component
1 parent 33ae13e commit ca44e89

File tree

14 files changed

+3523
-279
lines changed

14 files changed

+3523
-279
lines changed

src/api/entities.js

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@ const getDefaultMockData = () => ({
5151
{ id: '3', name: 'TechServ Solutions', type: 'technology', contact_person: 'Mike Davis', email: 'mike@techserv.com', phone: '555-0103', status: 'inactive', created_at: '2024-02-01T10:00:00Z' }
5252
],
5353
portfolios: [
54-
{ id: '1', name: 'Q1 2024 Medical Debt', client: 'MedCorp LLC', portfolio_type: 'committed', status: 'active', created_at: '2024-01-10T10:00:00Z' },
55-
{ id: '2', name: 'Credit Card Portfolio A', client: 'FinanceFirst LLC', portfolio_type: 'spec', status: 'active', created_at: '2024-02-15T10:00:00Z' },
56-
{ id: '3', name: 'Auto Loan Defaults', client: 'AutoCredit LLC', portfolio_type: 'committed', status: 'completed', created_at: '2024-03-01T10:00:00Z' }
54+
{ id: '1', name: 'Q1 2024 Medical Debt', client: 'MedCorp LLC', portfolio_type: 'committed', portfolio_category: 'purchased', total_face_value: 125000, purchase_price: 15000, account_count: 150, status: 'active', created_at: '2024-01-10T10:00:00Z' },
55+
{ id: '2', name: 'Credit Card Portfolio A', client: 'FinanceFirst LLC', portfolio_type: 'spec', portfolio_category: 'purchased', total_face_value: 250000, purchase_price: 37500, account_count: 320, status: 'active', created_at: '2024-02-15T10:00:00Z' },
56+
{ id: '3', name: 'Auto Loan Defaults', client: 'AutoCredit LLC', portfolio_type: 'committed', portfolio_category: 'purchased', total_face_value: 180000, purchase_price: 27000, account_count: 85, status: 'completed', created_at: '2024-03-01T10:00:00Z' },
57+
{ id: '4', name: 'High-Value Credit Cards', client: 'CAUSA Internal', portfolio_type: 'spec', portfolio_category: 'for_sale', total_face_value: 450000, asking_price: 90000, account_count: 275, status: 'for_sale', created_at: '2024-04-01T10:00:00Z' },
58+
{ id: '5', name: 'Medical Collection Bundle', client: 'CAUSA Internal', portfolio_type: 'committed', portfolio_category: 'for_sale', total_face_value: 320000, asking_price: 64000, account_count: 420, status: 'for_sale', created_at: '2024-04-15T10:00:00Z' }
5759
],
5860
cases: [
59-
{ id: '1', portfolio_id: '1', debtor_id: '1', debtor_name: 'John Doe', account_number: 'MED001', original_balance: 2500, current_balance: 2500, original_creditor: 'City Hospital', charge_off_date: '2024-01-01', status: 'new', priority: 'medium', created_at: '2024-01-10T10:00:00Z' },
60-
{ id: '2', portfolio_id: '1', debtor_id: '2', debtor_name: 'Jane Smith', account_number: 'MED002', original_balance: 1800, current_balance: 1800, original_creditor: 'City Hospital', charge_off_date: '2023-12-15', status: 'in_collection', priority: 'high', created_at: '2024-01-10T10:00:00Z' },
61-
{ id: '3', portfolio_id: '2', debtor_id: '3', debtor_name: 'Bob Johnson', account_number: 'CC001', original_balance: 3200, current_balance: 3200, original_creditor: 'National Bank', charge_off_date: '2023-11-01', status: 'payment_plan', priority: 'medium', created_at: '2024-02-15T10:00:00Z' },
62-
{ id: '4', portfolio_id: '2', debtor_id: '4', debtor_name: 'Alice Brown', account_number: 'CC002', original_balance: 1500, current_balance: 750, original_creditor: 'National Bank', charge_off_date: '2023-10-15', status: 'paid', priority: 'low', created_at: '2024-02-15T10:00:00Z' },
63-
{ id: '5', portfolio_id: '3', debtor_id: '5', debtor_name: 'Charlie Wilson', account_number: 'AUTO001', original_balance: 15000, current_balance: 12000, original_creditor: 'Car Finance Co', charge_off_date: '2023-08-01', status: 'settled', priority: 'high', created_at: '2024-03-01T10:00:00Z' },
64-
{ id: '6', portfolio_id: '1', debtor_id: '6', debtor_name: 'Sarah Chen', account_number: 'ACC-20241201-5678', original_balance: 12000, current_balance: 13500, original_creditor: 'Wells Fargo', charge_off_date: '2023-09-21', status: 'legal_action', priority: 'high', created_at: '2024-01-10T10:00:00Z' }
61+
{ id: '1', portfolio_id: '1', debtor_id: '1', debtor_name: 'John Doe', account_number: 'MED001', original_balance: 2500, current_balance: 2500, original_creditor: 'City Hospital', charge_off_date: '2024-01-01', status: 'new', priority: 'medium', vendor_id: '1', scrub_method: 'experian', created_at: '2024-01-10T10:00:00Z' },
62+
{ id: '2', portfolio_id: '1', debtor_id: '2', debtor_name: 'Jane Smith', account_number: 'MED002', original_balance: 1800, current_balance: 1800, original_creditor: 'City Hospital', charge_off_date: '2023-12-15', status: 'in_collection', priority: 'high', vendor_id: '2', scrub_method: 'rnn', created_at: '2024-01-10T10:00:00Z' },
63+
{ id: '3', portfolio_id: '2', debtor_id: '3', debtor_name: 'Bob Johnson', account_number: 'CC001', original_balance: 3200, current_balance: 3200, original_creditor: 'National Bank', charge_off_date: '2023-11-01', status: 'payment_plan', priority: 'medium', vendor_id: '2', scrub_method: 'tlo', created_at: '2024-02-15T10:00:00Z' },
64+
{ id: '4', portfolio_id: '2', debtor_id: '4', debtor_name: 'Alice Brown', account_number: 'CC002', original_balance: 1500, current_balance: 750, original_creditor: 'National Bank', charge_off_date: '2023-10-15', status: 'paid', priority: 'low', vendor_id: '2', scrub_method: 'experian', created_at: '2024-02-15T10:00:00Z' },
65+
{ id: '5', portfolio_id: '3', debtor_id: '5', debtor_name: 'Charlie Wilson', account_number: 'AUTO001', original_balance: 15000, current_balance: 12000, original_creditor: 'Car Finance Co', charge_off_date: '2023-08-01', status: 'settled', priority: 'high', vendor_id: '1', scrub_method: 'rnn', created_at: '2024-03-01T10:00:00Z' },
66+
{ id: '6', portfolio_id: '1', debtor_id: '6', debtor_name: 'Sarah Chen', account_number: 'ACC-20241201-5678', original_balance: 12000, current_balance: 13500, original_creditor: 'Wells Fargo', charge_off_date: '2023-09-21', status: 'legal_action', priority: 'high', vendor_id: '1', scrub_method: 'tlo', created_at: '2024-01-10T10:00:00Z' }
6567
],
6668
debtors: [
6769
{ id: '1', name: 'John Doe', email: 'john.doe@email.com', phone: '555-1001', created_at: '2024-01-05T10:00:00Z' },
@@ -166,10 +168,10 @@ const populateSupabaseIfEmpty = async (tableName) => {
166168
// Initialize mock data from localStorage
167169
let mockData = loadMockData();
168170

169-
// Save initial data to localStorage if not exists
170-
if (!localStorage.getItem('ccai_mock_data')) {
171-
saveMockData(mockData);
172-
}
171+
// Force update localStorage with vendor_id fields
172+
console.log('Force updating localStorage with vendor assignments...');
173+
localStorage.removeItem('ccai_mock_data');
174+
saveMockData(mockData);
173175

174176
// Entity helpers using Supabase
175177
const createEntity = (tableName) => ({
@@ -198,6 +200,56 @@ const createEntity = (tableName) => ({
198200
// Always add to mock data (for both localStorage and as default data)
199201
mockData[tableName] = mockData[tableName] || [];
200202
mockData[tableName].push(newRecord);
203+
204+
// For cases (debts), add activity log entries
205+
if (tableName === 'cases') {
206+
const now = new Date().toISOString();
207+
const baseId = Date.now();
208+
209+
// Account Created entry
210+
const accountCreatedLog = {
211+
id: `log_${baseId}_1`,
212+
case_id: newRecord.id,
213+
activity_type: 'account_created',
214+
description: 'Account Created',
215+
performed_by: 'system',
216+
activity_date: now,
217+
metadata: JSON.stringify({ event: 'account_created' }),
218+
created_at: now
219+
};
220+
221+
// DVN Sent entry
222+
const dvnSentLog = {
223+
id: `log_${baseId}_2`,
224+
case_id: newRecord.id,
225+
activity_type: 'dvn_sent',
226+
description: 'DVN was sent',
227+
performed_by: 'system',
228+
activity_date: new Date(Date.now() + 1000).toISOString(),
229+
metadata: JSON.stringify({ event: 'dvn_sent', method: 'automated' }),
230+
created_at: new Date(Date.now() + 1000).toISOString()
231+
};
232+
233+
// Scrub Process Started entry
234+
const scrubStartedLog = {
235+
id: `log_${baseId}_3`,
236+
case_id: newRecord.id,
237+
activity_type: 'scrub_started',
238+
description: `Scrub process started (${data.scrub_method || 'Unknown'})`,
239+
performed_by: 'system',
240+
activity_date: new Date(Date.now() + 2000).toISOString(),
241+
metadata: JSON.stringify({
242+
event: 'scrub_started',
243+
scrub_method: data.scrub_method || 'unknown',
244+
vendor_id: data.vendor_id
245+
}),
246+
created_at: new Date(Date.now() + 2000).toISOString()
247+
};
248+
249+
mockData.activity_logs = mockData.activity_logs || [];
250+
mockData.activity_logs.push(accountCreatedLog, dvnSentLog, scrubStartedLog);
251+
}
252+
201253
saveMockData(mockData);
202254

203255
// Also try to add to Supabase (for CloudFront persistence)

0 commit comments

Comments
 (0)