mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 14:48:18 +00:00
feat: add toggle to DJF
This commit is contained in:
@@ -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"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user