# GMB Dashboard — Adding Clients & Dealers (Screen Recording Script)

Use this document as a step-by-step script for your screen grab video. It walks through the full hierarchy: **Agency → Client → Dealer**.

---

## Prerequisites

1. **Backend is running:**
   ```
   cd backend
   python -m uvicorn app.main:app --reload --port 8000
   ```
2. **Frontend is open:** Navigate to `http://127.0.0.1:5500/frontend/index.html` in your browser.

---

## 🔐 Default Credentials

| Role    | Email                          | Password      | Notes |
|---------|--------------------------------|---------------|-------|
| Agency  | `admin@hashtagorang.in`        | `Admin@123`   | Agency admin — does NOT require password change |
| Client  | `fenesta@example.com`          | `Client@123`  | Pre-seeded test client — forced password change on first login |
| Dealer  | `dealer.gurugram@fenesta.com`  | `Dealer@123`  | Pre-seeded test dealer — forced password change on first login |
| Dealer  | `dealer.noida@fenesta.com`     | `Dealer@123`  | Pre-seeded test dealer — forced password change on first login |
| Dealer  | `dealer.jaipur@fenesta.com`    | `Dealer@123`  | Pre-seeded test dealer — forced password change on first login |

> **Important:** When a Client or Dealer is created via the UI, the system generates a **random temporary password** that is shown in a green toast notification at the top-right corner of the screen. Copy it immediately — it is only shown once. The user will be forced to change it on their first login.

---

## Step 1: Login as Agency Admin

1. Open the login page.
2. Enter:
   - **Email:** `admin@hashtagorang.in`
   - **Password:** `Admin@123`
3. Click **Secure Login**.
4. You will see the **Agency Administration** dashboard with the "Brand Clients" tab active.

---

## Step 2: Add a New Client (from Agency Dashboard)

1. On the **Brand Clients** tab, click the **"+ Add Client"** button (top-right of the table).
2. A modal popup will appear with three fields:

   | Field                | What to Enter                 | Required? |
   |----------------------|-------------------------------|-----------|
   | **Client Name**      | e.g. `Fenesta Windows`        | Yes       |
   | **Admin Email**      | e.g. `fenesta@brand.com`      | Yes       |
   | **GBP Account ID**   | e.g. `accounts/12345` (or leave blank) | No |

3. Click **"Create Client"**.
4. ✅ A **green toast notification** appears at the top-right showing:
   - "Created Successfully!"
   - **Temp Password: `xxxxxxxx`** ← Copy this! This is the client's login password.
5. The client now appears in the table below.

---

## Step 3: Logout & Login as the New Client

1. Click **Logout** (top-right).
2. On the login screen, enter:
   - **Email:** The email you used in Step 2 (e.g. `fenesta@brand.com`)
   - **Password:** The temporary password from the green toast
3. Click **Secure Login**.
4. ⚠️ You will be redirected to the **"Change Password"** screen (mandatory for new accounts).
5. Fill in:
   - **Current Password:** The temp password
   - **New Password:** Must meet requirements (8+ chars, uppercase, lowercase, digit, special char)
   - **Confirm Password:** Re-type the new password
6. Click **Update & Continue**.
7. You are now on the **Client Dashboard** with 4 tabs:
   - **Global Overview** — Cumulative brand metrics (HQ + all dealers)
   - **Dealer Network** — Sub-dealer table + network-only metrics
   - **Add Dealer** — Form to provision new dealers
   - **HQ Location** — Client's own flagship store metrics

---

## Step 4: Add a Dealer (from Client Dashboard)

1. Click the **"Add Dealer"** tab.
2. You will see the **"Provision Sub-Dealer"** form with these fields:

   | Field                    | What to Enter                     | Required? |
   |--------------------------|-----------------------------------|-----------|
   | **Dealer / Store Name**  | e.g. `Fenesta South Delhi`        | Yes       |
   | **Login Email**          | e.g. `south.delhi@fenesta.com`    | Yes       |
   | **City**                 | e.g. `New Delhi`                  | No        |
   | **State**                | e.g. `Delhi`                      | No        |
   | **Google Location ID**   | e.g. `123456789`                  | Yes *(required for API sync)* |

3. Click **"Create Dealer Account"**.
4. ✅ A **green toast notification** appears showing:
   - "Created Successfully!"
   - **Temp Password: `xxxxxxxx`** ← Copy this! This is the dealer's login password.
5. Switch to the **"Dealer Network"** tab to see the new dealer in the table.

---

## Step 5: Logout & Login as the New Dealer

1. Click **Logout**.
2. Enter:
   - **Email:** The dealer email from Step 4 (e.g. `south.delhi@fenesta.com`)
   - **Password:** The temporary password from the toast
3. Click **Secure Login**.
4. ⚠️ You will be redirected to the **"Change Password"** screen.
5. Set a new password and click **Update & Continue**.
6. You are now on the **Dealer Dashboard** showing individual location metrics and a 6-month trend chart.

---

## Password Summary

| Scenario                     | Where to Find the Password                                           |
|------------------------------|----------------------------------------------------------------------|
| Agency Admin                 | Hardcoded during setup: `Admin@123`                                  |
| Pre-seeded test Client       | `Client@123` (set in `seed_test_data.py`)                            |
| Pre-seeded test Dealers      | `Dealer@123` (set in `seed_test_data.py`)                            |
| Newly created Client (via UI)| **Green toast notification** after clicking "Create Client"          |
| Newly created Dealer (via UI)| **Green toast notification** after clicking "Create Dealer Account"  |

> All new accounts are flagged with `needs_password_change = TRUE`. The user **must** change the temp password on their first login before accessing the dashboard.

---

## Quick Demo Flow for Video

```
Agency Login → Add Client → Copy Temp PW → Logout
→ Client Login (temp PW) → Change Password → Add Dealer → Copy Temp PW → Logout
→ Dealer Login (temp PW) → Change Password → View Dealer Dashboard
```
