Files
ncd-fe/packages/pl-hooks/lib/hooks/statuses/use-status-translation.ts
nicole mikołajczyk bbf0325146 pl-hooks: migrate from eslint
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
2026-02-24 14:01:33 +01:00

27 lines
784 B
TypeScript

import { useQuery } from '@tanstack/react-query';
import { usePlHooksApiClient } from '@/contexts/api-client';
import { usePlHooksQueryClient } from '@/contexts/query-client';
import type { Translation } from 'pl-api';
const useStatusTranslation = (statusId: string, targetLanguage?: string) => {
const { client } = usePlHooksApiClient();
const queryClient = usePlHooksQueryClient();
return useQuery<Translation | false>(
{
queryKey: ['statuses', 'translations', statusId, targetLanguage],
queryFn: () =>
client.statuses
.translateStatus(statusId, targetLanguage)
.then((translation) => translation)
.catch(() => false),
enabled: !!targetLanguage,
},
queryClient,
);
};
export { useStatusTranslation };