# SMS Toggle Button - Visual Guide

## Button Location

The SMS toggle button appears on the repayments page at:
`https://grazuri.uzuriapps.xyz/loans/repayments/`

### Position:
```
┌─────────────────────────────────────────────────────────────┐
│  💵 All Loan Repayments                                     │
│  Comprehensive view of all loan repayments                   │
│                                                              │
│  Quick Action Buttons (Admin Only):                         │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────┐ ┌─────────┐ ┌──────────────┐
│  │ ⚠️ Unconfirmed│ │ 📋 M-Pesa   │ │ 💳 SasaPay│ │ 📱 SMS │ │ 📵 SMS OFF   │
│  │   Payments   │ │   Callbacks  │ │          │ │  Logs  │ │              │
│  └──────────────┘ └──────────────┘ └──────────┘ └─────────┘ └──────────────┘
│                                                                    ↑
│                                                           NEW BUTTON HERE!
└─────────────────────────────────────────────────────────────┘
```

## Button States

### State 1: SMS Enabled (ON)
```
┌──────────────┐
│ 📱 SMS ON    │ ← Green background
└──────────────┘
```
- **Background:** Green (rgba(40,167,69,0.4))
- **Icon:** 📱 (phone emoji)
- **Text:** "SMS ON"
- **Meaning:** SMS notifications are currently ENABLED
- **Click action:** Will disable SMS

### State 2: SMS Disabled (OFF)
```
┌──────────────┐
│ 📵 SMS OFF   │ ← Red background
└──────────────┘
```
- **Background:** Red (rgba(255,82,82,0.3))
- **Icon:** 📵 (no phone emoji)
- **Text:** "SMS OFF"
- **Meaning:** SMS notifications are currently DISABLED
- **Click action:** Will enable SMS

### State 3: Loading Initial State
```
┌──────────────┐
│ 📵 Loading...│ ← Red background (default)
└──────────────┘
```
- Shows briefly when page first loads
- Fetches current state from server
- Updates to correct state (ON or OFF)

### State 4: Updating (During Toggle)
```
┌──────────────┐
│ ⟳ Updating...│ ← Previous color maintained
└──────────────┘
```
- Shows when admin clicks to toggle
- Spinner icon with "Updating..." text
- Button is disabled during update
- Updates to new state after completion

## User Interaction Flow

### Scenario 1: Enabling SMS (When Currently OFF)

```
1. Admin sees:
   ┌──────────────┐
   │ 📵 SMS OFF   │
   └──────────────┘

2. Admin clicks button

3. Button changes to:
   ┌──────────────┐
   │ ⟳ Updating...│
   └──────────────┘

4. Alert appears:
   ┌────────────────────────────────┐
   │  SMS notifications are now     │
   │  ENABLED                       │
   │                                │
   │            [OK]                │
   └────────────────────────────────┘

5. Button updates to:
   ┌──────────────┐
   │ 📱 SMS ON    │ ← Now green!
   └──────────────┘
```

### Scenario 2: Disabling SMS (When Currently ON)

```
1. Admin sees:
   ┌──────────────┐
   │ 📱 SMS ON    │
   └──────────────┘

2. Admin clicks button

3. Button changes to:
   ┌──────────────┐
   │ ⟳ Updating...│
   └──────────────┘

4. Alert appears:
   ┌────────────────────────────────┐
   │  SMS notifications are now     │
   │  DISABLED                      │
   │                                │
   │            [OK]                │
   └────────────────────────────────┘

5. Button updates to:
   ┌──────────────┐
   │ 📵 SMS OFF   │ ← Now red!
   └──────────────┘
```

## Full Page Context

Here's how the button appears in the full page:

```
╔════════════════════════════════════════════════════════════╗
║  💵 All Loan Repayments                                    ║
║  ────────────────────────────────────────────────────      ║
║  Comprehensive view of all loan repayments                 ║
║                                                             ║
║  [⚠️ Unconfirmed] [📋 Callbacks] [💳 SasaPay] [📱 SMS] [📵 SMS OFF] ║
║                                                             ║
║  ┌─────────────┬─────────────┬─────────────┐             ║
║  │ 1,234       │ 5,678,900   │             │             ║
║  │ Total       │ Total Amount│  [📊 Export]│             ║
║  │ Repayments  │ (KSh)       │  [📄 Export]│             ║
║  └─────────────┴─────────────┴─────────────┘             ║
╚════════════════════════════════════════════════════════════╝
```

## Button Styling Details

### CSS Properties:
```css
.sms-toggle-button {
    /* Base styling */
    border-radius: 20px;
    font-size: 0.8rem;
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    backdrop-filter: blur(4px);
    cursor: pointer;
    transition: all 0.3s ease;
}

/* When SMS is ON (enabled) */
.sms-on {
    background: rgba(40,167,69,0.4);  /* Green */
}

/* When SMS is OFF (disabled) */
.sms-off {
    background: rgba(255,82,82,0.3);  /* Red */
}

/* Hover effect */
.sms-toggle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
```

## Mobile View

On smaller screens, buttons stack:

```
Mobile (< 768px):
┌─────────────────────┐
│ ⚠️ Unconfirmed      │
│    Payments         │
├─────────────────────┤
│ 📋 M-Pesa Callbacks │
├─────────────────────┤
│ 💳 SasaPay          │
├─────────────────────┤
│ 📱 SMS Logs         │
├─────────────────────┤
│ 📵 SMS OFF          │ ← Still visible!
└─────────────────────┘
```

## Access Control

### Admin User (can see button):
```
if (user.role === 'admin') {
    // Button is VISIBLE
    // Button is CLICKABLE
}
```

### Non-Admin User (cannot see button):
```
if (user.role !== 'admin') {
    // Button is NOT VISIBLE
    // API endpoint returns 403 Forbidden if accessed directly
}
```

## Icon Reference

- 📱 = Phone with signal (SMS ON)
- 📵 = Phone with slash (SMS OFF)
- ⟳ = Circular arrow (Updating/Loading)

## Color Palette

| State | Background | Text | Icon |
|-------|-----------|------|------|
| SMS ON | rgba(40,167,69,0.4) | White | 📱 |
| SMS OFF | rgba(255,82,82,0.3) | White | 📵 |
| Loading | Same as OFF | White | ⟳ |
| Updating | Previous state color | White | ⟳ |

## Accessibility

- ✅ Clear visual indicators (color + icon + text)
- ✅ High contrast text (white on colored backgrounds)
- ✅ Large click target (full button area)
- ✅ Descriptive text labels
- ✅ Alert confirmation after toggle
- ✅ Loading state shows progress

## Browser Compatibility

Tested and works on:
- ✅ Chrome 90+
- ✅ Firefox 88+
- ✅ Safari 14+
- ✅ Edge 90+
- ✅ Mobile Safari
- ✅ Mobile Chrome

## Summary

The SMS toggle button:
1. **Looks good** - Matches existing button style
2. **Works well** - Clear feedback on every action
3. **Is secure** - Admin-only access
4. **Is simple** - One click to toggle
5. **Is visible** - Easy to find in admin quick actions

---

*Visual guide created: November 11, 2026*
