feat: add payment report notes
This commit is contained in:
@@ -116,6 +116,13 @@ export function ReportedPaymentCard({ report, onOpenReceipt, onConfirm, onReject
|
||||
<ChevronRight className="size-4 shrink-0 text-foreground" aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
{report.note ? (
|
||||
<p className="mt-3 whitespace-pre-line break-words rounded-xl border border-border px-3 py-2 text-sm text-primary">
|
||||
<span className="block text-xs font-medium text-secondary">Nota del alumno</span>
|
||||
{report.note}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{rejecting ? (
|
||||
<form
|
||||
className="mt-3 space-y-2"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useState } from 'react'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ArrowLeft, Info, Loader2 } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { REPORTED_PAYMENT_NOTE_MAX } from '@gruperly/shared'
|
||||
import { Button, Label } from '../../components/ui'
|
||||
import { ApiError } from '../../lib/api'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { FeeStatusBadge } from './FeeStatusBadge'
|
||||
@@ -17,6 +18,7 @@ export function ReportPaymentView() {
|
||||
const { student, fees, reportPayment } = useStudentApp()
|
||||
const [selected, setSelected] = useState<string[] | null>(null)
|
||||
const [file, setFile] = useState<File | null>(null)
|
||||
const [note, setNote] = useState('')
|
||||
|
||||
if (!student || !fees) {
|
||||
return (
|
||||
@@ -51,7 +53,7 @@ export function ReportPaymentView() {
|
||||
|
||||
const submit = () => {
|
||||
if (chosen.length === 0 || !file) return
|
||||
reportPayment.mutate({ paymentIds: chosen, file })
|
||||
reportPayment.mutate({ paymentIds: chosen, note: note.trim() || null, file })
|
||||
}
|
||||
|
||||
const errorText =
|
||||
@@ -106,6 +108,19 @@ export function ReportPaymentView() {
|
||||
<ReceiptDropzone file={file} onChange={setFile} />
|
||||
</section>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="report-note">Nota para {teacher} (opcional)</Label>
|
||||
<textarea
|
||||
id="report-note"
|
||||
value={note}
|
||||
onChange={(event) => setNote(event.target.value)}
|
||||
maxLength={REPORTED_PAYMENT_NOTE_MAX}
|
||||
rows={3}
|
||||
placeholder="Ej.: pagué desde la cuenta de mi mamá"
|
||||
className="w-full rounded-xl border border-border bg-surface px-3 py-2 text-base text-primary placeholder:text-foreground/50 focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/30 sm:text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p className="flex gap-2 text-xs text-secondary">
|
||||
<Info className="mt-0.5 size-4 shrink-0" aria-hidden="true" />
|
||||
{teacher} va a confirmar el pago. Mientras tanto figura como Informado.
|
||||
|
||||
@@ -87,7 +87,7 @@ function useCancelAbsence(attendeeId: string | null) {
|
||||
function useReportPayment(attendeeId: string | null) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (input: { paymentIds: string[]; file: File }) =>
|
||||
mutationFn: (input: { paymentIds: string[]; note: string | null; file: File }) =>
|
||||
reportStudentPayment({ ...input, attendeeId: attendeeId ?? '' }),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['student', 'fees', attendeeId] }),
|
||||
})
|
||||
|
||||
@@ -100,6 +100,9 @@ export function StudentPaymentsView() {
|
||||
<Badge variant={REPORT_BADGE[report.status].variant}>{REPORT_BADGE[report.status].label}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
{report.note ? (
|
||||
<p className="mt-2 whitespace-pre-line break-words text-xs text-secondary">Tu nota: {report.note}</p>
|
||||
) : null}
|
||||
{report.status === 'rejected' && report.rejectionReason ? (
|
||||
<p className="mt-2 rounded-lg bg-danger-soft px-3 py-2 text-xs text-primary">Motivo: {report.rejectionReason}</p>
|
||||
) : null}
|
||||
|
||||
@@ -507,10 +507,11 @@ export const cancelStudentAbsence = (noticeId: string) =>
|
||||
export const getStudentFees = (attendeeId: string) =>
|
||||
apiFetch<StudentFeesDto>(`${STUDENT_API}/fees?attendeeId=${encodeURIComponent(attendeeId)}`)
|
||||
|
||||
export const reportStudentPayment = (payload: { attendeeId: string; paymentIds: string[]; file: File }) => {
|
||||
export const reportStudentPayment = (payload: { attendeeId: string; paymentIds: string[]; note?: string | null; file: File }) => {
|
||||
const form = new FormData()
|
||||
form.set('attendeeId', payload.attendeeId)
|
||||
for (const id of payload.paymentIds) form.append('paymentIds', id)
|
||||
if (payload.note) form.set('note', payload.note)
|
||||
form.set('file', payload.file)
|
||||
return apiFetch<{ id: string }>(`${STUDENT_API}/payment-reports`, { method: 'POST', body: form })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user