mirror of https://github.com/kern/filepizza
extract
parent
4583eaec1d
commit
2b26f7cca8
@ -0,0 +1,23 @@
|
||||
import Link from 'next/link'
|
||||
import Spinner from '../components/Spinner'
|
||||
import Wordmark from '../components/Wordmark'
|
||||
|
||||
export const metadata = {
|
||||
title: 'FilePizza - 404: Slice Not Found',
|
||||
description: 'Oops! This slice of FilePizza seems to be missing.',
|
||||
}
|
||||
|
||||
export default function NotFound(): JSX.Element {
|
||||
return (
|
||||
<div className="flex flex-col items-center space-y-5 py-10 max-w-2xl mx-auto">
|
||||
<Spinner direction="down" />
|
||||
<Wordmark />
|
||||
<p>
|
||||
<strong>404: Looks like this slice of FilePizza is missing!</strong>
|
||||
</p>
|
||||
<Link href="/" className="text-stone-500 hover:underline">
|
||||
Serve up a fresh slice »
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import React from 'react'
|
||||
|
||||
export default function InputLabel({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}): JSX.Element {
|
||||
return (
|
||||
<label className="text-[10px] text-stone-400 mb-0.5 font-bold">
|
||||
{children}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
|
||||
export function useUploaderChannelRenewal(
|
||||
shortSlug: string | undefined,
|
||||
renewInterval = 5000,
|
||||
): void {
|
||||
const mutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
const response = await fetch('/api/renew', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ slug: shortSlug }),
|
||||
})
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok')
|
||||
}
|
||||
return response.json()
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!shortSlug) return
|
||||
|
||||
let timeout: NodeJS.Timeout | null = null
|
||||
|
||||
const run = (): void => {
|
||||
timeout = setTimeout(() => {
|
||||
mutation.mutate()
|
||||
run()
|
||||
}, renewInterval)
|
||||
}
|
||||
|
||||
run()
|
||||
|
||||
return () => {
|
||||
if (timeout) clearTimeout(timeout)
|
||||
}
|
||||
}, [shortSlug, mutation, renewInterval])
|
||||
}
|
||||
Loading…
Reference in New Issue