tntgroup's picture
feat: add auth approve flow - login route, admin page, Layout auth guard
3e1734c
Raw History Blame Contribute Delete
1.65 kB
import React, { Component } from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import { StoreProvider } from "./store";
import { VideoGenProvider } from "./stores/videoGenStore";
import { DirtyProvider } from "./stores/dirtyStore";
import { AuthProvider } from "./stores/authStore";
import "./theme.css";
class ErrorBoundary extends Component {
state = { err: null };
static getDerivedStateFromError(err) { return { err }; }
componentDidCatch(err, info) { console.error("Lỗi render:", err, info); }
render() {
if (this.state.err) {
return (
<div style={{ padding: 32, fontFamily: "system-ui, sans-serif" }}>
<h2 style={{ color: "#b3541e", margin: "0 0 8px" }}>Có lỗi xảy ra khi hiển thị</h2>
<p style={{ color: "#555", margin: "0 0 16px" }}>
{String(this.state.err.message || this.state.err)}
</p>
<button
onClick={() => window.location.reload()}
style={{
padding: "8px 16px", border: "1px solid #ddd", borderRadius: 8,
background: "#fff", cursor: "pointer", fontWeight: 600,
}}>
Tải lại trang
</button>
</div>
);
}
return this.props.children;
}
}
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<StoreProvider>
<AuthProvider>
<VideoGenProvider>
<DirtyProvider>
<ErrorBoundary>
<App />
</ErrorBoundary>
</DirtyProvider>
</VideoGenProvider>
</AuthProvider>
</StoreProvider>
</React.StrictMode>
);