generated from lucien/api-template
add: added 404 page and fixed home loading display
This commit is contained in:
parent
63914b5b3b
commit
d28e14e262
5 changed files with 58 additions and 1 deletions
38
front/src/pages/404.tsx
Normal file
38
front/src/pages/404.tsx
Normal file
|
@ -0,0 +1,38 @@
|
|||
import TopBar from "../components/TopBar";
|
||||
import { Link } from "react-router-dom";
|
||||
import { User } from "../types";
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
|
||||
import "../styles/404.css";
|
||||
|
||||
export default function NotFoundPage() {
|
||||
const [user, setUser] = useState<User | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
const token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
axios
|
||||
.post("/api/auth/me", {
|
||||
token
|
||||
})
|
||||
.then((res) => {
|
||||
setUser(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err.response);
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="not-found-page">
|
||||
<TopBar user={user} />
|
||||
<div className="not-found-content">
|
||||
<h2>404 - Page Not Found</h2>
|
||||
<p>Sorry, the page you are looking for does not exist.</p>
|
||||
<Link to="/">Go back to the homepage</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -93,6 +93,8 @@ export default function ChannelPage({socket}: {socket: WebSocket}) {
|
|||
});
|
||||
}, [channel])
|
||||
|
||||
console.log(channel)
|
||||
|
||||
useEffect(() => {
|
||||
const words = message.toString().split(" ");
|
||||
const lastWord = words[words.length - 1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue