Skip to content

Conversation

@sai-suraj143
Copy link

@sai-suraj143 sai-suraj143 commented Dec 22, 2025

Description

Previously, the election creation form allowed users to select a "Start Date" in the past. The form would fail silently (no election created, no error shown). This PR adds a validation check to ensure startTime >= CurrentTime. If a past date is selected, a Toast error is displayed to the user.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Tested locally by attempting to create an election with yesterday's date.
  • Verified that the error "Invalid timing. Start time cannot be in the past." appears.
  • Verified that valid future dates still work correctly.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code

Closes #210

Summary by CodeRabbit

Release Notes

  • Improvements
    • Network switching now validates Crypto Wallet availability. Users receive guidance and installation options if their wallet isn't connected.
    • Election creation prevents past start times with error notifications when invalid dates are selected.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Added runtime validations to the election creation flow: a wallet (window.ethereum) presence check in changeChain that prompts MetaMask download if absent, and a start time validation in createElection that prevents creating elections with past start dates. Both failed validations display error toasts.

Changes

Cohort / File(s) Summary
Election Creation Validations
client/app/create/page.tsx
Added wallet presence check in changeChain to require Crypto Wallet; displays error toast and prompts MetaMask download if missing. Added start time validation in createElection to prevent past dates; displays error toast if start time is before current time.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Straightforward validation additions with no complex logic or side effects
  • Single file with two isolated validation checks (wallet presence and date comparison)
  • May want to verify error messaging alignment and date comparison logic accuracy

Poem

🐰 A hop, a skip, through forms so neat,
With wallets checked and dates complete!
No past-cast votes or missing keys,
Just errors shown with gentle ease. ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d3a4dd and c460646.

📒 Files selected for processing (1)
  • client/app/create/page.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

[UX] Election Creation Fails Silently for Past Start Dates

1 participant