AGENT SKILL

minipower-frontend-form-react

Form theo kit @platform/core — Zod schema + *FormDefaultValues + map entity→form ở validation/, hook use{Feature}Form (react-hook-form + zodResolver, mode onChange), component form chỉ có trường nhận register/control/errors, Controller cho FieldSelect/SearchableSelect/KitDatePicker/ToggleSwitch/PasswordInput, submit qua handleAction + notify. Dùng khi thêm form tạo/sửa, thêm validation hoặc trường bắt buộc, chọn ngày / chọn bản ghi liên kết, form trong dialog, hoặc form sửa không nạp dữ liệu cũ.

使用场景前端开发
License 许可
MIT
最近更新
2026-11-09
Stars
★ 7
Forks
0

01 前言 Front Matter

name
minipower-frontend-form-react
metadata
{ "workflow": "github" }
description
Form theo kit @platform/core — Zod schema + *FormDefaultValues + map entity→form ở validation/, hook use{Feature}Form (react-hook-form + zodResolver, mode onChange), component form chỉ có trường nhận register/control/errors, Controller cho FieldSelect/SearchableSelect/KitDatePicker/ToggleSwitch/PasswordInput, submit qua handleAction + notify. Dùng khi thêm form tạo/sửa, thêm validation hoặc trường bắt buộc, chọn ngày / chọn bản ghi liên kết, form trong dialog, hoặc form sửa không nạp dữ liệu cũ.

02 资源文件 9

03 SKILL.md 正文

Form (@platform/core) — Orchestrator

Skill sở hữu ba mảnh của một form: schema (validation/) · hook (hooks/use{Feature}Form) · component trường (components/{Feature}Form). Ai submit, gọi API nào, đi đâu sau khi lưu — thuộc page / dialog (crud).

Hướng dẫn người: README.md.

Khi nào dùng workflow nào

Tình huống Workflow
Thêm form mới hoặc thêm trường vào form có sẵn workflows/add-form.md
Trường là select / chọn bản ghi / ngày / giờ / bật-tắt / mật khẩu reference/controls.md

Luồng một form

validation/{feature}.ts   schema Zod · {Feature}FormData = z.infer · {feature}FormDefaultValues · to{Feature}FormValues(entity)
        │
hooks/use{Feature}Form    useForm({ resolver: zodResolver(schema), mode: 'onChange', defaultValues })
        │  register · control · errors
components/{Feature}Form  chỉ trường + lỗi — KHÔNG submit, KHÔNG gọi API
        │
page / dialog             handleSubmit(data ⇒ handleAction({ defaultSubmit: map form → payload → call* }))

Quy tắc cốt lõi

  • Ràng buộc khớp backend. min/max/bắt buộc lấy từ DOC-12 / DOC-11 — form cho qua mà API trả 400 là lỗi của schema. Thiếu số liệu ⇒ hỏi, đừng tự đặt.
  • Message lỗi tiếng Việt ngay trong schema — hiện thẳng dưới trường, không dịch lại ở component.
  • Kiểu form ≠ kiểu payload. Map tường minh trong defaultSubmit (sửa thường không gửi status); map ngược bằng to{Feature}FormValues.
  • Ô tuỳ chọn trống → null (setValueAs) — backend .NET nhận null, không nhận ''.
  • Input gốc dùng register; control khác bọc Controller — đúng giá trị dây của control (reference/controls.md). Ngày không giờ giữ chuỗi 'YYYY-MM-DD'.
  • Sửa: nạp dữ liệu rồi reset. defaultValues của useForm chỉ đọc lần đầu — dữ liệu về sau phải reset({ ...defaults, ...values }). Tham chiếu defaultValues truyền vào page phải ổn định, không thì form reset mỗi lần render.
  • Form trong dialog dùng MỘT instance — reset(defaults) khi mở tạo, reset(to{Feature}FormValues(item)) khi mở sửa.
  • Submit: <form noValidate>, nút disabled={isSubmitting}, lỗi API ⇒ notify.error(getErrorMessage(error, …)).

Templates

Placeholder: architecture § Placeholder.

Template Đích
templates/validation/{feature}.ts src/features/{feature}/validation/{feature}.ts
templates/validation/index.ts validation/index.ts
templates/hooks/use{Feature}Form.ts hooks/use{Feature}Form.ts
templates/hooks/index.ts hooks/index.ts
templates/components/{Feature}Form/ components/{Feature}Form/

Class trường (fieldInputClass…) từ components/fieldStyles.ts — template của convention.

Tham chiếu

  • reference/controls.md — bảng control → giá trị dây → Zod → cách gắn, kèm đoạn mẫu. Không load mặc định.

Output bắt buộc

  • Schema, kiểu, mặc định, mapper ở validation/; component form không import services/ (lint R6)
  • npm run typecheck + npm run lint xanh
  • Chạy thật: submit form trống hiện lỗi dưới từng trường bắt buộc; mở form sửa thấy dữ liệu cũ; lưu xong có toast
  • Code theo minipower-frontend-convention-react; file đặt đúng folder theo minipower-frontend-architecture-react

Liên quan

04 同仓库更多 Skills

hoangnh2412
hoangnh2412/minipower

minipower-vcs-gitlab

Tra GitLab (search, issue, pipeline, MR), soạn MR/comment, tạo MR và commit/push sau L2. Dùng khi merge request, GitLab MCP, code_provider gitlab — không scaffold .NET, không force-push.

Skill与智能体开发
★ 7
hoangnh2412
hoangnh2412/minipower

minipower-toolbox-skill-author

Viết và soát skill lá-rời Minipower (minipower-{module}-{capability}) — chọn module bằng 3 câu hỏi ADR-022, dựng cây SKILL.md/README.md/workflows/providers, đặt description kích hoạt được, cập nhật hub và test canh. Hỏi người xác nhận trước mọi quyết định, không tự chốt. Dùng khi tạo skill mới, thêm provider/pattern/workflow, mở module mới, hoặc soát skill có sẵn lệch chuẩn.

Skill与智能体开发
★ 7
hoangnh2412
hoangnh2412/minipower

minipower-tasks-lark

Đọc, lọc, tìm, soạn nháp và ghi task Lark (tasklist / task) theo L1–L3. Dùng khi việc trên Lark, sprint, tasklist, "tìm task", "tạo task", tasks_provider lark — không dùng cho tin nhắn nhóm hay wiki.

★ 7
hoangnh2412
hoangnh2412/minipower

minipower-support-registry

Rà registry DOC theo project_mode, nhắc owner thiếu ID hoặc chỗ lưu sai. Dùng khi doc-registry, thiếu DOC, rà soát tiêu chuẩn — không tự sửa FR, không init.

★ 7
hoangnh2412
hoangnh2412/minipower

minipower-support-publish

暂无简介

★ 7
hoangnh2412
hoangnh2412/minipower

minipower-router

Phân loại intent Minipower rồi gợi ý đúng một pack nghề hoặc kênh. Dùng khi làm gì tiếp, chọn skill, dispatcher, không biết mở pack nào — không tự gọi MCP L3, không spawn agent.

Skill与智能体开发
★ 7