fix: version guard uses static file, members table shows project name with round badge
All checks were successful
Build and Push Docker Image / build (push) Successful in 11m12s
All checks were successful
Build and Push Docker Image / build (push) Successful in 11m12s
Version guard: - Replace API route with prebuild-generated public/build-id.json - Captures build ID on first load, only notifies on mismatch - Fixes false positive refresh prompts from env mismatch Members table (applicants): - Show project name + round badge instead of round name + state - Red badge for rejected, gray for withdrawn, green for passed, outline for active rounds - Include projectName in applicantRoundInfo from backend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
const CLIENT_BUILD_ID = process.env.NEXT_PUBLIC_BUILD_ID
|
||||
// Capture the build ID when this module first loads (from the current deployment's JS bundle).
|
||||
// On subsequent fetches of /build-id.json, if the value differs, a new deploy happened.
|
||||
let initialBuildId: string | null = null
|
||||
|
||||
export function VersionGuard() {
|
||||
const notified = useRef(false)
|
||||
@@ -12,10 +14,19 @@ export function VersionGuard() {
|
||||
async function checkVersion() {
|
||||
if (notified.current) return
|
||||
try {
|
||||
const res = await fetch('/api/version', { cache: 'no-store' })
|
||||
const res = await fetch('/build-id.json?t=' + Date.now())
|
||||
if (!res.ok) return
|
||||
const { buildId } = await res.json()
|
||||
if (buildId && CLIENT_BUILD_ID && buildId !== CLIENT_BUILD_ID) {
|
||||
if (!buildId) return
|
||||
|
||||
// First load — capture the build ID
|
||||
if (initialBuildId === null) {
|
||||
initialBuildId = buildId
|
||||
return
|
||||
}
|
||||
|
||||
// Subsequent checks — compare
|
||||
if (buildId !== initialBuildId) {
|
||||
notified.current = true
|
||||
toast('A new version is available', {
|
||||
description: 'Refresh to get the latest updates.',
|
||||
@@ -31,6 +42,9 @@ export function VersionGuard() {
|
||||
}
|
||||
}
|
||||
|
||||
// Initial check (captures build ID)
|
||||
checkVersion()
|
||||
|
||||
// Check on tab focus (covers users returning to stale tabs)
|
||||
window.addEventListener('focus', checkVersion)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user