-
Import Handler Implementation: The
handleImportfunction was previously just showing a toast message. Now it:- Processes the parsed data from the paste import interface
- Extracts lead information from each row
- Creates leads in the database
- Shows success/failure counts
- Refreshes the page to show new leads
-
Debug Logging Added: Added console.log statements throughout the flow to track:
- Import data processing
- Lead creation in database
- Data fetching from database
-
Open Developer Console (F12 in Chrome/Edge)
- Go to Console tab to see debug logs
-
Navigate to Leads Page
- http://localhost:3002/en/leads
- Login if required
-
Click Import Button
- Click the "Import" button in the top toolbar
-
Paste Sample Data
- Use the "Use Sample Data" button OR
- Paste this test data:
John Doe, john@example.com, +1 555-0123, ABC Corp Jane Smith, jane@example.com, +1 555-0124, XYZ Inc Bob Johnson, bob@example.com, +1 555-0125, 123 Company -
Click "Import Leads"
You should see these debug logs:
Import started with data: [...]
Creating lead: {name: "John Doe", email: "john@example.com", ...}
[CREATE LEAD] Starting with input: {...}
[CREATE LEAD] User authenticated: [user-id]
[CREATE LEAD] Input validated: {...}
[CREATE LEAD] Creating lead in database...
[CREATE LEAD] Lead created successfully: [lead-id]
[CREATE LEAD] Cache revalidated, returning success
[LIST LEADS] Starting with params: {...}
[LIST LEADS] User authenticated: [user-id]
[LIST LEADS] Query where clause: {...}
[LIST LEADS] Found X leads, total: Y
Solution: The system prevents duplicate emails. Try with different email addresses.
Check:
- Console for errors
- Network tab for failed requests
- Database directly:
pnpm prisma studio
Possible Causes:
- Validation error - check console for details
- Database connection issue
- Authentication problem - make sure you're logged in
To verify leads are in the database:
# Open Prisma Studio
pnpm prisma studio- Navigate to Lead table
- Check if imported leads are present
- Verify userId field matches your user
You can also test by creating a lead manually:
- Click "New Lead" button
- Fill in form:
- Name: Test Lead
- Email: test@example.com
- Company: Test Company
- Status: New
- Source: Manual Entry
- Priority: Medium
- Click "Create Lead"
- Check if it appears in table
- "Import started with data": Client received paste data
- "Creating lead": Client is processing each lead
- "[CREATE LEAD] Starting": Server received create request
- "[CREATE LEAD] Lead created successfully": Database insert successful
- "[LIST LEADS] Found X leads": Table refresh found leads
- "Successfully imported X lead(s)": Import complete
-
Check Browser Console for JavaScript errors
-
Check Network Tab for failed API calls
-
Check Server Console (terminal running
pnpm dev) for server errors -
Verify Database Schema:
pnpm prisma generate pnpm prisma db push
-
Try Manual Database Insert:
pnpm prisma studio # Manually add a lead in the Lead table
✅ Console shows all debug logs without errors ✅ Toast notification shows "Successfully imported X lead(s)" ✅ New leads appear in the table after import ✅ Leads are visible in Prisma Studio ✅ Page refreshes automatically after import