Skip to content

Commit 61ebd84

Browse files
Merge pull request #185 from gofr-dev/fix-certificate-page
updated the certificate page from path params to query params and rem…
2 parents cf511cd + 72c0b79 commit 61ebd84

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

src/app/certificate/page.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use client'
2+
3+
import { useSearchParams } from 'next/navigation'
4+
import { useEffect, useState } from 'react'
5+
import Image from 'next/image'
6+
import NotFound from '@/app/not-found'
7+
8+
export default function Certificate() {
9+
const searchParams = useSearchParams()
10+
const id = searchParams.get('id')
11+
12+
const [certificateUrl, setCertificateUrl] = useState(null)
13+
const [error, setError] = useState(false)
14+
15+
useEffect(() => {
16+
async function fetchCertificate() {
17+
try {
18+
const response = await fetch(
19+
`https://gofr.dev/certificate-service/certificate/${id}`,
20+
)
21+
const { data } = await response.json()
22+
setCertificateUrl(data.url)
23+
} catch (err) {
24+
setError(true)
25+
}
26+
}
27+
28+
if (id) fetchCertificate()
29+
}, [id])
30+
31+
if (error) return <NotFound />
32+
if (!certificateUrl)
33+
return (
34+
<div className="flex h-[80vh] items-center justify-center">
35+
<div className="h-12 w-12 animate-spin rounded-full border-4 border-gray-300 border-t-[#38bdf9]" />
36+
</div>
37+
)
38+
39+
return (
40+
<Image
41+
className="mx-auto w-[90%] max-w-5xl"
42+
src={certificateUrl}
43+
alt="certificate"
44+
height={600}
45+
width={800}
46+
unoptimized
47+
priority
48+
/>
49+
)
50+
}

src/components/Layout.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Search } from '@/components/Search'
1010
import { formatNumber } from '@/lib/common'
1111
import { ErrorBoundary } from './BugsnagWrapper'
1212
import FooterUi from '@/components/Footer'
13-
import { HackathonLinkButton } from './goforgofr/HackathonLinkButton'
13+
// import { HackathonLinkButton } from './goforgofr/HackathonLinkButton'
1414

1515
export function GitHubIcon(props) {
1616
return (
@@ -149,10 +149,10 @@ export function Layout({ children }) {
149149
<div className="flex w-full flex-col">
150150
{pathname !== '/hackathon' && (
151151
<>
152-
<div className="relative z-50 sm:fixed sm:left-0 sm:right-0 sm:top-0">
152+
{/* <div className="relative z-50 sm:fixed sm:left-0 sm:right-0 sm:top-0">
153153
<HackathonLinkButton />
154-
</div>
155-
<div className="sticky left-0 right-0 top-0 z-40 sm:top-8">
154+
</div> */}
155+
<div className="sticky left-0 right-0 top-0 z-40 sm:top-0">
156156
<Header />
157157
</div>
158158
</>

0 commit comments

Comments
 (0)