All files / src/composables useReportDecisionSummary.ts

100% Statements 11/11
100% Branches 8/8
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29              31x 31x     11x 11x 11x 1x           10x 8x   11x     31x    
// @implements UC-REPORT-005.1, UC-REPORT-010.1
import type { AdminReportDecision } from '@/stores/admin'
import { useUILanguage } from '@/composables/useUILanguage'
import { useDateFormat } from '@/composables/useDateFormat'
 
/** "Content removed · Restricted until …": what a decision on reports did */
export function useReportDecisionSummary() {
  const { t } = useUILanguage()
  const { formatDateTime } = useDateFormat()
 
  function decisionSummary(decision: AdminReportDecision): string {
    const parts: string[] = []
    if (decision.removed) parts.push(t('report.admin.removed'))
    if (decision.sanction === 'restriction' && decision.restrictedUntil) {
      parts.push(
        t('report.admin.restrictedUntil').replace(
          '{date}',
          formatDateTime(decision.restrictedUntil)
        )
      )
    } else if (decision.sanction) {
      parts.push(t(`report.decision.sanctions.${decision.sanction}`))
    }
    return parts.join(' · ')
  }
 
  return { decisionSummary }
}