Compare commits
2 Commits
bc5f676cea
...
b22b6da2e1
| Author | SHA1 | Date | |
|---|---|---|---|
| b22b6da2e1 | |||
|
|
9e4d34b5d8 |
@@ -19,6 +19,7 @@ import { logger } from '@/logger';
|
||||
import { PlanGuard } from '@/modules/billing/lib/entitlements';
|
||||
import { getMpAccessToken } from '@/modules/mp';
|
||||
import { createCheckoutPreference, getWebOrigin, MpApiError } from '@/modules/mp/lib';
|
||||
import { CHECKOUT_BACK_PATH } from '../../lib';
|
||||
|
||||
type BatchDeps = {
|
||||
db?: Pick<PrismaClient, 'group' | 'attendee' | 'payment' | 'user'>;
|
||||
@@ -95,7 +96,7 @@ export class CreatePaymentBatch {
|
||||
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 title = input.description?.trim() || group.name;
|
||||
const createPreference = this.deps.createPreference ?? createCheckoutPreference;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { logger } from '@/logger';
|
||||
import { PlanGuard } from '@/modules/billing/lib/entitlements';
|
||||
import { getMpAccessToken } from '@/modules/mp';
|
||||
import { createCheckoutPreference, getWebOrigin } from '@/modules/mp/lib';
|
||||
import { type PaymentRecord, toPaymentDto } from '../../lib';
|
||||
import { CHECKOUT_BACK_PATH, type PaymentRecord, toPaymentDto } from '../../lib';
|
||||
|
||||
type RenewDeps = {
|
||||
db?: Pick<PrismaClient, 'payment' | 'user'>;
|
||||
@@ -83,7 +83,7 @@ export class RenewPaymentLink {
|
||||
return token;
|
||||
}
|
||||
|
||||
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}/payments`;
|
||||
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}${CHECKOUT_BACK_PATH}`;
|
||||
const createPreference = this.deps.createPreference ?? createCheckoutPreference;
|
||||
|
||||
let preference: { initPoint: string; id: string };
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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 = {
|
||||
id: string;
|
||||
groupId: string;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { type PaymentRecord, toPaymentDto } from './helpers';
|
||||
export { CHECKOUT_BACK_PATH, type PaymentRecord, toPaymentDto } from './helpers';
|
||||
|
||||
@@ -142,7 +142,7 @@ describe('create payments batch', () => {
|
||||
unitPrice: 120,
|
||||
currencyId: 'ARS',
|
||||
externalReference: 'pay-1',
|
||||
backUrl: `${webOrigin}/payments`,
|
||||
backUrl: `${webOrigin}/student/payments`,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('renew payment link', () => {
|
||||
unitPrice: 120,
|
||||
currencyId: 'ARS',
|
||||
externalReference: 'pay-1',
|
||||
backUrl: `${webOrigin}/payments`,
|
||||
backUrl: `${webOrigin}/student/payments`,
|
||||
});
|
||||
expect(prisma.payment.update).toHaveBeenCalledWith({
|
||||
where: { id: 'pay-1' },
|
||||
|
||||
@@ -103,7 +103,7 @@ export function InviteToAppSheet({
|
||||
}
|
||||
>
|
||||
<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}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import type { StudentFee } from '@gruperly/shared'
|
||||
import { Receipt } from 'lucide-react'
|
||||
import { ExternalLink, Receipt } from 'lucide-react'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { feeLabel } from './format'
|
||||
@@ -12,6 +12,10 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
|
||||
const first = fees[0] as StudentFee
|
||||
const toReport = fees.filter((fee) => fee.status !== 'reported')
|
||||
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 (
|
||||
<article className="rounded-2xl border border-border bg-surface p-5">
|
||||
@@ -32,13 +36,29 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
|
||||
) : null}
|
||||
</div>
|
||||
{toReport.length > 0 ? (
|
||||
<Link
|
||||
to="/student/report-payment"
|
||||
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"
|
||||
>
|
||||
<Receipt className="size-5" aria-hidden="true" />
|
||||
Informar pago
|
||||
</Link>
|
||||
<div className="mt-4 space-y-2">
|
||||
{single ? (
|
||||
<a href={single.checkoutUrl ?? undefined} target="_blank" rel="noreferrer" className={primary}>
|
||||
Pagar con Mercado Pago
|
||||
<ExternalLink className="size-4" aria-hidden="true" />
|
||||
</a>
|
||||
) : 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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user