opencrm/frontend/src/hooks/useProviderSettings.ts

27 lines
944 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useQuery } from '@tanstack/react-query';
import { emailProviderApi } from '../services/api';
export interface ProviderSettings {
domain: string | null;
customerEmailLabel: string; // z.B. "Stressfrei-Wechseln" (aus Config oder aus Domain abgeleitet)
customerEmailLabelIsCustom: boolean;
}
/**
* Holt die öffentlichen Provider-Einstellungen (Domain + Label für Kunden-E-Mail-Adressen).
* Mit Default-Fallback bei Ladefehler UI-Labels werden dann generisch angezeigt.
*/
export function useProviderSettings(): ProviderSettings {
const { data } = useQuery({
queryKey: ['email-provider-public-settings'],
queryFn: () => emailProviderApi.getPublicSettings(),
staleTime: 5 * 60_000,
});
return {
domain: data?.data?.domain ?? null,
customerEmailLabel: data?.data?.customerEmailLabel || 'Kunden-E-Mail',
customerEmailLabelIsCustom: data?.data?.customerEmailLabelIsCustom ?? false,
};
}