> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ezagroup.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Feature-flags

> Activer et désactiver des fonctionnalités sans redéploiement

<CardGroup cols={2}>
  <Card title="Toggle instantané" color="#38aadc" icon="zap">
    Activation ou désactivation en un clic depuis l'admin.
  </Card>

  <Card title="Rollout progressif" color="#a78bfa" icon="trending-up">
    Déployer sur X% des utilisateurs seulement.
  </Card>

  <Card title="Ciblage rôle" color="#f59e0b" icon="users">
    Réservé aux Business, VIP, testeurs, etc.
  </Card>

  <Card title="Kill switch" color="#ef4444" icon="power">
    Couper un module en cas d'incident.
  </Card>
</CardGroup>

## L'entité `FeatureFlag`

| Champ             | Description                                        |
| ----------------- | -------------------------------------------------- |
| `key`             | Clé unique (`page_flash_enabled`)                  |
| `enabled`         | Activé globalement                                 |
| `rollout_percent` | 0-100, pourcentage d'utilisateurs                  |
| `audience`        | `all`, `certified`, `business`, `role:X`, `tier:X` |
| `description`     | Notes internes                                     |
| `updated_by`      | Dernier admin à modifier                           |

## Hook React `usePageEnabled`

```jsx theme={null}
import { usePageEnabled } from '@/hooks/usePageEnabled';
import FeatureDisabled from '@/components/shared/FeatureDisabled';

function FlashDeliveryPage() {
  const { enabled, isLoading } = usePageEnabled('page_flash_enabled');
  if (isLoading) return null;
  if (!enabled) return <FeatureDisabled title="Flash Delivery indisponible" />;
  // ... contenu de la page
}
```

## Flags actuels

| Flag                    | Rôle                       |
| ----------------------- | -------------------------- |
| `page_flash_enabled`    | Active Flash Delivery      |
| `page_wifi_enabled`     | Portail Wi-Fi              |
| `page_ads_enabled`      | Espace publicité           |
| `page_stories_enabled`  | Stories 24h                |
| `page_spaces_enabled`   | Espaces vocaux             |
| `nexus_ai_enabled`      | IA Nexus dans messagerie   |
| `certification_enabled` | Demandes certification     |
| `donations_enabled`     | Plateforme de dons         |
| `referral_v2_enabled`   | Nouveau système parrainage |

## Cas d'usage

<CardGroup cols={2}>
  <Card title="Beta test" icon="flask-conical">
    `audience: role:collaborateur_interne` → seuls les employés voient.
  </Card>

  <Card title="Progressive rollout" icon="trending-up">
    `rollout_percent: 10` puis 25, 50, 100.
  </Card>

  <Card title="Kill switch" icon="power">
    Bug détecté en prod → `enabled: false` immédiat.
  </Card>

  <Card title="Segment Business" icon="briefcase">
    `audience: business` → exclusivité abonnés Business.
  </Card>
</CardGroup>

<Note>
  **Évaluation côté serveur.** Chaque appel `usePageEnabled` vérifie via API. Les décisions sont mises en cache 30 secondes pour éviter le spam de requêtes.
</Note>
