development #14

Merged
jselesan merged 102 commits from development into main 2026-11-07 13:21:43 +00:00
545 changed files with 48579 additions and 1196 deletions
Showing only changes of commit bef4056f8e - Show all commits

View File

@@ -1,5 +1,6 @@
import { ArrowLeft, ArrowRight, BadgeCheck, CheckCircle2, Loader2 } from 'lucide-react' import { ArrowLeft, ArrowRight, BadgeCheck, CheckCircle2, Loader2 } from 'lucide-react'
import { Badge, Button } from '../../components/ui' import { Badge, Button } from '../../components/ui'
import { ApiError } from '../../lib/api'
import type { WhatsappCallbackFeedback } from '../whatsapp' import type { WhatsappCallbackFeedback } from '../whatsapp'
import { import {
linksWithQr, linksWithQr,
@@ -8,6 +9,7 @@ import {
WhatsappQrModal, WhatsappQrModal,
whatsappCallbackErrorMessage, whatsappCallbackErrorMessage,
whatsappStatusBadgeVariant, whatsappStatusBadgeVariant,
whatsappStatusErrorMessage,
whatsappStatusLabel, whatsappStatusLabel,
} from '../whatsapp' } from '../whatsapp'
@@ -69,6 +71,12 @@ export function WhatsappStep({ feedback, onNext, onBack }: WhatsappStepProps) {
<Loader2 className="size-4 animate-spin" /> <Loader2 className="size-4 animate-spin" />
Consultando tu WhatsApp… Consultando tu WhatsApp…
</p> </p>
) : statusQuery.isError ? (
<p className="text-sm text-foreground/60">
{whatsappStatusErrorMessage(
statusQuery.error instanceof ApiError ? statusQuery.error.status : null,
)}
</p>
) : ( ) : (
<p className="text-sm text-foreground/60"> <p className="text-sm text-foreground/60">
{usesQr {usesQr

View File

@@ -1,13 +1,14 @@
import { BadgeCheck, Loader2, MessageCircle, Unlink } from 'lucide-react' import { BadgeCheck, Loader2, MessageCircle, Unlink } from 'lucide-react'
import { useState } from 'react' import { useState } from 'react'
import { Badge, Button, Modal } from '../../components/ui' import { Badge, Button, Modal } from '../../components/ui'
import { ApiError } from '../../lib/api'
import { formatMpConnectionDate } from '../mp' import { formatMpConnectionDate } from '../mp'
import { import {
linksWithQr, linksWithQr,
readinessLabel, readinessLabel,
WEEKLY_SEND_LABEL, WEEKLY_SEND_LABEL,
WHATSAPP_UNAVAILABLE_MESSAGE,
whatsappStatusBadgeVariant, whatsappStatusBadgeVariant,
whatsappStatusErrorMessage,
whatsappStatusLabel, whatsappStatusLabel,
} from './copy' } from './copy'
import { useDisconnectWhatsapp } from './useDisconnectWhatsapp' import { useDisconnectWhatsapp } from './useDisconnectWhatsapp'
@@ -39,7 +40,11 @@ export function WhatsappStatusCard() {
return ( return (
<div className="rounded-xl border border-border bg-surface px-4 py-3"> <div className="rounded-xl border border-border bg-surface px-4 py-3">
<p className="text-sm font-medium text-primary">WhatsApp</p> <p className="text-sm font-medium text-primary">WhatsApp</p>
<p className="mt-0.5 text-xs text-foreground/50">{WHATSAPP_UNAVAILABLE_MESSAGE}</p> <p className="mt-0.5 text-xs text-foreground/50">
{whatsappStatusErrorMessage(
statusQuery.error instanceof ApiError ? statusQuery.error.status : null,
)}
</p>
</div> </div>
) )
} }

View File

@@ -16,6 +16,17 @@ export const WHATSAPP_CONNECT_ERROR_MESSAGE =
export const WHATSAPP_UNAVAILABLE_MESSAGE = export const WHATSAPP_UNAVAILABLE_MESSAGE =
'La vinculación con WhatsApp no está disponible en este momento.' 'La vinculación con WhatsApp no está disponible en este momento.'
/**
* Mensaje para un fallo al consultar el estado. Solo un 503 significa "WhatsApp
* no está configurado en este servidor"; cualquier otro código es un error de
* verdad y se muestra con su número para poder rastrearlo.
*/
export function whatsappStatusErrorMessage(httpStatus: number | null): string {
if (httpStatus === 503) return WHATSAPP_UNAVAILABLE_MESSAGE
const code = httpStatus ? ` (error ${httpStatus})` : ''
return `No pudimos consultar el estado de tu WhatsApp${code}. Intentá de nuevo en un rato.`
}
/** Día y hora en que salen los mensajes automáticos (lo fija el job del backend). */ /** Día y hora en que salen los mensajes automáticos (lo fija el job del backend). */
export const WEEKLY_SEND_LABEL = 'Se envían los lunes a las 10:00 (hora de Argentina).' export const WEEKLY_SEND_LABEL = 'Se envían los lunes a las 10:00 (hora de Argentina).'

View File

@@ -7,6 +7,7 @@ export {
type WhatsappCallbackFeedback, type WhatsappCallbackFeedback,
whatsappCallbackErrorMessage, whatsappCallbackErrorMessage,
whatsappStatusBadgeVariant, whatsappStatusBadgeVariant,
whatsappStatusErrorMessage,
whatsappStatusLabel, whatsappStatusLabel,
} from './copy' } from './copy'
export { useDisconnectWhatsapp } from './useDisconnectWhatsapp' export { useDisconnectWhatsapp } from './useDisconnectWhatsapp'

View File

@@ -6,7 +6,9 @@ import {
readinessLabel, readinessLabel,
readWhatsappCallbackFeedback, readWhatsappCallbackFeedback,
whatsappCallbackErrorMessage, whatsappCallbackErrorMessage,
WHATSAPP_UNAVAILABLE_MESSAGE,
whatsappStatusBadgeVariant, whatsappStatusBadgeVariant,
whatsappStatusErrorMessage,
whatsappStatusLabel, whatsappStatusLabel,
} from '../src/features/whatsapp/copy' } from '../src/features/whatsapp/copy'
@@ -77,3 +79,14 @@ describe('automationBlockedReason', () => {
expect(automationBlockedReason(status(), 'PAYMENT_REMINDER')).toBeNull() expect(automationBlockedReason(status(), 'PAYMENT_REMINDER')).toBeNull()
}) })
}) })
describe('whatsappStatusErrorMessage', () => {
test('solo un 503 dice que no está disponible', () => {
expect(whatsappStatusErrorMessage(503)).toBe(WHATSAPP_UNAVAILABLE_MESSAGE)
})
test('otro error muestra su código', () => {
expect(whatsappStatusErrorMessage(500)).toContain('error 500')
expect(whatsappStatusErrorMessage(null)).not.toContain('error')
})
})