shinkan-jinkendo/frontend/src/utils/featureUsageSync.js
Lars b68185842e
All checks were successful
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m40s
Enhance Club Feature Consumption Logic and Update Versioning
- Introduced the `consume_club_feature_with_usage` function to standardize feature consumption across endpoints, improving code reusability and clarity.
- Implemented `merge_feature_usage_into_response` to embed feature usage data in API responses, streamlining frontend integration.
- Updated various backend routers to utilize the new consumption logic, ensuring consistent feature usage tracking during AI-related actions.
- Enhanced tests to validate the new consumption and logging behavior.
- Incremented application version to 0.8.199 and updated module version for 'club_features' to 1.6.0 to reflect these changes.
2026-06-07 10:32:49 +02:00

27 lines
836 B
JavaScript

/**
* Zentraler Abgleich Vereins-Kontingente nach API-Responses.
*
* Backend-Standard: Jeder Endpoint mit Verbrauch liefert ``feature_usage``
* (siehe club_features.consume_club_feature_with_usage). ``request()`` in
* client.js ruft syncFeatureUsageFromApiResponse() — UI-Komponenten müssen
* nichts Einzelnes tun.
*/
let usageHandler = null
export function registerFeatureUsageSyncHandler(handler) {
usageHandler = typeof handler === 'function' ? handler : null
}
export function unregisterFeatureUsageSyncHandler() {
usageHandler = null
}
/** Wird von request() nach jedem erfolgreichen JSON-Response aufgerufen. */
export function syncFeatureUsageFromApiResponse(data) {
if (!data || typeof data !== 'object' || !data.feature_usage) return
if (typeof usageHandler === 'function') {
usageHandler(data)
}
}