Skip to content

feature: Prevent duplicate compare submissions #193

Description

@O2sa

The compare form should prevent users from comparing the same GitHub username against itself and should avoid submitting the same completed comparison again after the data has already been fetched. This would reduce unnecessary API calls and make the form validation clearer.

Context

  • components/compare-form.tsx currently enables submit when both username fields are non-empty and the page is not loading.
  • The submit handler trims values, but it does not compare username1 and username2 case-insensitively before calling onSubmit.
  • components/home-page-client.tsx tracks lastFetchedKeyRef, inFlightFetchKeyRef, data, and displayData, but the submit button remains enabled after a successful fetch for the same usernames and selected languages.
  • GitHub usernames should be treated case-insensitively for validation, so Octocat and octocat should count as the same username.

Tasks

  • Add client-side validation that blocks submission when both username fields normalize to the same value.
  • Show a localized field or form error explaining that two different GitHub usernames are required.
  • Disable the compare button when the current form values and selected languages match the already-fetched comparison.
  • Re-enable submission when either username or selected languages change.
  • Keep protection in handleCompare so repeated submissions cannot trigger duplicate /api/compare requests even if the button state is bypassed.
  • Add tests for same-username validation and already-fetched comparison submit prevention.

Tip

🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions