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

Đang mở Phù hợp với người mới
#35 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
nextjs, react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu tại apps/web/components/bio-links/BioLinkStudio.tsx và lần theo handleSave, handleUploadImage cùng các props của ProfileSettingsCard; kiểm tra callback xác thực slug trong ProfileSettingsCard.tsx. Xác minh mọi phản hồi lưu đều được kiểm tra, lỗi tải lên hiển thị toast lỗi và slug không hợp lệ chặn việc lưu. Hoàn tất khi cả ba hành vi đều hoạt động và thao tác lưu thất bại không bao giờ hiển thị toast thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 />.
Ngôn ngữ chính
TypeScript
Star
2
Fork
1
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sumamakhan761/tryinstance

Tất cả issue của sumamakhan761/tryinstance

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.