"use client"; import { useImperativeHandle, useRef } from "react"; import { Alert, Button, Group, Skeleton, Stack, Text } from "@mantine/core"; import { IconInfoCircle } from "@tabler/icons-react"; import { clientApi } from "@homarr/api/client"; import { getIntegrationName } from "@homarr/definitions"; import { useI18n } from "@homarr/translation/client"; import { IntegrationAvatar } from "@homarr/ui"; import type { EmbeddedIntegrationEditFormProps } from "@homarr/widgets/modals"; import type { EditIntegrationFormHandle } from "~/app/[locale]/manage/integrations/edit/[id]/_integration-edit-form"; import { EditIntegrationForm } from "~/app/[locale]/manage/integrations/edit/[id]/_integration-edit-form"; export type { EmbeddedIntegrationEditFormProps } from "@homarr/widgets/modals"; export const EmbeddedIntegrationEditForm = ({ integrationId, handleRef, onSuccess, }: EmbeddedIntegrationEditFormProps) => { const t = useI18n(); const integrationFormRef = useRef(null); const { data: integration, isPending, isError, refetch, } = clientApi.integration.byId.useQuery({ id: integrationId, }); useImperativeHandle( handleRef, () => ({ submitIfDirty: async () => { if (!integrationFormRef.current?.isDirty()) { return true; } return integrationFormRef.current.submit(); }, }), [], ); if (isPending) { return ( ); } if (isError || !integration) { return ( {t("item.edit.integration.loadError")} ); } return ( {integration.name} {getIntegrationName(integration.kind)} } color="blue" variant="light"> {t("item.edit.integration.propagationNotice")} ); };