feat: add toggle to DJF

This commit is contained in:
ghost2023
2026-09-06 16:35:14 +03:00
parent aa96bb4086
commit eab36a2526
21 changed files with 337 additions and 41 deletions

View File

@@ -9,6 +9,18 @@ import {
import { useErrorHandler } from "@/shared/hooks/useErrorHandler";
export const MANUAL_PAYMENT_SETTINGS_KEY = ["manualPaymentSettings"];
export const PAYMENT_CURRENCIES_KEY = ["paymentCurrencies"];
/**
* Currencies a booking may be billed in right now. Open read, so forms can
* hide a switched-off currency without needing the settings permission.
*/
export const usePaymentCurrenciesQuery = () =>
useQuery({
queryKey: PAYMENT_CURRENCIES_KEY,
queryFn: () => manualPaymentSettingsService.currencies(),
staleTime: 60_000,
});
export const useManualPaymentSettingsQuery = () =>
useQuery({
@@ -25,13 +37,18 @@ export const useUpdateManualPaymentSettings = () => {
return useMutation({
mutationFn: (
patch: Partial<
Pick<ManualPaymentSettings, "etbEnabled" | "usdEnabled" | "djfEnabled">
Pick<
ManualPaymentSettings,
"etbEnabled" | "usdEnabled" | "djfEnabled" | "djfPaymentsEnabled"
>
>,
) => manualPaymentSettingsService.update(patch),
onSuccess: (data) => {
queryClient.setQueryData(MANUAL_PAYMENT_SETTINGS_KEY, data);
// The Manual Payments worklist only lists enabled currencies.
// The Manual Payments worklist only lists enabled currencies, and the
// booking forms only offer currencies that are switched on.
queryClient.invalidateQueries({ queryKey: ["invoices"] });
queryClient.invalidateQueries({ queryKey: PAYMENT_CURRENCIES_KEY });
toast.success(
t("manualPaymentSettings.updated", "Manual payment settings updated"),
);