From cec1e2c95d1d16974a201a242e70a093fab2c267 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Fri, 30 Jan 2026 22:51:39 -0700 Subject: [PATCH] Move splash text submit page and add a view page --- src/app/game/berry-dash/page.tsx | 5 +- src/app/game/berry-dash/splash/page.tsx | 130 ++++-------------- .../game/berry-dash/splash/submit/page.tsx | 121 ++++++++++++++++ 3 files changed, 154 insertions(+), 102 deletions(-) create mode 100644 src/app/game/berry-dash/splash/submit/page.tsx diff --git a/src/app/game/berry-dash/page.tsx b/src/app/game/berry-dash/page.tsx index b64e03a..cf630fe 100644 --- a/src/app/game/berry-dash/page.tsx +++ b/src/app/game/berry-dash/page.tsx @@ -107,9 +107,12 @@ export default function BerryDashGameInfo () { View the Icon Marketplace! - + Submit a new Splash Text! + + View the Splash Texts! +

Downloads

diff --git a/src/app/game/berry-dash/splash/page.tsx b/src/app/game/berry-dash/splash/page.tsx index 85677e6..1160852 100644 --- a/src/app/game/berry-dash/splash/page.tsx +++ b/src/app/game/berry-dash/splash/page.tsx @@ -2,120 +2,48 @@ import { BackButton } from '@/app/components/BackButton' import { DiscordButton } from '@/app/components/DiscordButton' -import { getCookie } from '@/util/cookie' -import { Turnstile } from '@marsidev/react-turnstile' import axios from 'axios' -import { useRouter } from 'next/navigation' +import Link from 'next/link' import { useEffect, useState } from 'react' export default function BerryDashSplash () { - const [token, setToken] = useState(null) - const [result, setResult] = useState(-1) - const [loading, setLoading] = useState(true) - const router = useRouter() + const [response, setResponse] = useState(null) useEffect(() => { - document.title = 'Lncvrt Games - Berry Dash Splash Text Submition' - - const token = getCookie('accountToken', '-1') - if (token === '-1') { - router.push('/account/login?redirect=/game/berry-dash/splash') - } else setLoading(false) + document.title = 'Lncvrt Games - Berry Dash Splash Texts' + ;(async () => { + try { + const request = await axios.get('/api/berrydash/splash-text') + setResponse(request.data) + } catch { + setResponse(-1) + } + })() }, []) return (
-

- {loading - ? 'Loading...' - : result == -1 - ? 'Verify you are human to submit a splash text' - : 'Berry Dash Splash Text Submition'} +

+ Berry Dash Splash Texts +

+
+ + Want to submit a splash text? + +
+

+ {response == null + ? 'Loading...' + : response == -1 + ? 'Failed to get splash texts' + : response}

- {!loading && ( - <> - {result == -1 ? ( - { - setToken(token) - setResult(0) - }} - onError={() => setResult(1)} - className='flex justify-center' - /> - ) : result == 0 ? ( -
{ - e.preventDefault() - - const form = e.currentTarget - const formData = new FormData(form) - const text = formData.get('text') as string - - try { - const result = await axios.post( - '/api/berrydash/splash-text', - { - token, - content: text - }, - { - headers: { - authorization: getCookie('accountToken', '-1') - } - } - ) - if (result.data.success) { - setResult(2) - } else { - alert( - 'Failed to submit splash text, error: ' + - (result.data.message || 'n/a') - ) - } - } catch (e: any) { - if (e.response) { - alert( - 'Failed to submit splash text, error: ' + - (e.response.data?.message || - JSON.stringify(e.response.data)) - ) - } else if (e.request) { - alert( - 'Failed to submit splash text, no response from server.' - ) - } else { - alert('Failed to submit splash text, error: ' + e.message) - } - } - }} - > - - -
- ) : ( - (result == 1 || result == 2) && ( -

- {result == 1 - ? 'Unable to verify captcha, please reload page.' - : 'Successfully submitted splash text! It will be reviewed soon. Refresh to add more splash texts, there is no limit after all!'} -

- ) - )} - - )}
) } diff --git a/src/app/game/berry-dash/splash/submit/page.tsx b/src/app/game/berry-dash/splash/submit/page.tsx new file mode 100644 index 0000000..8450080 --- /dev/null +++ b/src/app/game/berry-dash/splash/submit/page.tsx @@ -0,0 +1,121 @@ +'use client' + +import { BackButton } from '@/app/components/BackButton' +import { DiscordButton } from '@/app/components/DiscordButton' +import { getCookie } from '@/util/cookie' +import { Turnstile } from '@marsidev/react-turnstile' +import axios from 'axios' +import { useRouter } from 'next/navigation' +import { useEffect, useState } from 'react' + +export default function BerryDashSubmitSplash () { + const [token, setToken] = useState(null) + const [result, setResult] = useState(-1) + const [loading, setLoading] = useState(true) + const router = useRouter() + + useEffect(() => { + document.title = 'Lncvrt Games - Berry Dash Splash Text Submition' + + const token = getCookie('accountToken', '-1') + if (token === '-1') { + router.push('/account/login?redirect=/game/berry-dash/splash/submit') + } else setLoading(false) + }, []) + + return ( +
+ + +

+ {loading + ? 'Loading...' + : result == -1 + ? 'Verify you are human to submit a splash text' + : 'Berry Dash Splash Text Submition'} +

+ {!loading && ( + <> + {result == -1 ? ( + { + setToken(token) + setResult(0) + }} + onError={() => setResult(1)} + className='flex justify-center' + /> + ) : result == 0 ? ( +
{ + e.preventDefault() + + const form = e.currentTarget + const formData = new FormData(form) + const text = formData.get('text') as string + + try { + const result = await axios.post( + '/api/berrydash/splash-text', + { + token, + content: text + }, + { + headers: { + authorization: getCookie('accountToken', '-1') + } + } + ) + if (result.data.success) { + setResult(2) + } else { + alert( + 'Failed to submit splash text, error: ' + + (result.data.message || 'n/a') + ) + } + } catch (e: any) { + if (e.response) { + alert( + 'Failed to submit splash text, error: ' + + (e.response.data?.message || + JSON.stringify(e.response.data)) + ) + } else if (e.request) { + alert( + 'Failed to submit splash text, no response from server.' + ) + } else { + alert('Failed to submit splash text, error: ' + e.message) + } + } + }} + > + + +
+ ) : ( + (result == 1 || result == 2) && ( +

+ {result == 1 + ? 'Unable to verify captcha, please reload page.' + : 'Successfully submitted splash text! It will be reviewed soon. Refresh to add more splash texts, there is no limit after all!'} +

+ ) + )} + + )} +
+ ) +}