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

Aperta Adatta ai principianti
#35 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nextjs, react, typescript
Ambito
frontend

Direzione di ricerca

Inizia da apps/web/components/bio-links/BioLinkStudio.tsx e segui handleSave, handleUploadImage e le props di ProfileSettingsCard; controlla in ProfileSettingsCard.tsx il callback di validazione dello slug. Verifica che ogni risposta di salvataggio venga controllata, che gli errori di caricamento mostrino un toast di errore e che gli slug non validi impediscano il salvataggio. Il lavoro è completato quando tutti e tre i comportamenti funzionano e i salvataggi non riusciti non mostrano mai un toast di successo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 />.
Lingua principale
TypeScript
Stelle
2
Fork
1
Merge medio
6m
PR unite (30g)
27

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sumamakhan761/tryinstance

Tutte le issue di sumamakhan761/tryinstance

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.