Add refresh buttons to these pages

This commit is contained in:
2026-01-30 23:04:42 -07:00
parent cec1e2c95d
commit f5f49c27ea
3 changed files with 36 additions and 12 deletions

View File

@@ -0,0 +1,17 @@
import { faArrowsRotate } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export function ReloadButton ({ action }: { action: () => void }) {
return (
<>
<div className='relative'>
<button
className='top-button absolute -top-4 -right-4'
onClick={action}
>
<FontAwesomeIcon icon={faArrowsRotate} />
</button>
</div>
</>
)
}

View File

@@ -1,7 +1,7 @@
'use client' 'use client'
import { BackButton } from '@/app/components/BackButton' import { BackButton } from '@/app/components/BackButton'
import { DiscordButton } from '@/app/components/DiscordButton' import { ReloadButton } from '@/app/components/ReloadButton'
import axios from 'axios' import axios from 'axios'
import Link from 'next/link' import Link from 'next/link'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
@@ -9,22 +9,29 @@ import { useEffect, useState } from 'react'
export default function BerryDashSplash () { export default function BerryDashSplash () {
const [response, setResponse] = useState<string | null | -1>(null) const [response, setResponse] = useState<string | null | -1>(null)
async function Refresh () {
try {
const request = await axios.get('/api/berrydash/splash-text')
setResponse(request.data)
} catch {
setResponse(-1)
}
}
useEffect(() => { useEffect(() => {
document.title = 'Lncvrt Games - Berry Dash Splash Texts' document.title = 'Lncvrt Games - Berry Dash Splash Texts'
;(async () => { Refresh()
try {
const request = await axios.get('/api/berrydash/splash-text')
setResponse(request.data)
} catch {
setResponse(-1)
}
})()
}, []) }, [])
return ( return (
<div className='box'> <div className='box'>
<BackButton href='/game/berry-dash' /> <BackButton href='/game/berry-dash' />
<DiscordButton /> <ReloadButton
action={() => {
setResponse(null)
Refresh()
}}
/>
<p className='px-8 mb-2 -mt-2 text-center text-2xl'> <p className='px-8 mb-2 -mt-2 text-center text-2xl'>
Berry Dash Splash Texts Berry Dash Splash Texts
</p> </p>

View File

@@ -1,7 +1,7 @@
'use client' 'use client'
import { BackButton } from '@/app/components/BackButton' import { BackButton } from '@/app/components/BackButton'
import { DiscordButton } from '@/app/components/DiscordButton' import { ReloadButton } from '@/app/components/ReloadButton'
import { getCookie } from '@/util/cookie' import { getCookie } from '@/util/cookie'
import { Turnstile } from '@marsidev/react-turnstile' import { Turnstile } from '@marsidev/react-turnstile'
import axios from 'axios' import axios from 'axios'
@@ -26,7 +26,7 @@ export default function BerryDashSubmitSplash () {
return ( return (
<div className='box'> <div className='box'>
<BackButton href='/game/berry-dash/splash' /> <BackButton href='/game/berry-dash/splash' />
<DiscordButton /> <ReloadButton action={() => window.location.reload()} />
<p className={`px-8 ${loading ? '-my-2' : 'mb-4 -mt-2'} text-center`}> <p className={`px-8 ${loading ? '-my-2' : 'mb-4 -mt-2'} text-center`}>
{loading {loading
? 'Loading...' ? 'Loading...'