Skip to content

Add a duplicate-from-existing-commitment prefill action to the create flow#1193

Open
greatest0fallt1me wants to merge 1 commit into
Commitlabs-Org:masterfrom
greatest0fallt1me:fix/issue-952
Open

Add a duplicate-from-existing-commitment prefill action to the create flow#1193
greatest0fallt1me wants to merge 1 commit into
Commitlabs-Org:masterfrom
greatest0fallt1me:fix/issue-952

Conversation

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Fixes #952

Summary

  • Adds usePrefillFromCommitment hook: reads ?sourceId query param, fetches the source commitment's configurable parameters, and returns a typed PrefillData object (identity-bound fields id, ownerAddress, on-chain state are intentionally excluded).
  • Adds onDuplicate prop to CommitmentDetailActions with a Duplicate Commitment button that routes to /create?sourceId=<id>.
  • Updates the CreateCommitment page to apply prefill on mount (skips type-selection step 1, opens step 2 pre-filled) and shows an accessible role="status" banner informing the user they are in duplicate mode.
  • All prefilled fields remain fully editable; source commitment is unaffected.

Changes

  • src/hooks/usePrefillFromCommitment.ts — new hook with safe fallback for missing/erroring sources
  • src/components/CommitmentDetailActions.tsx — new optional onDuplicate prop + Duplicate button
  • src/app/create/page.tsx — prefill integration, duplicate-mode banner
  • src/app/create/DuplicateCommitment.test.tsx — tests covering happy path, 404, network error, identity-field exclusion, clamping, and page-level integration
  • docs/DUPLICATE_COMMITMENT.md — feature docs with API, accessibility notes, usage example, and edge-case table

…create flow

- Add `usePrefillFromCommitment` hook that reads `?sourceId` from the URL,
  fetches the source commitment's configurable parameters, and returns a
  typed `PrefillData` object (identity-bound fields excluded).
- Add `onDuplicate` prop to `CommitmentDetailActions` with a Duplicate button
  that routes to `/create?sourceId=<id>`.
- Update `CreateCommitment` page to apply prefill on mount (skips step 1,
  prefills step 2) and show an accessible status banner in duplicate mode.
- Add `DuplicateCommitment.test.tsx` covering hook happy path, missing source,
  identity-field exclusion, clamping, and UI integration.
- Add `docs/DUPLICATE_COMMITMENT.md` with API, accessibility, usage, and edge-case docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@greatest0fallt1me is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a duplicate-from-existing-commitment prefill action to the create flow

1 participant