Statistiques — refonte complète, aucun changement backend statistics_screen.dart réécrit (+1832) : barres horizontales monochromes à la place des barres verticales tronquées et des deux anneaux, barre de filtres unique avec les volumes par canal, règle mono-canal, 4 KPI portant chacun leur variation, bandeau « à retenir », courbe en aire avec bandes de week-end. La période précédente s'obtient en rappelant le même endpoint. statistics_report.dart : export PDF généré côté client (paquet pdf Dart), il partage les valeurs calculées de l'écran — un chiffre ne peut pas diverger entre l'écran et le document envoyé à la commune. Deux puces du sommaire promettaient des données inexistantes (parcours terminés, questions au guide IA), retirées. ⚠️ Jamais ouvert dans un navigateur. Cases de test : test-plan.md §8bis / §8ter. Guide IA Screens/GuideIa/guide_ia_screen.dart — onglet Configuration. Menu conditionné à isAssistant, le même drapeau que la garde d'AiController. L'onglet « Ce que demandent vos visiteurs » n'est pas dans ce commit : le schéma backend est prêt, l'UI non. Onboarding self-service Screens/Auth/ (mot de passe oublié, définition du mot de passe), Screens/Billing/subscription_screen.dart, ai_quota_hint.dart. ⚠️ Aucun parcours joué de bout en bout — test-plan.md §18. Parcours guidés progression_mode.dart : 9 booléens sur 3 niveaux remplacés par 3 questions. Popups GuidedPath / GuidedStep / QuizQuestion mises à jour en conséquence. Client API (manager_api_new) — édité À LA MAIN, ne pas relancer la génération onboarding_api.dart, authentication_api.dart (+80), instance_dto (champs Guide*), guided_step / quiz_question_guided_step (flags morts retirés). Le // @dart=2.18 manquant dans onboarding_api.dart cassait les 3 apps Flutter d'un coup — corrigé ici. i18n : ~180 clés par langue (FR/EN/NL) + fichiers générés. Tests : progression_mode_test, statistics_report_test (le second a attrapé deux plantages qui seraient sortis au premier clic). flutter build web ✅. flutter analyze : 68 erreurs, toutes dans les fichiers modèle orphelins de manager_api_new — dette connue, pas une régression, ces fichiers ne sont pas dans le graphe de compilation.
148 lines
6.0 KiB
Dart
148 lines
6.0 KiB
Dart
import 'dart:html' as html;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/common_loader.dart';
|
|
import 'package:manager_app/Components/message_notification.dart';
|
|
import 'package:manager_app/Components/rounded_button.dart';
|
|
import 'package:manager_app/Models/managerContext.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:manager_app/l10n/app_localizations.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
/// Subscription screen for the Essentiel plan only — Pro/Premium/Enterprise
|
|
/// remain fully manual (contact commercial), so they have no self-service
|
|
/// screen here. Shows trial status + what's included, and lets the user
|
|
/// convert to a paid subscription via a Stripe-hosted Checkout Session.
|
|
///
|
|
/// The "Add-ons" section below is intentionally a placeholder for now — it's
|
|
/// the future home of the paid AI request quota add-on, not implemented yet.
|
|
class SubscriptionScreen extends StatefulWidget {
|
|
const SubscriptionScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_SubscriptionScreenState createState() => _SubscriptionScreenState();
|
|
}
|
|
|
|
class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
|
bool isRedirecting = false;
|
|
|
|
static const _includedFeatures = [
|
|
"App visiteur web, ouverte par QR code — aucune installation",
|
|
"Contenus, agenda, plans et sections illimités",
|
|
"Multilingue — vos visiteurs choisissent leur langue",
|
|
"Vos couleurs et votre logo, votre adresse dédiée",
|
|
];
|
|
|
|
Future<void> _startCheckout(ManagerAppContext ctx) async {
|
|
setState(() => isRedirecting = true);
|
|
try {
|
|
final url = await ctx.clientAPI!.onboardingApi!.onboardingCreateCheckoutSession();
|
|
html.window.open(url, '_blank');
|
|
} catch (e) {
|
|
showNotification(kError, kWhite, AppLocalizations.of(context)!.subscriptionCheckoutError, context, null);
|
|
} finally {
|
|
if (mounted) setState(() => isRedirecting = false);
|
|
}
|
|
}
|
|
|
|
String _formatDate(DateTime date) {
|
|
final d = date.toLocal();
|
|
return "${d.day.toString().padLeft(2, '0')}/${d.month.toString().padLeft(2, '0')}/${d.year}";
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l = AppLocalizations.of(context)!;
|
|
final managerCtx = Provider.of<AppContext>(context).getContext() as ManagerAppContext;
|
|
final instance = managerCtx.instanceDTO;
|
|
final isTrialActive = instance?.isTrialActive == true;
|
|
final trialEndsAt = instance?.trialEndsAt;
|
|
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(l.subscriptionTitle, style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: kPrimaryColor)),
|
|
const SizedBox(height: 16),
|
|
Card(
|
|
elevation: 0,
|
|
color: isTrialActive ? kPrimaryColor.withValues(alpha: 0.06) : kSuccess.withValues(alpha: 0.08),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
side: BorderSide(color: (isTrialActive ? kPrimaryColor : kSuccess).withValues(alpha: 0.25)),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
isTrialActive ? Icons.hourglass_top_rounded : Icons.check_circle_outline,
|
|
color: isTrialActive ? kPrimaryColor : kSuccess,
|
|
size: 32,
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
isTrialActive ? l.subscriptionTrialActive : l.subscriptionPlanActive,
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
isTrialActive
|
|
? (trialEndsAt != null
|
|
? l.subscriptionTrialEndsAt(_formatDate(trialEndsAt))
|
|
: l.subscriptionTrialNoDate)
|
|
: l.subscriptionPlanActiveDesc,
|
|
style: TextStyle(fontSize: 13, color: Colors.grey[700]),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(l.subscriptionIncludedTitle, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
|
const SizedBox(height: 12),
|
|
..._includedFeatures.map((feature) => Padding(
|
|
padding: const EdgeInsets.only(bottom: 8),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Icon(Icons.check, color: kSuccess, size: 18),
|
|
const SizedBox(width: 8),
|
|
Expanded(child: Text(feature, style: const TextStyle(fontSize: 14))),
|
|
],
|
|
),
|
|
)),
|
|
if (isTrialActive) ...[
|
|
const SizedBox(height: 16),
|
|
isRedirecting
|
|
? const CommonLoader(iconSize: 32)
|
|
: RoundedButton(
|
|
text: l.subscriptionUpgradeBtn,
|
|
fontSize: 15,
|
|
vertical: 14,
|
|
horizontal: 24,
|
|
press: () => _startCheckout(managerCtx),
|
|
),
|
|
],
|
|
const SizedBox(height: 32),
|
|
Text(l.subscriptionAddonsTitle, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
l.subscriptionAddonsComingSoon,
|
|
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|