Add refresh button to icon marketplace page
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { HomeButton } from '@/app/components/HomeButton'
|
||||
import { DiscordButton } from '@/app/components/DiscordButton'
|
||||
import axios from 'axios'
|
||||
import { BackButton } from '@/app/components/BackButton'
|
||||
import { ReloadButton } from '@/app/components/ReloadButton'
|
||||
|
||||
interface MarketplaceIcon {
|
||||
username: string
|
||||
@@ -20,22 +19,29 @@ interface MarketplaceIcon {
|
||||
export default function BerryDashIconMarketplace () {
|
||||
const [response, setResponse] = useState<MarketplaceIcon[] | null | -1>(null)
|
||||
|
||||
async function Refresh () {
|
||||
try {
|
||||
const request = await axios.get('/api/berrydash/icon-marketplace')
|
||||
setResponse(request.data.success ? request.data.data : -1)
|
||||
} catch {
|
||||
setResponse(-1)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.title = 'Lncvrt Games - Berry Dash Icon Marketplace'
|
||||
;(async () => {
|
||||
try {
|
||||
const request = await axios.get('/api/berrydash/icon-marketplace')
|
||||
setResponse(request.data.success ? request.data.data : -1)
|
||||
} catch {
|
||||
setResponse(-1)
|
||||
}
|
||||
})()
|
||||
Refresh()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className='box text-center'>
|
||||
<BackButton href='/game/berry-dash' />
|
||||
<DiscordButton />
|
||||
<ReloadButton
|
||||
action={() => {
|
||||
setResponse(null)
|
||||
Refresh()
|
||||
}}
|
||||
/>
|
||||
<p className='px-8 -mt-2 mb-4 text-2xl'>Berry Dash Icon Marketplace</p>
|
||||
<p>A browser for the in game icon marketplace!</p>
|
||||
<div className='sub-box mt-2 -mx-4 -mb-4 flex flex-row flex-wrap justify-center gap-2 max-w-[95vw]'>
|
||||
|
||||
Reference in New Issue
Block a user