mirror of
https://github.com/usatiuk/y.git
synced 2025-10-28 10:37:47 +01:00
pain and suffering
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"start": "parcel",
|
||||
"build": "parcel build"
|
||||
},
|
||||
"publicUrl": "/app",
|
||||
"browserslist": "> 0.5%, last 2 versions, not dead",
|
||||
"dependencies": {
|
||||
"jwt-decode": "^4.0.0",
|
||||
|
||||
@@ -39,95 +39,98 @@ import { Chat } from "./Chat";
|
||||
import { ChatEdit } from "./ChatEdit";
|
||||
import { Haters } from "./Haters";
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: "/",
|
||||
loader: async () => {
|
||||
if (getToken() == null) {
|
||||
return redirect("/login");
|
||||
} else {
|
||||
return redirect("/home");
|
||||
}
|
||||
const router = createBrowserRouter(
|
||||
[
|
||||
{
|
||||
path: "/",
|
||||
loader: async () => {
|
||||
if (getToken() == null) {
|
||||
return redirect("/login");
|
||||
} else {
|
||||
return redirect("/home");
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/home",
|
||||
loader: homeLoader,
|
||||
action: homeAction,
|
||||
element: <Home />,
|
||||
children: [
|
||||
{ path: "feed", element: <Feed />, loader: feedLoader },
|
||||
// { path: "messages", element: <Messages /> },
|
||||
{
|
||||
path: "messages/chats",
|
||||
element: <Chats />,
|
||||
loader: chatListLoader,
|
||||
},
|
||||
{
|
||||
path: "messages/chats/new",
|
||||
element: <ChatCreate />,
|
||||
loader: newChatLoader,
|
||||
action: newChatAction,
|
||||
},
|
||||
{
|
||||
path: "messages/chat/:id",
|
||||
element: <Chat />,
|
||||
loader: chatLoader,
|
||||
action: chatAction,
|
||||
},
|
||||
{
|
||||
path: "messages/chat/:id/edit",
|
||||
element: <ChatEdit />,
|
||||
loader: editChatLoader,
|
||||
action: editChatAction,
|
||||
},
|
||||
{
|
||||
path: "users",
|
||||
element: <UserList />,
|
||||
loader: userListLoader,
|
||||
action: userListAction,
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
loader: profileLoader,
|
||||
action: profileSelfAction,
|
||||
element: <Profile self={true} />,
|
||||
},
|
||||
{
|
||||
path: "profile/:username",
|
||||
loader: profileLoader,
|
||||
// action: profileSelfAction,
|
||||
element: <Profile self={false} />,
|
||||
},
|
||||
{
|
||||
path: "haters",
|
||||
element: <Haters />,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
element: <Login />,
|
||||
loader: async () => {
|
||||
if (getToken()) {
|
||||
return redirect("/");
|
||||
}
|
||||
return null;
|
||||
{
|
||||
path: "/home",
|
||||
loader: homeLoader,
|
||||
action: homeAction,
|
||||
element: <Home />,
|
||||
children: [
|
||||
{ path: "feed", element: <Feed />, loader: feedLoader },
|
||||
// { path: "messages", element: <Messages /> },
|
||||
{
|
||||
path: "messages/chats",
|
||||
element: <Chats />,
|
||||
loader: chatListLoader,
|
||||
},
|
||||
{
|
||||
path: "messages/chats/new",
|
||||
element: <ChatCreate />,
|
||||
loader: newChatLoader,
|
||||
action: newChatAction,
|
||||
},
|
||||
{
|
||||
path: "messages/chat/:id",
|
||||
element: <Chat />,
|
||||
loader: chatLoader,
|
||||
action: chatAction,
|
||||
},
|
||||
{
|
||||
path: "messages/chat/:id/edit",
|
||||
element: <ChatEdit />,
|
||||
loader: editChatLoader,
|
||||
action: editChatAction,
|
||||
},
|
||||
{
|
||||
path: "users",
|
||||
element: <UserList />,
|
||||
loader: userListLoader,
|
||||
action: userListAction,
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
loader: profileLoader,
|
||||
action: profileSelfAction,
|
||||
element: <Profile self={true} />,
|
||||
},
|
||||
{
|
||||
path: "profile/:username",
|
||||
loader: profileLoader,
|
||||
// action: profileSelfAction,
|
||||
element: <Profile self={false} />,
|
||||
},
|
||||
{
|
||||
path: "haters",
|
||||
element: <Haters />,
|
||||
},
|
||||
],
|
||||
},
|
||||
action: loginAction,
|
||||
},
|
||||
{
|
||||
path: "/signup",
|
||||
element: <Signup />,
|
||||
loader: async () => {
|
||||
if (getToken()) {
|
||||
return redirect("/");
|
||||
}
|
||||
return null;
|
||||
{
|
||||
path: "/login",
|
||||
element: <Login />,
|
||||
loader: async () => {
|
||||
if (getToken()) {
|
||||
return redirect("/");
|
||||
}
|
||||
return null;
|
||||
},
|
||||
action: loginAction,
|
||||
},
|
||||
action: signupAction,
|
||||
},
|
||||
]);
|
||||
{
|
||||
path: "/signup",
|
||||
element: <Signup />,
|
||||
loader: async () => {
|
||||
if (getToken()) {
|
||||
return redirect("/");
|
||||
}
|
||||
return null;
|
||||
},
|
||||
action: signupAction,
|
||||
},
|
||||
],
|
||||
{ basename: "/app" },
|
||||
);
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
|
||||
@@ -3,7 +3,14 @@
|
||||
import { jwtDecode } from "jwt-decode";
|
||||
import { isError } from "./dto";
|
||||
|
||||
const apiRoot: string = "http://localhost:8080";
|
||||
declare const process: {
|
||||
env: {
|
||||
NODE_ENV: string;
|
||||
};
|
||||
};
|
||||
|
||||
const apiRoot: string =
|
||||
process.env.NODE_ENV == "production" ? "/" : "http://localhost:8080";
|
||||
|
||||
let token: string | null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user