import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { create_tasks, get_tasks } from '../../service.ts'; import { Button } from '../shared/Button.tsx'; import { ConfigurationWarning } from '../shared/ConfigurationWarning.tsx'; import { ErrorMessage } from '../shared/ErrorMessage.tsx'; import { Spinner } from '../shared/Spinner.tsx'; import { TaskInfo } from './TaskInfo.tsx'; interface OrderMetaBoxProps { order_id: number; order_key: string; } export function OrderMetaBox({ order_id, order_key }: OrderMetaBoxProps) { const query_client = useQueryClient(); const get_task_query = useQuery({ queryKey: ['tasks', order_key], queryFn: async () => get_tasks([order_key]), refetchOnWindowFocus: true, }); const create_task_mutation = useMutation({ mutationFn: async () => create_tasks([order_id]), onSuccess: async () => { await query_client.invalidateQueries({ queryKey: ['tasks', order_key] }); }, }); // Check if plugin is configured before attempting API calls const is_configured = window.JAAK_IS_CONFIGURED === true; if (!is_configured) { return (