fix(bio-links): check all PUT responses on save, toast on upload errors, and wire slug validation in BioLinkStudio

Abierto Apto para principiantes
#35 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nextjs, react, typescript
Área
frontend

Línea de trabajo

Empieza en apps/web/components/bio-links/BioLinkStudio.tsx y sigue handleSave, handleUploadImage y las props de ProfileSettingsCard; comprueba en ProfileSettingsCard.tsx el callback de validación del slug. Verifica que se comprueben todas las respuestas de guardado, que los errores de carga muestren un toast de error y que los slugs no válidos impidan guardar. El trabajo está terminado cuando funcionan los tres comportamientos y los guardados fallidos nunca muestran un toast de éxito.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug good first issue ui web
Problem Description

In apps/web/components/bio-links/BioLinkStudio.tsx, there are three error-handling and validation gaps:

  1. False success toast on partial save failure (handleSave):
    handleSave sends 5 sequential PUT requests (/api/bio-links/settings, buttons, links, products, faqs), but only checks if (!settingsRes.ok).
    The 4 subsequent PUT calls (buttons, links, products, faqs) never check res.ok, so if any of them fail, handleSave still sets isSaved(true) and shows toast.success('Bio link updated', 'All changes published successfully').

  2. Silent image upload failures (handleUploadImage):
    handleUploadImage catches upload errors from /api/bio-links/upload, logs to the console, and returns null without calling toast.error(...). Child callers (ProfileSettingsCard.tsx, CustomLinksManager.tsx, ProductsManager.tsx) do not display an error toast when null is returned either.

  3. Slug validation never wired to <ProfileSettingsCard>:
    BioLinkStudio.tsx declares const [isSlugValid, setIsSlugValid] = useState(true) and checks if (!isSlugValid) in handleSave, and ProfileSettingsCard.tsx already accepts onSlugValidationChange?: (isValid: boolean) => void. However, onSlugValidationChange={setIsSlugValid} is never passed to <ProfileSettingsCard>, leaving isSlugValid permanently true.


Expected Behavior
  1. handleSave checks res.ok on all PUT requests (settings, buttons, links, products, faqs) and throws/toasts an error if any request fails, without showing toast.success(...).
  2. handleUploadImage surfaces a clear toast.error(...) message whenever image upload fails.
  3. <ProfileSettingsCard> receives onSlugValidationChange={setIsSlugValid} so invalid, taken, or reserved handles block saving as intended.

Where to Look
  • apps/web/components/bio-links/BioLinkStudio.tsx (handleUploadImage, handleSave, <ProfileSettingsCard> usage)
  • apps/web/components/bio-links/ProfileSettingsCard.tsx (onSlugValidationChange)

Solution / Implementation Guide
  1. In BioLinkStudio.tsx (handleSave):
    • Extract a small response-checking helper (e.g. assertOk(res, fallbackMsg)) and apply it to the buttons, links, products, and faqs PUT responses just like settingsRes.
  2. In BioLinkStudio.tsx (handleUploadImage):
    • In the catch block (or on !res.ok), call toast.error(...) with a user-facing message before returning null.
  3. In BioLinkStudio.tsx (<ProfileSettingsCard>):
    • Pass onSlugValidationChange={setIsSlugValid} to <ProfileSettingsCard />.
Lenguaje dominante
TypeScript
Estrellas
2
Forks
1
Merge medio
6 min
PR fusionados (30 d)
27

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de sumamakhan761/tryinstance

Todos los issues de sumamakhan761/tryinstance

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.