Next.js Application Bugs & Enhancements
Budget: ₹12,500 – ₹37,500 INR
**Tech Stack:** Next.js 16, Supabase (PostgreSQL), Twilio SMS, Resend Email, Stripe
**Priority:** Fix courier SMS notifications
---
## BUG #1 - CRITICAL: Courier Not Receiving SMS
**Problem:** When customers confirm delivery time on tracking page, couriers don't receive SMS notification.
**Location:** `app/track/[orderId]/page.tsx`, function `confirmTimeSlot` (line ~200-250)
**Details:**
- Table: `courier_applications` (stores courier data)
- Orders table: `delivery_requests`
- Query: `.from("courier_applications").eq("id", order.assigned_courier_id)`
- SMS sent via: `/api/send-notification`
**Need to verify:**
- Database schema (`courier_applications` columns: id, phone, email, full_name, status)
- Relationship between `delivery_requests.assigned_courier_id` and `courier_applications.id`
- Courier phone format (+972... for Israel)
**Test Mode Available:** Set `TEST_MODE=true` in env vars to test without Twilio charges.
---
## BUG #2 - MEDIUM: Resend Email 403 Errors
**Problem:** Resend API returns 403 when sending to non-verified emails (testing mode restriction).
**Files:**
- `app/api/send-notification/route.ts`
- `app/api/send-confirmation/route.ts`
**Fix:** Either verify custom domain in Resend OR improve error handling to suppress client errors.
---
## BUG #3 - HIGH PRIORITY: Twilio Costs Too High
**Problem:** Twilio charges $0.26/SMS to Israel. 6-8 SMS per delivery = expensive.
**Solution:** Migrate to cheaper provider:
- Infobip: $0.03-0.05/SMS (80% savings)
- AWS SNS: $0.05/SMS
- Vonage: $0.04-0.06/SMS
**Task:** Replace Twilio with Infobip or AWS SNS.
---
## BUG #4 - MEDIUM: Database Schema Confusion
**Problem:** Code inconsistently references table names:
- Some code uses `couriers` table (doesn't exist)
- Actual table: `courier_applications`
- Mixed use of `user_id` vs `id` in queries
**Files to audit:**
- `app/track/[orderId]/page.tsx`
- `components/admin/admin-dashboard.tsx`
- `components/courier/courier-dashboard.tsx`
---
## TEST FLOW
1. Create order at `/order/new`
2. Admin assigns courier
3. Courier accepts at `/portal/courier/dashboard`
4. Courier sends scheduling options
5. Customer confirms time slot on tracking page
6. **VERIFY:** Courier receives SMS
---
## DELIVERABLES
1. Fix courier SMS (MAIN PRIORITY)
2. Document database schema
3. SMS provider migration plan
4. Test report
Task 1.2: Enhanced Notifications System
Add real-time push notifications for:
New order assigned to courier
Customer confirms scheduling
Order status changes (picked up, in transit, delivered, for the customer as well)
New chat messages
Steps:
VI. Add notification preferences to user settings
VII. Send email + SMS for each status change
VIII. Add in-app toast notifications
IX. Create notification history/inbox
X. Organize the data received from the process correctly on the Manager dashboard.
Task 1.3: Order Soft Delete + Admin Control
Couriers can "close" orders (mark as archived)
Only admin can permanently delete from database
Steps:
VI. Add archived boolean field to delivery_requests table
VII. Add "Archive Order" button in courier dashboard
VIII. Filter archived orders from courier view
IX. Admin dashboard shows all orders including archived
X. Admin has "Permanently Delete" button with confirmation
PHASE 2: Payment Integration (Week 3-4)
Task 2.1: Stripe Payment Flow
Escrow-like system: Customer pays → You hold → Release to courier after delivery
Steps:
VII. Set up Stripe Connect for courier payouts
VIII. Create payment flow: Customer confirms scheduling → Payment window opens
IX. Hold funds in your Stripe account
X. Calculate platform fee (your cut)
XI. After customer confirms delivery → Release payment to courier
XII. Handle refunds for cancelled/failed deliveries
Stripe fees: 2.9% + $0.30 per transaction
Task 2.2: Scheduling Lock After Payment
Order only locks to courier after customer pays
Before payment: other couriers can still bid
After payment: order is exclusive to assigned courier
Steps:
VI. Add payment_status field (pending/paid/refunded)
VII. Add payment_intent_id field
VIII. Lock courier assignment only when payment_status === 'paid'
IX. Show customer payment button after scheduling confirmation
X. Reveal customer details only after payment
PHASE 3: Advanced Features
Task 3.1: Israel Map with Location Notifications
Interactive map showing all active deliveries
Popup notifications based on location
Steps:
VII. Integrate Google Maps or Mapbox
VIII. Geocode all pickup/delivery addresses
IX. Display markers for each order (color-coded by status)
X. Add location-based filters (by city/region)
XI. Popup notification clouds for new orders in your area
XII. Real-time courier location tracking (optional)
Task 3.2: Courier Bidding System (Optional Enhancement)
Multiple couriers can bid on orders
Customer chooses courier based on price/rating
Steps:
V. Add bids table (courier_id, order_id, offered_price, estimated_time)
VI. Show all bids to customer
VII. Customer selects preferred courier
VIII. Proceed to payment
PHASE 4: Legal & Compliance (Ongoing)
For Production (When You Launch):
- Get a domain (movix.com, movix.co.il, etc.) - costs ~$10-15/year
- Verify it with Resend or SendGrid (15-60 minutes)
- Update the `from` address in code
- Then emails go directly to customers
Task 4.1: Terms of Service + Privacy Policy
Work with attorney to draft:
Terms of Service for customers
Terms of Service for couriers
Privacy Policy (GDPR/data protection)
Liability disclaimers
Payment terms and refund policy
Steps:
V. Research Israeli e-commerce/delivery regulations
VI. Consult with attorney
VII. Add legal pages to website
VIII. Require acceptance during signup
**Priority:** Fix courier SMS notifications
---
## BUG #1 - CRITICAL: Courier Not Receiving SMS
**Problem:** When customers confirm delivery time on tracking page, couriers don't receive SMS notification.
**Location:** `app/track/[orderId]/page.tsx`, function `confirmTimeSlot` (line ~200-250)
**Details:**
- Table: `courier_applications` (stores courier data)
- Orders table: `delivery_requests`
- Query: `.from("courier_applications").eq("id", order.assigned_courier_id)`
- SMS sent via: `/api/send-notification`
**Need to verify:**
- Database schema (`courier_applications` columns: id, phone, email, full_name, status)
- Relationship between `delivery_requests.assigned_courier_id` and `courier_applications.id`
- Courier phone format (+972... for Israel)
**Test Mode Available:** Set `TEST_MODE=true` in env vars to test without Twilio charges.
---
## BUG #2 - MEDIUM: Resend Email 403 Errors
**Problem:** Resend API returns 403 when sending to non-verified emails (testing mode restriction).
**Files:**
- `app/api/send-notification/route.ts`
- `app/api/send-confirmation/route.ts`
**Fix:** Either verify custom domain in Resend OR improve error handling to suppress client errors.
---
## BUG #3 - HIGH PRIORITY: Twilio Costs Too High
**Problem:** Twilio charges $0.26/SMS to Israel. 6-8 SMS per delivery = expensive.
**Solution:** Migrate to cheaper provider:
- Infobip: $0.03-0.05/SMS (80% savings)
- AWS SNS: $0.05/SMS
- Vonage: $0.04-0.06/SMS
**Task:** Replace Twilio with Infobip or AWS SNS.
---
## BUG #4 - MEDIUM: Database Schema Confusion
**Problem:** Code inconsistently references table names:
- Some code uses `couriers` table (doesn't exist)
- Actual table: `courier_applications`
- Mixed use of `user_id` vs `id` in queries
**Files to audit:**
- `app/track/[orderId]/page.tsx`
- `components/admin/admin-dashboard.tsx`
- `components/courier/courier-dashboard.tsx`
---
## TEST FLOW
1. Create order at `/order/new`
2. Admin assigns courier
3. Courier accepts at `/portal/courier/dashboard`
4. Courier sends scheduling options
5. Customer confirms time slot on tracking page
6. **VERIFY:** Courier receives SMS
---
## DELIVERABLES
1. Fix courier SMS (MAIN PRIORITY)
2. Document database schema
3. SMS provider migration plan
4. Test report
Task 1.2: Enhanced Notifications System
Add real-time push notifications for:
New order assigned to courier
Customer confirms scheduling
Order status changes (picked up, in transit, delivered, for the customer as well)
New chat messages
Steps:
VI. Add notification preferences to user settings
VII. Send email + SMS for each status change
VIII. Add in-app toast notifications
IX. Create notification history/inbox
X. Organize the data received from the process correctly on the Manager dashboard.
Task 1.3: Order Soft Delete + Admin Control
Couriers can "close" orders (mark as archived)
Only admin can permanently delete from database
Steps:
VI. Add archived boolean field to delivery_requests table
VII. Add "Archive Order" button in courier dashboard
VIII. Filter archived orders from courier view
IX. Admin dashboard shows all orders including archived
X. Admin has "Permanently Delete" button with confirmation
PHASE 2: Payment Integration (Week 3-4)
Task 2.1: Stripe Payment Flow
Escrow-like system: Customer pays → You hold → Release to courier after delivery
Steps:
VII. Set up Stripe Connect for courier payouts
VIII. Create payment flow: Customer confirms scheduling → Payment window opens
IX. Hold funds in your Stripe account
X. Calculate platform fee (your cut)
XI. After customer confirms delivery → Release payment to courier
XII. Handle refunds for cancelled/failed deliveries
Stripe fees: 2.9% + $0.30 per transaction
Task 2.2: Scheduling Lock After Payment
Order only locks to courier after customer pays
Before payment: other couriers can still bid
After payment: order is exclusive to assigned courier
Steps:
VI. Add payment_status field (pending/paid/refunded)
VII. Add payment_intent_id field
VIII. Lock courier assignment only when payment_status === 'paid'
IX. Show customer payment button after scheduling confirmation
X. Reveal customer details only after payment
PHASE 3: Advanced Features
Task 3.1: Israel Map with Location Notifications
Interactive map showing all active deliveries
Popup notifications based on location
Steps:
VII. Integrate Google Maps or Mapbox
VIII. Geocode all pickup/delivery addresses
IX. Display markers for each order (color-coded by status)
X. Add location-based filters (by city/region)
XI. Popup notification clouds for new orders in your area
XII. Real-time courier location tracking (optional)
Task 3.2: Courier Bidding System (Optional Enhancement)
Multiple couriers can bid on orders
Customer chooses courier based on price/rating
Steps:
V. Add bids table (courier_id, order_id, offered_price, estimated_time)
VI. Show all bids to customer
VII. Customer selects preferred courier
VIII. Proceed to payment
PHASE 4: Legal & Compliance (Ongoing)
For Production (When You Launch):
- Get a domain (movix.com, movix.co.il, etc.) - costs ~$10-15/year
- Verify it with Resend or SendGrid (15-60 minutes)
- Update the `from` address in code
- Then emails go directly to customers
Task 4.1: Terms of Service + Privacy Policy
Work with attorney to draft:
Terms of Service for customers
Terms of Service for couriers
Privacy Policy (GDPR/data protection)
Liability disclaimers
Payment terms and refund policy
Steps:
V. Research Israeli e-commerce/delivery regulations
VI. Consult with attorney
VII. Add legal pages to website
VIII. Require acceptance during signup