adasd
All checks were successful
Deploy / deploy-staging (push) Successful in 5s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-29 01:31:47 +02:00
parent b76edb49b0
commit af1d94a3b6
5 changed files with 75 additions and 24 deletions

View File

@@ -115,19 +115,6 @@
}
});
root.querySelector('[data-action="refresh-catalog"]')?.addEventListener('click', async () => {
try {
setLoading(true);
setMessage('Ich synchronisiere jetzt den Waehrungskatalog.');
const data = await request('/currencies-refresh', { method: 'POST', body: JSON.stringify({}) });
setMessage(`Waehrungskatalog synchronisiert. ${data?.synced_count || 0} Waehrungen verarbeitet.`, 'success');
} catch (error) {
setMessage(error.message || 'Waehrungskatalog konnte nicht synchronisiert werden.', 'error');
} finally {
setLoading(false);
}
});
root.querySelector('[data-action="save-settings"]')?.addEventListener('click', async () => {
try {
setLoading(true);

View File

@@ -129,6 +129,23 @@ $mm->registerFunction($moduleName, 'service', static function (): FxRatesService
);
});
$mm->registerFunction($moduleName, 'setup_actions', static function (): array {
return [
[
'name' => 'sync_currency_catalog',
'label' => 'Waehrungskatalog synchronisieren',
'help' => 'Laedt die verfuegbaren Waehrungen einmalig aus dem konfigurierten FX-Provider.',
],
];
});
$mm->registerFunction($moduleName, 'run_setup_action', static function (string $action): array {
return match ($action) {
'sync_currency_catalog' => module_fn('fx-rates', 'service')->refreshCurrencyCatalog(),
default => throw new \RuntimeException('Unbekannte Setup-Aktion.'),
};
});
$mm->registerFunction($moduleName, 'refresh_latest', static function (?array $currencies = null, ?string $baseCurrency = null): array {
return module_fn('fx-rates', 'service')->refreshLatestRates($currencies, $baseCurrency);
});

View File

@@ -30,7 +30,6 @@ $pageData = json_encode([
</div>
<div class="fx-actions">
<button type="button" class="fx-button fx-button--primary" data-action="refresh-rates">Aktuelle Kurse abrufen</button>
<button type="button" class="fx-button" data-action="refresh-catalog">Waehrungskatalog sync</button>
</div>
</div>
<div class="fx-meta-grid">
@@ -79,7 +78,6 @@ $pageData = json_encode([
</tbody>
</table>
</div>
<p class="fx-api-note">API: <code>/api/fx-rates/v1/latest</code>, <code>/api/fx-rates/v1/rate</code>, <code>/api/fx-rates/v1/history</code>, <code>/api/fx-rates/v1/refresh</code></p>
</div>
</div>
</div>

View File

@@ -88,14 +88,6 @@ final class Router
$this->respond(['data' => $this->service->probeLatestRates($base)]);
}
if ($path === 'v1/currencies-probe' && $method === 'GET') {
$this->respond(['data' => $this->service->probeCurrencyCatalog()]);
}
if ($path === 'v1/currencies-refresh' && $method === 'POST') {
$this->respond(['data' => $this->service->refreshCurrencyCatalog()], 201);
}
if ($path === 'v1/settings' && $method === 'GET') {
$this->respond(['data' => module_fn('fx-rates', 'settings')]);
}