mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 08:53:51 +00:00
8d2d8ef979
* feat: add user defined translations * add refetch key for translation (#1757) --------- Co-authored-by: Alex Christoffer Rasmussen <ac@omnivox.dk>
17 lines
598 B
TypeScript
17 lines
598 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { langEn } from 'ontime-types';
|
|
|
|
import { getUserTranslation } from '../../common/api/assets';
|
|
import { TRANSLATION } from '../../common/api/constants';
|
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
|
|
|
export function useCustomTranslation() {
|
|
const { data, status, refetch } = useQuery({
|
|
queryKey: TRANSLATION,
|
|
queryFn: getUserTranslation,
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
refetchInterval: queryRefetchIntervalSlow,
|
|
});
|
|
return { data: data ?? langEn, status, refetch };
|
|
}
|