development #14

Merged
jselesan merged 102 commits from development into main 2026-11-07 13:21:43 +00:00
788 changed files with 66134 additions and 1203 deletions
Showing only changes of commit 9e4d34b5d8 - Show all commits

View File

@@ -19,6 +19,7 @@ import { logger } from '@/logger';
import { PlanGuard } from '@/modules/billing/lib/entitlements'; import { PlanGuard } from '@/modules/billing/lib/entitlements';
import { getMpAccessToken } from '@/modules/mp'; import { getMpAccessToken } from '@/modules/mp';
import { createCheckoutPreference, getWebOrigin, MpApiError } from '@/modules/mp/lib'; import { createCheckoutPreference, getWebOrigin, MpApiError } from '@/modules/mp/lib';
import { CHECKOUT_BACK_PATH } from '../../lib';
type BatchDeps = { type BatchDeps = {
db?: Pick<PrismaClient, 'group' | 'attendee' | 'payment' | 'user'>; db?: Pick<PrismaClient, 'group' | 'attendee' | 'payment' | 'user'>;
@@ -95,7 +96,7 @@ export class CreatePaymentBatch {
return token; return token;
} }
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}/payments`; const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}${CHECKOUT_BACK_PATH}`;
const dueDate = new Date(input.dueDate); const dueDate = new Date(input.dueDate);
const title = input.description?.trim() || group.name; const title = input.description?.trim() || group.name;
const createPreference = this.deps.createPreference ?? createCheckoutPreference; const createPreference = this.deps.createPreference ?? createCheckoutPreference;

View File

@@ -12,7 +12,7 @@ import { logger } from '@/logger';
import { PlanGuard } from '@/modules/billing/lib/entitlements'; import { PlanGuard } from '@/modules/billing/lib/entitlements';
import { getMpAccessToken } from '@/modules/mp'; import { getMpAccessToken } from '@/modules/mp';
import { createCheckoutPreference, getWebOrigin } from '@/modules/mp/lib'; import { createCheckoutPreference, getWebOrigin } from '@/modules/mp/lib';
import { type PaymentRecord, toPaymentDto } from '../../lib'; import { CHECKOUT_BACK_PATH, type PaymentRecord, toPaymentDto } from '../../lib';
type RenewDeps = { type RenewDeps = {
db?: Pick<PrismaClient, 'payment' | 'user'>; db?: Pick<PrismaClient, 'payment' | 'user'>;
@@ -83,7 +83,7 @@ export class RenewPaymentLink {
return token; return token;
} }
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}/payments`; const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}${CHECKOUT_BACK_PATH}`;
const createPreference = this.deps.createPreference ?? createCheckoutPreference; const createPreference = this.deps.createPreference ?? createCheckoutPreference;
let preference: { initPoint: string; id: string }; let preference: { initPoint: string; id: string };

View File

@@ -1,5 +1,9 @@
import type { PaymentDto } from '@gruperly/shared'; import type { PaymentDto } from '@gruperly/shared';
/* Where Mercado Pago sends whoever paid a Checkout Pro link: the student app
(without a student session it falls through to /access). */
export const CHECKOUT_BACK_PATH = '/student/payments';
export type PaymentRecord = { export type PaymentRecord = {
id: string; id: string;
groupId: string; groupId: string;

View File

@@ -1 +1 @@
export { type PaymentRecord, toPaymentDto } from './helpers'; export { CHECKOUT_BACK_PATH, type PaymentRecord, toPaymentDto } from './helpers';

View File

@@ -142,7 +142,7 @@ describe('create payments batch', () => {
unitPrice: 120, unitPrice: 120,
currencyId: 'ARS', currencyId: 'ARS',
externalReference: 'pay-1', externalReference: 'pay-1',
backUrl: `${webOrigin}/payments`, backUrl: `${webOrigin}/student/payments`,
}); });
}); });

View File

@@ -101,7 +101,7 @@ describe('renew payment link', () => {
unitPrice: 120, unitPrice: 120,
currencyId: 'ARS', currencyId: 'ARS',
externalReference: 'pay-1', externalReference: 'pay-1',
backUrl: `${webOrigin}/payments`, backUrl: `${webOrigin}/student/payments`,
}); });
expect(prisma.payment.update).toHaveBeenCalledWith({ expect(prisma.payment.update).toHaveBeenCalledWith({
where: { id: 'pay-1' }, where: { id: 'pay-1' },

View File

@@ -103,7 +103,7 @@ export function InviteToAppSheet({
} }
> >
<div className="space-y-4"> <div className="space-y-4">
<div className="rounded-2xl rounded-tl-sm bg-success-soft px-4 py-3 text-sm text-primary" aria-label="Vista previa del mensaje"> <div className="rounded-2xl rounded-tl-sm bg-success-soft px-4 py-3 text-sm text-primary break-words" aria-label="Vista previa del mensaje">
{preview} {preview}
</div> </div>

View File

@@ -1,6 +1,6 @@
import { Link } from '@tanstack/react-router' import { Link } from '@tanstack/react-router'
import type { StudentFee } from '@gruperly/shared' import type { StudentFee } from '@gruperly/shared'
import { Receipt } from 'lucide-react' import { ExternalLink, Receipt } from 'lucide-react'
import { Badge } from '../../components/ui' import { Badge } from '../../components/ui'
import { formatPrice } from '../../lib/format' import { formatPrice } from '../../lib/format'
import { feeLabel } from './format' import { feeLabel } from './format'
@@ -12,6 +12,10 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
const first = fees[0] as StudentFee const first = fees[0] as StudentFee
const toReport = fees.filter((fee) => fee.status !== 'reported') const toReport = fees.filter((fee) => fee.status !== 'reported')
const total = toReport.reduce((sum, fee) => sum + fee.amount, 0) const total = toReport.reduce((sum, fee) => sum + fee.amount, 0)
// Cada cuota tiene su propio link de MP: con varias, se elige en Pagos.
const payable = toReport.filter((fee) => fee.checkoutUrl)
const single = payable.length === 1 ? (payable[0] as StudentFee) : null
const primary = 'flex min-h-12 items-center justify-center gap-2 rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong'
return ( return (
<article className="rounded-2xl border border-border bg-surface p-5"> <article className="rounded-2xl border border-border bg-surface p-5">
@@ -32,13 +36,29 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
) : null} ) : null}
</div> </div>
{toReport.length > 0 ? ( {toReport.length > 0 ? (
<Link <div className="mt-4 space-y-2">
to="/student/report-payment" {single ? (
className="mt-4 flex min-h-12 items-center justify-center gap-2 rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong" <a href={single.checkoutUrl ?? undefined} target="_blank" rel="noreferrer" className={primary}>
> Pagar con Mercado Pago
<Receipt className="size-5" aria-hidden="true" /> <ExternalLink className="size-4" aria-hidden="true" />
Informar pago </a>
</Link> ) : payable.length > 1 ? (
<Link to="/student/payments" className={primary}>
Pagar con Mercado Pago
</Link>
) : null}
<Link
to="/student/report-payment"
className={
payable.length > 0
? 'flex min-h-12 items-center justify-center gap-2 rounded-xl border border-border font-semibold text-primary hover:bg-primary-soft'
: primary
}
>
<Receipt className="size-5" aria-hidden="true" />
Informar pago
</Link>
</div>
) : ( ) : (
<p className="mt-3 text-sm text-secondary">Tu profe tiene que confirmar el pago que informaste.</p> <p className="mt-3 text-sm text-secondary">Tu profe tiene que confirmar el pago que informaste.</p>
)} )}