• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CaptainFact / captain-fact-frontend / 20411409289

21 Dec 2025 02:42PM UTC coverage: 1.46% (-1.8%) from 3.249%
20411409289

push

github

Betree
iterate

26 of 1952 branches covered (1.33%)

Branch coverage included in aggregate %.

1 of 8 new or added lines in 4 files covered. (12.5%)

528 existing lines in 32 files now uncovered.

39 of 2500 relevant lines covered (1.56%)

0.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/components/Moderation/ModerationForm.jsx
1
import { useMutation } from '@apollo/client'
2
import { Formik } from 'formik'
3
import { ShieldBan, ShieldCheck, ShieldQuestion } from 'lucide-react'
4
import React from 'react'
5
import { useTranslation } from 'react-i18next'
6

7
import { MODERATE_ACTION_MUTATION } from '../../API/graphql_queries'
8
import {
9
  MODERATION_ACTION_ABUSIVE,
10
  MODERATION_ACTION_CONFIRM,
11
  MODERATION_ACTION_NOTSURE,
12
} from '../../constants'
13
import { useLoggedInUser } from '../LoggedInUser/UserProvider'
14
import { Button } from '../ui/button'
15
import FlagReasonSelect from './FlagReasonSelect'
16

17
const ModerationForm = ({ action, onSubmit }) => {
×
UNCOV
18
  const { t } = useTranslation('moderation')
×
UNCOV
19
  const { user, loading: userLoading } = useLoggedInUser()
×
UNCOV
20
  const [moderateAction, { loading: moderatingLoading }] = useMutation(MODERATE_ACTION_MUTATION)
×
21

UNCOV
22
  const handleSubmit = async (values, { resetForm }) => {
×
UNCOV
23
    try {
×
24
      await moderateAction({
×
25
        variables: {
26
          actionId: action.id,
27
          reason: parseInt(values.reason, 10),
28
          value: values.value,
29
        },
30
      })
UNCOV
31
      resetForm()
×
UNCOV
32
      if (onSubmit) {
×
UNCOV
33
        onSubmit()
×
34
      }
35
    } catch (error) {
UNCOV
36
      console.error('Error moderating action:', error)
×
37
    }
38
  }
39

UNCOV
40
  const submitAction = (value) => (formikProps) => {
×
UNCOV
41
    formikProps.setFieldValue('value', value)
×
UNCOV
42
    formikProps.handleSubmit()
×
43
  }
44

UNCOV
45
  return (
×
46
    <Formik initialValues={{ reason: '', value: null }} onSubmit={handleSubmit} enableReinitialize>
47
      {({ values, handleSubmit }) => (
UNCOV
48
        <div>
×
49
          <h4 className="text-lg font-medium mb-4 dark:text-foreground">{t('whyReport')}</h4>
50
          <FlagReasonSelect />
51
          <div className="flex gap-2 mt-6 flex-wrap">
52
            <Button
53
              className="flex-1"
54
              variant="outline"
55
              disabled={!values.reason || userLoading || moderatingLoading}
×
56
              onClick={submitAction(MODERATION_ACTION_ABUSIVE)}
57
              loading={moderatingLoading}
58
            >
59
              <ShieldBan size={16} />
60
              {t('actions.flag_abusive')}
61
            </Button>
62
            <Button
63
              className="flex-1"
64
              variant="outline"
65
              disabled={!values.reason || userLoading || moderatingLoading}
×
66
              onClick={submitAction(MODERATION_ACTION_NOTSURE)}
67
              loading={moderatingLoading}
68
            >
69
              <ShieldQuestion size={16} />
70
              {t('actions.unsure')}
71
            </Button>
72
            <Button
73
              className="flex-1"
74
              variant="outline"
75
              disabled={!values.reason || userLoading || moderatingLoading}
×
76
              onClick={submitAction(MODERATION_ACTION_CONFIRM)}
77
              loading={moderatingLoading}
78
            >
79
              <ShieldCheck size={16} />
80
              {t('actions.confirm')}
81
            </Button>
82
          </div>
83
        </div>
84
      )}
85
    </Formik>
86
  )
87
}
88

89
export default ModerationForm
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc