Files
gruperly/apps/web/src/features/student-app/PaymentReviewBanner.tsx
2026-11-03 14:05:21 -03:00

37 lines
1.5 KiB
TypeScript

import type { StudentPaymentReport } from '@gruperly/shared'
import { CheckCircle2, XCircle } from 'lucide-react'
import { formatPrice } from '../../lib/format'
import { useTranslation } from 'react-i18next'
const RECENT_MS = 7 * 24 * 60 * 60 * 1000
/* In-app notice of the teacher's review: the latest report reviewed in the
last week (the student is also emailed if they confirmed a recovery email). */
export function PaymentReviewBanner({ reports }: { reports: StudentPaymentReport[] }) {
const { t } = useTranslation(['student', 'common'])
const latest = reports.find(
(report) => report.status !== 'reported' && report.reviewedAt && Date.now() - Date.parse(report.reviewedAt) < RECENT_MS,
)
if (!latest) return null
const amount = formatPrice(latest.totalAmount, latest.currency)
if (latest.status === 'confirmed') {
return (
<p role="status" className="flex gap-3 rounded-2xl bg-success-soft px-4 py-3 text-sm text-primary">
<CheckCircle2 className="size-5 shrink-0 text-success" aria-hidden="true" />
<span>{t('review.confirmed', { amount })}</span>
</p>
)
}
return (
<p role="status" className="flex gap-3 rounded-2xl bg-danger-soft px-4 py-3 text-sm text-primary">
<XCircle className="size-5 shrink-0 text-danger-fg" aria-hidden="true" />
<span>
{t('review.rejected', { amount })}
{latest.rejectionReason ? t('review.reason', { reason: latest.rejectionReason }) : ''}
{t('review.retry')}
</span>
</p>
)
}