Skip to content

feat: add bounty countdown timer#1341

Open
TUPM96 wants to merge 1 commit into
SolFoundry:mainfrom
TUPM96:feat/bounty-826-countdown
Open

feat: add bounty countdown timer#1341
TUPM96 wants to merge 1 commit into
SolFoundry:mainfrom
TUPM96:feat/bounty-826-countdown

Conversation

@TUPM96
Copy link
Copy Markdown

@TUPM96 TUPM96 commented May 26, 2026

Closes #826

Summary

  • Add a reusable BountyCountdown component with normal, warning, urgent, and expired states.
  • Display the real-time countdown on bounty cards and the bounty detail sidebar.
  • Update every second without a page refresh and expose urgency metadata for testing/accessibility.
  • Add focused coverage for countdown formatting, real-time updates, and card integration.
  • Restore tracked frontend shared helpers needed by the existing app imports and build.

Verification

  • git diff --check
  • npm run test -- bounty-countdown.test.tsx
  • npm run build

Wallet

  • Not included by automation; contributor should add their Solana wallet address before payout.

Copilot AI review requested due to automatic review settings May 26, 2026 02:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Introduces shared frontend utilities and motion variants, and replaces static deadline labels with a live-updating countdown component for bounties.

Changes:

  • Added BountyCountdown component (with urgency styling) and unit/UI tests.
  • Introduced shared utils.ts (time/currency formatting + language colors) and reusable framer-motion variants.
  • Updated bounty card/detail views and .gitignore to use/track the new shared lib directory.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/src/lib/utils.ts Adds shared formatting helpers and LANG_COLORS used by bounty UI.
frontend/src/lib/animations.ts Adds reusable Framer Motion variants for consistent animations.
frontend/src/components/bounty/BountyDetail.tsx Swaps static deadline display for BountyCountdown.
frontend/src/components/bounty/BountyCountdown.tsx New live-updating countdown with urgency states + styles.
frontend/src/components/bounty/BountyCard.tsx Uses BountyCountdown in the card metadata row.
frontend/src/tests/bounty-countdown.test.tsx Adds tests for countdown state formatting and live updates.
.gitignore Un-ignores frontend/src/lib so the new shared modules are committed.

Comment on lines +80 to +82
setNow(Date.now());
const interval = window.setInterval(() => setNow(Date.now()), 1000);
return () => window.clearInterval(interval);
Comment on lines +80 to +89
setNow(Date.now());
const interval = window.setInterval(() => setNow(Date.now()), 1000);
return () => window.clearInterval(interval);
}, [deadline]);

const countdown = getCountdownState(deadline, now);

return (
<span
aria-live="polite"
Comment on lines +13 to +23
export function getCountdownState(deadline: string, now = Date.now()): CountdownState {
const deadlineTime = new Date(deadline).getTime();

if (Number.isNaN(deadlineTime)) {
return {
urgency: 'expired',
label: 'Expired',
isExpired: true,
totalMinutes: 0,
};
}
Comment thread frontend/src/lib/utils.ts
Comment on lines +50 to +67
export function timeLeft(deadline?: string | null): string {
if (!deadline) return 'No deadline';

const date = new Date(deadline);
if (Number.isNaN(date.getTime())) return 'Invalid deadline';

const deltaMs = date.getTime() - Date.now();
if (deltaMs <= 0) return 'Expired';

const totalMinutes = Math.floor(deltaMs / 60000);
const days = Math.floor(totalMinutes / (24 * 60));
const hours = Math.floor((totalMinutes % (24 * 60)) / 60);
const minutes = totalMinutes % 60;

if (days > 0) return `${days}d ${hours}h left`;
if (hours > 0) return `${hours}h ${minutes}m left`;
return `${Math.max(minutes, 1)}m left`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-wallet PR is missing a Solana wallet for bounty payout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🏭 Bounty T1: Bounty Countdown Timer Component

2 participants