mirror of
https://github.com/dsoaress/link-free.git
synced 2026-08-17 06:56:04 +01:00
fix: add error pages
This commit is contained in:
@@ -2,7 +2,6 @@ import { isEqual } from 'lodash'
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import Collapsible from 'react-collapsible'
|
import Collapsible from 'react-collapsible'
|
||||||
|
|
||||||
import { useAuth } from 'hooks/useAuth'
|
|
||||||
import { useData } from 'hooks/useData'
|
import { useData } from 'hooks/useData'
|
||||||
import { getLocalStorageData, setLocalStorageData } from 'utils/localStorage'
|
import { getLocalStorageData, setLocalStorageData } from 'utils/localStorage'
|
||||||
import { Home } from 'components/Home'
|
import { Home } from 'components/Home'
|
||||||
@@ -22,9 +21,6 @@ export function Dash({ initialData }: DashProps) {
|
|||||||
const { data, setData } = useData()
|
const { data, setData } = useData()
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false)
|
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false)
|
||||||
const [activeTab, setActiveTab] = useState<'data' | 'colors'>('data')
|
|
||||||
|
|
||||||
const { user } = useAuth()
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -43,12 +39,6 @@ export function Dash({ initialData }: DashProps) {
|
|||||||
}
|
}
|
||||||
}, [data, initialData, isLoading, setData])
|
}, [data, initialData, isLoading, setData])
|
||||||
|
|
||||||
const tabs = [
|
|
||||||
{ label: 'Data', value: 'data' },
|
|
||||||
{ label: 'Colors', value: 'colors' }
|
|
||||||
]
|
|
||||||
const body = { data: <DataSettings />, colors: <ColorsSettings /> }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Content>
|
<Content>
|
||||||
@@ -59,15 +49,8 @@ export function Dash({ initialData }: DashProps) {
|
|||||||
/>
|
/>
|
||||||
<h1>Dash </h1>
|
<h1>Dash </h1>
|
||||||
|
|
||||||
<pre>{JSON.stringify(user, null, 2)}</pre>
|
<DataSettings />
|
||||||
|
<ColorsSettings />
|
||||||
{tabs.map((tab, i) => (
|
|
||||||
<button key={i} onClick={() => setActiveTab(tab.value as 'data' | 'colors')}>
|
|
||||||
{tab.label}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{body[activeTab]}
|
|
||||||
|
|
||||||
<Collapsible trigger="Start here">
|
<Collapsible trigger="Start here">
|
||||||
<p>This is the collapsible content. It can be any element or React component you like.</p>
|
<p>This is the collapsible content. It can be any element or React component you like.</p>
|
||||||
|
|||||||
12
src/pages/404.tsx
Normal file
12
src/pages/404.tsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { fetchData } from 'services/fetchData'
|
||||||
|
|
||||||
|
import type { GetStaticProps } from 'next'
|
||||||
|
|
||||||
|
export default function NotFoundPage() {
|
||||||
|
return <div>Not found</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getStaticProps: GetStaticProps = async () => {
|
||||||
|
const initialData = await fetchData()
|
||||||
|
return { props: { initialData }, revalidate: 1 }
|
||||||
|
}
|
||||||
12
src/pages/500.tsx
Normal file
12
src/pages/500.tsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { fetchData } from 'services/fetchData'
|
||||||
|
|
||||||
|
import type { GetStaticProps } from 'next'
|
||||||
|
|
||||||
|
export default function InternalErrorPage() {
|
||||||
|
return <div>Internal server error</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getStaticProps: GetStaticProps = async () => {
|
||||||
|
const initialData = await fetchData()
|
||||||
|
return { props: { initialData }, revalidate: 1 }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user