feat: add NewsPaymentPage component and error boundary for payment route
This commit is contained in:
parent
56d9081b4f
commit
b9fb1112ae
13
app/pages/news-payment/index.tsx
Normal file
13
app/pages/news-payment/index.tsx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { Card } from '~/components/ui/card'
|
||||||
|
|
||||||
|
export const NewsPaymentPage = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="sm-max:mx-5 relative">
|
||||||
|
<Card>
|
||||||
|
<h1>Payment</h1>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
37
app/routes/_news.payment.tsx
Normal file
37
app/routes/_news.payment.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { isRouteErrorResponse } from 'react-router'
|
||||||
|
|
||||||
|
import { NewsPaymentPage } from '~/pages/news-payment'
|
||||||
|
|
||||||
|
import type { Route } from './+types/_news.payment'
|
||||||
|
|
||||||
|
export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => {
|
||||||
|
let message = 'Oops!'
|
||||||
|
let details = 'An unexpected error occurred.'
|
||||||
|
let stack: string | undefined
|
||||||
|
|
||||||
|
if (isRouteErrorResponse(error)) {
|
||||||
|
message = error.status === 404 ? '404' : 'Error'
|
||||||
|
details =
|
||||||
|
error.status === 404
|
||||||
|
? 'The requested page could not be found.'
|
||||||
|
: error.statusText || details
|
||||||
|
} else if (import.meta.env.DEV && error && error instanceof Error) {
|
||||||
|
details = error.message
|
||||||
|
stack = error.stack
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container mx-auto p-4">
|
||||||
|
<h1>{message}</h1>
|
||||||
|
<p>{details}</p>
|
||||||
|
{stack && (
|
||||||
|
<pre className="w-full p-4 whitespace-pre-wrap">
|
||||||
|
<code>{stack}</code>
|
||||||
|
</pre>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const NewsPaymentLayout = () => <NewsPaymentPage />
|
||||||
|
|
||||||
|
export default NewsPaymentLayout
|
||||||
Loading…
x
Reference in New Issue
Block a user