Fix tsc errors (#649)
* fixed tsc errors * fixed tsc errors * fixed tsc errors * fixing tsc errors * fixing more tsc errors * fixing more tsc errors * fixed tsc errors * fixing tsc errors * fixing PR issues * commented out tsc check * completing tsc fixes * updating lockfile * removed react-hooks
This commit is contained in:
+33
-2
@@ -4,10 +4,11 @@ import MessagesPage from "@pages/Messages.tsx";
|
||||
import MapPage from "@pages/Map/index.tsx";
|
||||
import ConfigPage from "@pages/Config/index.tsx";
|
||||
import ChannelsPage from "@pages/Channels.tsx";
|
||||
import NodesPage from "@pages/Nodes.tsx";
|
||||
import NodesPage from "@pages/Nodes/index.tsx";
|
||||
import { createRootRoute } from "@tanstack/react-router";
|
||||
import { App } from "./App.tsx";
|
||||
import { DialogManager } from "@components/Dialog/DialogManager.tsx";
|
||||
import { z } from "zod";
|
||||
|
||||
const rootRoute = createRootRoute({
|
||||
component: App,
|
||||
@@ -27,12 +28,42 @@ const messagesRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/messages",
|
||||
component: MessagesPage,
|
||||
beforeLoad: ({ params }) => {
|
||||
const DEFAULT_CHANNEL = 0;
|
||||
|
||||
if (Object.values(params).length === 0) {
|
||||
throw redirect({
|
||||
to: `/messages/broadcast/${DEFAULT_CHANNEL}`,
|
||||
replace: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const messagesWithParamsRoute = createRoute({
|
||||
const chatIdSchema = z.string().refine((val) => {
|
||||
const num = Number(val);
|
||||
if (isNaN(num) || !Number.isInteger(num)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isChannelId = num >= 0 && num <= 10;
|
||||
const isNodeId = num >= 1000000000 && num <= 9999999999;
|
||||
|
||||
return isChannelId || isNodeId;
|
||||
}, {
|
||||
message: "Chat ID must be a channel (0-10) or a valid node ID.",
|
||||
});
|
||||
|
||||
export const messagesWithParamsRoute = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/messages/$type/$chatId",
|
||||
component: MessagesPage,
|
||||
parseParams: (params) => ({
|
||||
type: z.enum(["direct", "broadcast"], {
|
||||
errorMap: () => ({ message: 'Type must be "direct" or "broadcast".' }),
|
||||
}).parse(params.type),
|
||||
chatId: chatIdSchema.parse(params.chatId),
|
||||
}),
|
||||
});
|
||||
|
||||
const mapRoute = createRoute({
|
||||
|
||||
Reference in New Issue
Block a user