feat: add route constant

This commit is contained in:
2026-03-17 14:10:53 +05:30
parent 2b2f348cc7
commit e41236108a
8 changed files with 39 additions and 19 deletions

View File

@@ -15,6 +15,7 @@ import {
} from "@/lib/api"
import { getVideoFile, clearVideoFile } from "@/lib/video-storage"
import { DetectionData, DetectionType } from "@/lib/types"
import { ROUTES } from "@/utils/routes"
const API_URL = process.env.NEXT_PUBLIC_API_URL
@@ -82,7 +83,7 @@ export default function VideoResultsPage() {
}
}
clearSession()
router.push("/new-analysis")
router.push(ROUTES.NEW_ANALYSIS)
}
const getTitle = () => {
@@ -108,8 +109,8 @@ export default function VideoResultsPage() {
<div className="flex flex-col items-center gap-4 p-8 rounded-2xl bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl shadow-lg text-center">
<p className="text-red-500 font-medium">{error}</p>
<div className="flex gap-4 mt-4">
<Button onClick={() => router.push("/upload")} variant="outline">Back to Upload</Button>
<Button onClick={handleNewAnalysis} className="bg-gradient-to-r from-indigo-500 to-purple-600 text-white">New Analysis</Button>
<Button onClick={() => router.push(ROUTES.UPLOAD)} variant="outline">Back to Upload</Button>
<Button onClick={handleNewAnalysis} className="bg-linear-to-r from-indigo-500 to-purple-600 text-white">New Analysis</Button>
</div>
</div>
</div>

View File

@@ -20,6 +20,8 @@ import { DetectionData, DetectionType } from "@/lib/types"
const API_URL = process.env.NEXT_PUBLIC_API_URL
import { ROUTES } from "@/utils/routes"
export default function ResultsPage() {
const router = useRouter()
const [session, setSession] = useState<SessionContext | null>(null)
@@ -36,13 +38,13 @@ export default function ResultsPage() {
const videoData = loadVideoData()
if (!isSessionValid(storedSession) || !videoData) {
router.replace("/new-analysis")
router.replace(ROUTES.NEW_ANALYSIS)
return
}
// If we have a videoId, redirect to the dynamic results page
if (videoData.videoId) {
router.replace(`/results/${videoData.videoId}`)
router.replace(`${ROUTES.RESULTS}/${videoData.videoId}`)
return
}
@@ -59,11 +61,11 @@ export default function ResultsPage() {
}
}
clearSession()
router.push("/new-analysis")
router.push(ROUTES.NEW_ANALYSIS)
}
const handleBackToUpload = () => {
router.push("/upload")
router.push(ROUTES.UPLOAD)
}
const getTitle = () => {