feat: add NewsPaymentPage component and error boundary for payment route

This commit is contained in:
fredy.siswanto 2025-03-12 00:06:43 +07:00
parent 56d9081b4f
commit b9fb1112ae
2 changed files with 50 additions and 0 deletions

View 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>
)
}

View 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