Create useFormState hook for modals

Đang mở
#44 1 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Start by comparing the repeated form state logic in BuyInModal.tsx, WithdrawalModal.tsx, DepositCore.tsx, TopUpModal.tsx, and QRDeposit.tsx. Create hooks/useFormState.ts from the specified generic interface, then refactor those modals while checking that their existing behavior remains unchanged. Done means all listed acceptance criteria are met without regressions.

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

Mô tả

architecture enhancement tech debt ux

Priority: MEDIUM

Problem

Multiple modal components repeat identical form state logic:

  • BuyInModal.tsx
  • WithdrawalModal.tsx
  • DepositCore.tsx
  • TopUpModal.tsx
  • QRDeposit.tsx

Pattern repeated:

const [amount, setAmount] = useState("");
const [isProcessing, setIsProcessing] = useState(false);
const [error, setError] = useState<string | null>(null);
const [success, setSuccess] = useState(false);

Solution

Create a reusable form state hook:

// hooks/useFormState.ts
interface FormState<T> {
  values: T;
  setValues: (values: T) => void;
  isProcessing: boolean;
  setIsProcessing: (v: boolean) => void;
  error: string | null;
  setError: (e: string | null) => void;
  success: boolean;
  setSuccess: (s: boolean) => void;
  reset: () => void;
}

const useFormState = <T>(initialValues: T): FormState<T> => { ... }

Acceptance Criteria

  • Create useFormState hook with generic typing
  • Include processing, error, and success states
  • Add reset functionality
  • Refactor modals to use the hook
  • Maintain existing behavior

Related

Parent issue: block52/ui#45

Ngôn ngữ chính
TypeScript
Star
2
Fork
5
Merge trung bình
22 giờ 3 phút
Pull request đã merge (30 ngày)
103

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

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 block52/ui

Tất cả issue của block52/ui

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.