mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-06 15:55:02 +00:00
feat(freight-backoffice): rework settings pages for the per-currency API
exchangeSettings.service/hook/card follow the backend's new shape: a single ExchangeSettings object becomes a list, get() becomes list(), and setFallbackRate(rate) becomes setFallbackRate(currency, rate). ExchangeRateSettingsCard now renders one row per currency instead of one hardcoded USD->ETB form. manualPaymentSettings.service/hook/card add djfEnabled alongside etb/usdEnabled, matching the backend's new column. InvoicesPage's collected-summary KPI strip adds a DJF tile and folds its ETB-equivalent into the existing 'Total collected' conversion, reading each currency's rate from the now-list-shaped settings query. Claude-Session: https://claude.ai/code/session_01CZy77vCWhka3pnmVF9NDkL
This commit is contained in:
@@ -7,10 +7,11 @@ import { useErrorHandler } from "@/shared/hooks/useErrorHandler";
|
||||
|
||||
const QUERY_KEY = ["exchangeSettings"];
|
||||
|
||||
/** One row per foreign currency (USD, DJF, …) — see `exchangeSettingsService.list`. */
|
||||
export const useExchangeSettingsQuery = () =>
|
||||
useQuery({
|
||||
queryKey: QUERY_KEY,
|
||||
queryFn: () => exchangeSettingsService.get(),
|
||||
queryFn: () => exchangeSettingsService.list(),
|
||||
// Feed health is only interesting while it is being looked at.
|
||||
staleTime: 30_000,
|
||||
refetchOnWindowFocus: true,
|
||||
@@ -22,7 +23,8 @@ export const useSetExchangeFallbackRate = () => {
|
||||
const { handleError } = useErrorHandler(t);
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (rate: number) => exchangeSettingsService.setFallbackRate(rate),
|
||||
mutationFn: ({ currency, rate }: { currency: string; rate: number }) =>
|
||||
exchangeSettingsService.setFallbackRate(currency, rate),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: QUERY_KEY });
|
||||
toast.success(
|
||||
|
||||
@@ -24,7 +24,9 @@ export const useUpdateManualPaymentSettings = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (
|
||||
patch: Partial<Pick<ManualPaymentSettings, "etbEnabled" | "usdEnabled">>,
|
||||
patch: Partial<
|
||||
Pick<ManualPaymentSettings, "etbEnabled" | "usdEnabled" | "djfEnabled">
|
||||
>,
|
||||
) => manualPaymentSettingsService.update(patch),
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(MANUAL_PAYMENT_SETTINGS_KEY, data);
|
||||
|
||||
Reference in New Issue
Block a user