Skip to content

Instantly share code, notes, and snippets.

@joe-oli
Last active April 8, 2025 06:27
Show Gist options
  • Save joe-oli/93e22d22c5fa606a35eaa2b302f467e1 to your computer and use it in GitHub Desktop.
Save joe-oli/93e22d22c5fa606a35eaa2b302f467e1 to your computer and use it in GitHub Desktop.

🧩 Tip for SCSS Setup with Bootstrap

In main.scss:

@import "./bootstrap-custom.scss"; // your custom bootstrap overrides
@import "bootstrap/scss/bootstrap"; // then import Bootstrap SCSS itself

In vite.config.ts, make sure your scss files are properly picked up:

css: {
  preprocessorOptions: {
    scss: {
      additionalData: `@import "src/styles/_variables.scss";`
    }
  }
}

See below for a router.tsx example, and OrderList.tsx too.

//Of course sketch it out, can't refuse help when it's offered :-)
Haha, love that attitude πŸ˜„ β€” here’s a solid sketch of both `router.tsx` and a sample `OrderList.tsx` to get you started with best practices but still keep it simple and readable.
---
### πŸ“„ `src/router.tsx`
This sets up basic routing using React Router (v6+).
```tsx
// src/router.tsx
import { BrowserRouter, Routes, Route } from "react-router-dom";
import HomePage from "./pages/HomePage";
import AdminDashboard from "./pages/AdminDashboard";
import OrderList from "./features/Orders/OrderList";
const AppRouter = () => {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/admin" element={<AdminDashboard />} />
<Route path="/orders" element={<OrderList />} />
{/* add more routes as needed */}
</Routes>
</BrowserRouter>
);
};
export default AppRouter;
```
---
### πŸ“„ `src/App.tsx`
Your root component, which wraps the router.
```tsx
// src/App.tsx
import "bootstrap/dist/css/bootstrap.min.css"; // optional, if not using SCSS build
import "./styles/main.scss";
import AppRouter from "./router";
function App() {
return <AppRouter />;
}
export default App;
```
---
### πŸ“„ `src/features/Orders/OrderList.tsx`
Example component that:
- Fetches orders from your backend
- Uses `fetchWithAuth`
- Displays a Bootstrap-styled table
```tsx
// src/features/Orders/OrderList.tsx
import { useEffect, useState } from "react";
import { fetchWithAuth } from "../../shared/api/fetchClient";
import Table from "react-bootstrap/Table";
type Order = {
id: number;
customerName: string;
status: string;
createdAt: string;
};
const OrderList = () => {
const [orders, setOrders] = useState<Order[]>([]);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const sessionToken = "your-session-token-here"; // replace with context or hook
fetchWithAuth("/api/Orders", {}, sessionToken)
.then((data: Order[]) => setOrders(data))
.catch((err) => setError(err.message));
}, []);
return (
<div className="container mt-4">
<h2>Order List</h2>
{error && <div className="alert alert-danger">{error}</div>}
<Table striped bordered hover>
<thead>
<tr>
<th>ID</th>
<th>Customer</th>
<th>Status</th>
<th>Created</th>
</tr>
</thead>
<tbody>
{orders.map((order) => (
<tr key={order.id}>
<td>{order.id}</td>
<td>{order.customerName}</td>
<td>{order.status}</td>
<td>{new Date(order.createdAt).toLocaleString()}</td>
</tr>
))}
</tbody>
</Table>
</div>
);
};
export default OrderList;
```
---
Let me know if you want an example of:
- session token management with context or a hook
- a layout wrapper (`MainLayout`) for shared header/sidebar
- a Bootstrap modal component
- or a matching `orderApi.ts` file
I’m here for all of it.
ui/
β”œβ”€β”€ public/
β”‚ └── index.html
β”‚
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ index.tsx
β”‚ β”œβ”€β”€ App.tsx
β”‚ β”œβ”€β”€ router.tsx
β”‚
β”‚ β”œβ”€β”€ assets/
β”‚ β”‚ β”œβ”€β”€ logo.svg
β”‚ β”‚ └── fonts/
β”‚
β”‚ β”œβ”€β”€ components/
β”‚ β”‚ β”œβ”€β”€ Button.tsx
β”‚ β”‚ └── Modal.tsx
β”‚
β”‚ β”œβ”€β”€ features/
β”‚ β”‚ β”œβ”€β”€ Orders/
β”‚ β”‚ β”‚ β”œβ”€β”€ OrderList.tsx
β”‚ β”‚ β”‚ β”œβ”€β”€ OrderDetail.tsx
β”‚ β”‚ β”‚ β”œβ”€β”€ orderApi.ts
β”‚ β”‚ β”‚ └── orderTypes.ts
β”‚ β”‚ └── Notifications/
β”‚ β”‚ β”œβ”€β”€ NotificationList.tsx
β”‚ β”‚ └── notificationApi.ts
β”‚
β”‚ β”œβ”€β”€ pages/
β”‚ β”‚ β”œβ”€β”€ HomePage.tsx
β”‚ β”‚ └── AdminDashboard.tsx
β”‚
β”‚ β”œβ”€β”€ shared/
β”‚ β”‚ β”œβ”€β”€ hooks/
β”‚ β”‚ β”‚ β”œβ”€β”€ useSessionToken.ts
β”‚ β”‚ β”‚ └── useDebounce.ts
β”‚ β”‚ β”œβ”€β”€ api/
β”‚ β”‚ β”‚ └── fetchClient.ts
β”‚ β”‚ └── constants.ts
β”‚
β”‚ β”œβ”€β”€ styles/
β”‚ β”‚ β”œβ”€β”€ bootstrap-custom.scss
β”‚ β”‚ β”œβ”€β”€ main.scss
β”‚ β”‚ └── _variables.scss
β”‚
β”‚ β”œβ”€β”€ types/
β”‚ β”‚ β”œβ”€β”€ common.d.ts
β”‚ β”‚ └── user.d.ts
β”‚
β”‚
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ vite.config.ts
β”œβ”€β”€ README.md
└── .gitignore
// src/router.tsx
import { BrowserRouter, Routes, Route } from "react-router-dom";
import HomePage from "./pages/HomePage";
import AdminDashboard from "./pages/AdminDashboard";
import OrderList from "./features/Orders/OrderList";
const AppRouter = () => {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/admin" element={<AdminDashboard />} />
<Route path="/orders" element={<OrderList />} />
{/* add more routes as needed */}
</Routes>
</BrowserRouter>
);
};
export default AppRouter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment