# Platform Dummy Data & Pending Work Audit

This document tracks all remaining hardcoded dummy values, mock fallbacks, static metrics, and cleanup tasks across the Social Media Manager codebase to ensure the application is 100% production-ready.

---

## 1. High Priority: Active Features with Hardcoded Mock Data

### 1.1 Dashboard: Hardcoded Billing Summary
- **File**: [`app/Http/Controllers/DashboardController.php`](../app/Http/Controllers/DashboardController.php) (lines 183–194)
- **Problem**:
  ```php
  $billingSummary = [
      'planName' => 'Professional Plan',
      'renewalDate' => now()->addDays(30)->format('M d, Y'),
      'postsUsedPercentage' => $postsUsedPercentage,
      'aiUsedPercentage' => $aiUsedPercentage,
  ];
  ```
  - `planName` is statically set to `'Professional Plan'` regardless of whether the team is on a trial, starter, pro, or enterprise plan.
  - `renewalDate` is statically set to `now()->addDays(30)`.
  - `postsUsedPercentage` and `aiUsedPercentage` calculate against a hardcoded `/ 500` denominator instead of looking up the team's actual plan limit via `QuotaService`.
- **Work Required**:
  - Retrieve the team's active subscription: `$team->subscriptions()->latest()->first()`.
  - Resolve the real plan name: `$subscription?->plan?->name ?? 'Trial Plan'`.
  - Resolve the real period end date: `$subscription?->current_period_ends_at?->format('M d, Y') ?? now()->addDays(14)->format('M d, Y')`.
  - Use `QuotaService::getUsageAndLimit($team, 'socialPosts')` and `QuotaService::getUsageAndLimit($team, 'aiCommentModeration')` to obtain accurate percentage usages.

---

### 1.2 Live Chat Inbox: Hardcoded AI Suggestions & Canned Replies
- **Files**:
  - [`resources/js/composables/useLiveChat.ts`](../resources/js/composables/useLiveChat.ts) (lines 256–281)
  - [`resources/js/services/livechat.ts`](../resources/js/services/livechat.ts) (lines 7–40)
  - [`app/Http/Controllers/FacebookTools/LiveChatController.php`](../app/Http/Controllers/FacebookTools/LiveChatController.php) (lines 218–227)
- **Problem**:
  1. **AI Smart Suggestions**: In `useLiveChat.ts`, `aiSmartSuggestions` returns 3 hardcoded static responses labeled as "RAG Grounded" with fake match scores (`96%`, `92%`, `88%`):
     - *"Confirm Information & Availability"*
     - *"Offer Special VIP Discount"*
     - *"Share Catalog & Details"*
  2. **Canned Replies**: In `useLiveChat.ts`, `cannedReplies` is initialized directly from `MOCK_CANNED_REPLIES` in `services/livechat.ts` (`/vip20`, `/catalog`, `/shipping`, `/status`). There is no database table, persistence, or team customization.
  3. **Hardcoded Stats**:
     - `LiveChatController.php`: `'avgResponseTimeSec' => 45` is static.
     - When a workspace has 0 conversations, `aiHandledRate` defaults to `75%` instead of `0%`.
- **Work Required**:
  - Connect AI smart suggestions to the backend RAG pipeline via `AgentRagService` or show a clean empty state when no agent knowledge base is configured.
  - Implement a `canned_replies` migration/model/API so teams can manage their own quick replies, or allow local page preferences.
  - Compute real average response time from `ChatMessage` timestamps and return `0%` AI handled rate when no conversations exist.

---

### 1.3 Social Integrations: Fallback to Mock Accounts on 404
- **Files**:
  - [`resources/js/composables/useIntegrations.ts`](../resources/js/composables/useIntegrations.ts) (lines 34–53)
  - [`resources/js/services/integrations.ts`](../resources/js/services/integrations.ts) (lines 8–128)
  - [`routes/api.php`](../routes/api.php)
- **Problem**:
  - `loadIntegrations()` tries to fetch `GET /api/{teamSlug}/integrations`, but this endpoint does not exist in `routes/api.php` (only POST and PATCH routes exist).
  - When the fetch returns a 404 error, the catch block calls `data.value = getMockIntegrationsData()`.
  - This injects fake connected accounts (*"Alex Rivera (Meta Business)"*, *"Nexus E-Commerce Brand"*) from `services/integrations.ts`.
- **Work Required**:
  - Either add the `GET /api/{current_team}/integrations` route in `routes/api.php` delegating to `IntegrationController@index` (which already has JSON return support), or rely solely on Inertia page props.
  - Remove `getMockIntegrationsData()` fallback so empty accounts show the clean "No accounts connected yet" state.

---

## 2. Medium Priority: Metrics & Fallback Sanitization

### 2.1 Facebook Tools: Subscribers Static Metrics & Fallbacks
- **Files**:
  - [`app/Services/SubscriberService.php`](../app/Services/SubscriberService.php) (lines 111–113, 261–274)
  - [`resources/js/composables/useSubscribers.ts`](../resources/js/composables/useSubscribers.ts) (line 176)
- **Problem**:
  - `SubscriberService::getStatsForTeam()` hardcodes:
    - `'avgResponseTime' => '1.8 min'`
    - `'growthRate' => 14.2`
  - In `formatSubscriber()`, fallback defaults use dummy identifiers:
    - `'accountId' => ... ?? 'acc-meta-01'`
    - `'pageId' => ... ?? 'page-01'`
    - `'sourceDetails' => $sub->source_details ?? 'Post Comment'`
    - `'tags' => $sub->tags ?? ['Engaged']`
  - In `useSubscribers.ts`, fallback stat calculation uses `activeSubscribers7d: Math.round(total * 0.4)` (arbitrary 40%).
- **Work Required**:
  - Calculate `growthRate` comparing the last 30 days against the prior 30-day window (same logic as `DashboardController`).
  - Calculate `avgResponseTime` from `ChatMessage` delivery intervals or return `'N/A'` if no messages exist.
  - Remove fake fallback strings in `formatSubscriber`.

---

### 2.2 Facebook Tools: Comment Moderation Static Latency & Fallbacks
- **Files**:
  - [`app/Services/CommentService.php`](../app/Services/CommentService.php) (line 179)
  - [`resources/js/composables/useCommentManager.ts`](../resources/js/composables/useCommentManager.ts) (lines 94–95)
  - [`app/Http/Controllers/FacebookTools/CommentManagerController.php`](../app/Http/Controllers/FacebookTools/CommentManagerController.php) (line 85)
- **Problem**:
  - `CommentService::getStatsForTeam()` hardcodes `'avgModerationTimeMs' => 340` when `totalScanned > 0`.
  - In `useCommentManager.ts`, blocklist settings include static hardcoded arrays:
    - `competitorNames: ['Competitor Brand A', 'Competitor Brand B']`
    - `vipWhitelistUsers: ['VIP Buyer 1', 'VIP Partner 2']`
  - In `CommentManagerController.php`, default fallback keywords if page settings are empty:
    `['crypto', 'whatsapp me', 'telegram me', 'free money', 'cheap followers']`
- **Work Required**:
  - Persist `competitor_names` and `vip_whitelist` columns or JSON attributes in `social_pages` table so users can customize them.
  - Compute actual moderation latency from AI telemetry logs (`AiRequestLog::where('module', 'comment_moderation')->avg('latency_ms')`) or set to 0 when not recorded.

---

## 3. Low Priority: Dead Mock Files & Constants Pruning

The following files contain legacy mock constants that are no longer used by active pages (since the pages have been transitioned to real database records), but clutter the codebase:

1. [`resources/js/services/posting.ts`](../resources/js/services/posting.ts):
   - `MOCK_POSTS`: ~190 lines of mock Facebook and Instagram posts from 2026.
   - `MOCK_AI_CAPTION_VARIANTS`: empty array.
2. [`resources/js/services/livechat.ts`](../resources/js/services/livechat.ts):
   - `MOCK_CONVERSATIONS`: ~250 lines of mock chat threads (Tanvir Hossain, Sarah Jenkins, Samantha Reed).
3. [`resources/js/services/comments.ts`](../resources/js/services/comments.ts):
   - `MOCK_FLYWHEEL_RULES`: Mock flywheel triggers with Bengali text and PDF attachments.
   - `MOCK_BLOCKLIST_SETTINGS`: Static blocklist settings.
4. [`resources/js/services/integrations.ts`](../resources/js/services/integrations.ts):
   - `MOCK_CONNECTED_ACCOUNTS`: Mock accounts and pages.
5. [`resources/js/pages/AutomationRules/Index.vue`](../resources/js/pages/AutomationRules/Index.vue):
   - Standalone page superseded by Comment Manager's flywheels tab (`AutomationRuleController@index` redirects to `/facebook-tools/comments?tab=flywheels`).

---

## 4. Implementation Checklist

- [ ] **1. Dashboard Billing Summary**
  - Update `DashboardController.php` to fetch active team subscription and use `QuotaService` for real post and AI percentages.
- [ ] **2. Live Chat Inbox**
  - Replace static `aiSmartSuggestions` in `useLiveChat.ts` with real RAG integration or empty state.
  - Remove static 75% AI handled rate and 45s response time in `LiveChatController.php`.
  - Add database-backed or clean empty state for canned replies.
- [ ] **3. Social Integrations**
  - Add missing GET route in `routes/api.php` or standardize `useIntegrations.ts` on Inertia props.
  - Remove `getMockIntegrationsData()` fallback on fetch error.
- [ ] **4. Subscribers & Moderation Metrics**
  - Fix hardcoded growth rate (14.2%) and response time (1.8 min) in `SubscriberService.php`.
  - Fix hardcoded moderation latency (340ms) in `CommentService.php`.
  - Remove hardcoded competitor/VIP buyer names in `useCommentManager.ts`.
- [ ] **5. Prune Dormant Mocks**
  - Clean up `MOCK_POSTS`, `MOCK_CONVERSATIONS`, and `MOCK_FLYWHEEL_RULES` from `resources/js/services/`.
