feat: affichage dynamique des compteurs sync/non sync sur la page admin/sync
src/Controller/Admin/SyncController.php - index(): - Calcul du nombre de tarifs synchronises avec Stripe (stripeId non vide) et non synchronises, passes au template - Chargement des StripeWebhookSecret depuis la BDD pour afficher le nombre de webhooks configures templates/admin/sync/index.html.twig: - Bloc Tarifs Stripe: affiche "X sync" (vert) + "Y non sync" (rouge si > 0) + "/ Z total" (gris) au lieu du texte statique - Bloc Webhooks Stripe: affiche "X/4 configure(s)" en vert si 4/4, orange si partiel, rouge si 0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,12 +23,29 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
class SyncController extends AbstractController
|
||||
{
|
||||
#[Route('', name: 'index')]
|
||||
public function index(CustomerRepository $customerRepository, RevendeurRepository $revendeurRepository, PriceAutomaticRepository $priceRepository): Response
|
||||
public function index(CustomerRepository $customerRepository, RevendeurRepository $revendeurRepository, PriceAutomaticRepository $priceRepository, StripeWebhookSecretRepository $secretRepository): Response
|
||||
{
|
||||
$prices = $priceRepository->findAll();
|
||||
$stripeSynced = 0;
|
||||
$stripeNotSynced = 0;
|
||||
|
||||
foreach ($prices as $price) {
|
||||
if (null !== $price->getStripeId() && '' !== $price->getStripeId()) {
|
||||
++$stripeSynced;
|
||||
} else {
|
||||
++$stripeNotSynced;
|
||||
}
|
||||
}
|
||||
|
||||
$webhookSecrets = $secretRepository->findAll();
|
||||
|
||||
return $this->render('admin/sync/index.html.twig', [
|
||||
'totalCustomers' => $customerRepository->count([]),
|
||||
'totalRevendeurs' => $revendeurRepository->count([]),
|
||||
'totalPrices' => $priceRepository->count([]),
|
||||
'totalPrices' => \count($prices),
|
||||
'stripeSynced' => $stripeSynced,
|
||||
'stripeNotSynced' => $stripeNotSynced,
|
||||
'webhookSecrets' => $webhookSecrets,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,13 @@
|
||||
<div>
|
||||
<h2 class="font-bold uppercase text-sm">Tarifs - Stripe</h2>
|
||||
<p class="text-xs text-gray-500">Cree les produits et prix dans Stripe</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ totalPrices }} tarif(s) a synchroniser</p>
|
||||
<p class="text-xs mt-0.5">
|
||||
<span class="text-green-600 font-bold">{{ stripeSynced }} sync</span>
|
||||
{% if stripeNotSynced > 0 %}
|
||||
<span class="text-red-600 font-bold ml-2">{{ stripeNotSynced }} non sync</span>
|
||||
{% endif %}
|
||||
<span class="text-gray-400 ml-1">/ {{ totalPrices }} total</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" action="{{ path('app_admin_sync_stripe_prices') }}" data-confirm="Synchroniser tous les tarifs avec Stripe ? Les produits et prix seront crees ou mis a jour.">
|
||||
@@ -129,6 +135,9 @@
|
||||
<div>
|
||||
<h2 class="font-bold uppercase text-sm">Webhooks Stripe</h2>
|
||||
<p class="text-xs text-gray-500">Cree les 4 endpoints : main light/instant + connect light/instant</p>
|
||||
<p class="text-xs mt-0.5">
|
||||
<span class="font-bold {{ webhookSecrets|length >= 4 ? 'text-green-600' : (webhookSecrets|length > 0 ? 'text-orange-600' : 'text-red-600') }}">{{ webhookSecrets|length }}/4 configure(s)</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" action="{{ path('app_admin_sync_stripe_webhooks') }}" data-confirm="Creer les webhooks Stripe ? Les secrets seront sauvegardes dans .env.local">
|
||||
|
||||
Reference in New Issue
Block a user