// AK-P21 (AD-28 interim polish) — global feedback widget. The mini form is a
// real ~/ui Dialog (size XS 420) with a category select (bug/feature/question,
// designer brief P21); the category is prefixed into the message because the
// support-ticket contract intentionally has no category column. Shared by the
// legacy NavBar trigger (mobile visibility restriction removed) and the shadcn
// nav-actions trigger. Submission keeps the established add-feedback intent on
// the tenant root route (rate limit 3/24h lives in Feedback.server).
//
// Instead of the originally sketched screenshot checkbox, the reporter attaches
// an image themselves (decision 2026-07-21): the client never captures the page
// on its own, so no third-party personal data leaves the workspace without the
// reporter consciously picking the file. The upload is fail-closed scanned and
// ClamAV-checked server-side.
import { useFetcher, useLocation, useParams } from "react-router";
import { Fragment, useEffect, useState } from "react";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
import StarsIconFilled from "~/components/ui/icons/StarsIconFilled";
import { appPath } from "~/utils/app/CanonicalUrlUtils";
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
import { useRootData } from "~/utils/data/useRootData";
import { Button } from "~/ui/components/Button";
import { Dialog } from "~/ui/components/Dialog";
import { Select } from "~/ui/components/Select";
import { TextArea } from "~/ui/components/TextArea";
const FEEDBACK_CATEGORIES = ["bug", "feature", "question"] as const;
type FeedbackCategory = (typeof FEEDBACK_CATEGORIES)[number];
/** Mirrors the server-side contract in Feedback.server. */
const FEEDBACK_ATTACHMENT_ACCEPT = "image/png,image/jpeg,image/webp,image/gif";
const FEEDBACK_ATTACHMENT_MAX_MB = 5;
export default function AddFeedbackButton() {
const [isOpen, setIsOpen] = useState(false);
const { t } = useTranslation();
return (