Skip to content

Commit

Permalink
chore: code optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
rimorin committed Sep 11, 2024
1 parent 58f8837 commit aef2dd4
Show file tree
Hide file tree
Showing 15 changed files with 407 additions and 288 deletions.
41 changes: 41 additions & 0 deletions src/components/statics/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";
import { Container, Card, Button } from "react-bootstrap";
import { useRouteError } from "react-router-dom";

interface ErrorPageProps {
onRetry?: () => void;
}

const GenericErrorPage: React.FC<ErrorPageProps> = ({ onRetry }) => {
const error = useRouteError() as Error;
const title = "An Error Occurred";
const message = "We are sorry, something went wrong.";

return (
<Container className="container-main">
<Card className="card-main">
<Card.Img
alt="Ministry Mapper logo"
className="mm-logo"
src="/android-chrome-192x192.png"
/>
<Card.Body>
<Card.Title className="text-center">{title}</Card.Title>
<Card.Text className="text-center">{message}</Card.Text>
{error && (
<Card.Text className="text-center">
<small>{error.message}</small>
</Card.Text>
)}
{onRetry && (
<div className="text-center">
<Button onClick={onRetry}>Retry</Button>
</div>
)}
</Card.Body>
</Card>
</Container>
);
};

export default GenericErrorPage;
35 changes: 13 additions & 22 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import Main from "./pages/index";
import { BrowserRouter } from "react-router-dom";
import { StrictMode } from "react";
import NiceModal from "@ebay/nice-modal-react";
import RollbarMiddleware from "./components/middlewares/rollbar";
import MapsMiddleware from "./components/middlewares/googlemap";
import PostHogMiddleware from "./components/middlewares/posthog";

const root = createRoot(document.getElementById("root") as HTMLElement);
root.render(
<StrictMode>
<RollbarMiddleware>
<PostHogMiddleware>
<MapsMiddleware>
<NiceModal.Provider>
<BrowserRouter>
<Main />
</BrowserRouter>
</NiceModal.Provider>
</MapsMiddleware>
</PostHogMiddleware>
</RollbarMiddleware>
</StrictMode>
);
const rootElement = document.getElementById("root");

if (rootElement) {
const root = createRoot(rootElement);
root.render(
<StrictMode>
<Main />
</StrictMode>
);
} else {
console.error("Root element not found");
}
Loading

0 comments on commit aef2dd4

Please sign in to comment.