import './report-modal.css'; import { Fragment } from 'preact'; import { useMemo, useRef, useState } from 'preact/hooks'; import { api } from '../utils/api'; import showToast from '../utils/show-toast'; import { getCurrentInstance } from '../utils/store-utils'; import AccountBlock from './account-block'; import Icon from './icon'; import Loader from './loader'; import Status from './status'; // NOTE: `dislike` hidden for now, it's actually not used for reporting // Mastodon shows another screen for unfollowing, muting or blocking instead of reporting const CATEGORIES = [, /*'dislike'*/ 'spam', 'legal', 'violation', 'other']; // `violation` will be set if there are `rule_ids[]` const CATEGORIES_INFO = { // dislike: { // label: 'Dislike', // description: 'Not something you want to see', // }, spam: { label: 'Spam', description: 'Malicious links, fake engagement, or repetitive replies', }, legal: { label: 'Illegal', description: "Violates the law of your or the server's country", }, violation: { label: 'Server rule violation', description: 'Breaks specific server rules', stampLabel: 'Violation', }, other: { label: 'Other', description: "Issue doesn't fit other categories", excludeStamp: true, }, }; function ReportModal({ account, post, onClose }) { const { masto } = api(); const [uiState, setUIState] = useState('default'); const [username, domain] = account.acct.split('@'); const [rules, currentDomain] = useMemo(() => { const { rules, domain } = getCurrentInstance(); return [rules || [], domain]; }); const [selectedCategory, setSelectedCategory] = useState(null); const [showRules, setShowRules] = useState(false); const rulesRef = useRef(null); const [hasRules, setHasRules] = useState(false); return (