import React, { useState, useCallback } from "react"; import { useFetcher } from "@remix-run/react"; import { Button } from "~/components/ui/button"; import { Textarea } from "~/components/ui/textarea"; interface IngestionRuleSectionProps { ingestionRule: { id: string; text: string; } | null; activeAccount: any; } export function IngestionRuleSection({ ingestionRule, activeAccount, }: IngestionRuleSectionProps) { const [ingestionRuleText, setIngestionRuleText] = useState( ingestionRule?.text || "", ); const ingestionRuleFetcher = useFetcher(); const handleIngestionRuleUpdate = useCallback(() => { ingestionRuleFetcher.submit( { ingestionRule: ingestionRuleText, }, { method: "post", }, ); }, [ingestionRuleText, ingestionRuleFetcher]); React.useEffect(() => { if (ingestionRuleFetcher.state === "idle") { // Optionally show success message or refresh } }, [ingestionRuleFetcher.state, ingestionRuleFetcher.data]); if (!activeAccount) { return null; } return (