root redirect to home buzzer
This commit is contained in:
parent
672b62b3ef
commit
d9475aca0a
@ -2,7 +2,6 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
|
||||
import { AuthPage, loader as authpageloader } from './pages/AuthPage';
|
||||
import { DoorPage, loader as doorpageloader } from './pages/DoorPage';
|
||||
|
||||
|
||||
@ -17,9 +16,9 @@ const router = createBrowserRouter([
|
||||
errorElement: <h1>error</h1>,
|
||||
children: [
|
||||
{
|
||||
path: "action/:action",
|
||||
loader: authpageloader,
|
||||
element: <AuthPage />,
|
||||
path: "",
|
||||
loader: doorpageloader,
|
||||
element: <DoorPage />
|
||||
},
|
||||
{
|
||||
path: "door/:door",
|
||||
|
||||
@ -7,7 +7,9 @@ import type { IDoorResponse } from "../../../server/src/types/IDoorResponse";
|
||||
import { CountdownBar } from "../components/CountdownBar";
|
||||
|
||||
export async function loader({ params }: any) {
|
||||
const response = await fetch(`/api/door/${params.door}`).then(res => res.json());
|
||||
const response = await fetch(params.door ? `/api/door/${params.door}`: `/api/door`).then(res => res.json());
|
||||
|
||||
console.log(response);
|
||||
|
||||
if (response.msg) {
|
||||
throw new Error("Not a valid door");
|
||||
@ -229,10 +231,14 @@ export function DoorPage() {
|
||||
<p>Enter the buzzer code at the front entrance</p>
|
||||
</TextContent>
|
||||
<OtpInput
|
||||
containerStyle={{
|
||||
width: "100%",
|
||||
justifyContent: "space-around",
|
||||
}}
|
||||
inputStyle={{
|
||||
margin: '1rem',
|
||||
margin: '0.5rem',
|
||||
height: '3rem',
|
||||
width: '3rem',
|
||||
width: '2rem',
|
||||
fontSize: '2rem',
|
||||
}}
|
||||
value={'2207'}
|
||||
|
||||
@ -2,7 +2,7 @@ import express from "express";
|
||||
import { getRedisClient } from "../clients/db/RedisDbProvider";
|
||||
import { doorStatusKey } from "../types/RedisKeys";
|
||||
import { HandleAuthMode } from "../middlewares/DoorAuthModes";
|
||||
import { getAuthModes, getDoorSettingNumber, getDoorSettingString } from "../util/EnvConfigUtil";
|
||||
import { getAllDoorNames, getAuthModes, getDoorSettingNumber, getDoorSettingString } from "../util/EnvConfigUtil";
|
||||
import { IDoorConfig } from "../types/IDoorConfig";
|
||||
import { TimeLockVerify } from "../middlewares/TimeLockMiddleware";
|
||||
import { IDoorStatus } from "../types/IDoorStatus";
|
||||
@ -10,6 +10,10 @@ import { IDoorStatus } from "../types/IDoorStatus";
|
||||
const router = express.Router();
|
||||
const client = await getRedisClient();
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
res.redirect(`/api/door/${Bun.env.DEFAULT_DOOR || getAllDoorNames()[0]}`);
|
||||
});
|
||||
|
||||
router.get('/:id', async(req, res) => {
|
||||
const doorId = req.params.id;
|
||||
const authModes = getAuthModes(doorId);
|
||||
|
||||
@ -6,5 +6,6 @@ declare module "bun" {
|
||||
DOOR_OPEN_TIMEOUT: number;
|
||||
DOOR_FIXED_PIN: string;
|
||||
ROTATING_KEY_NTFY: string;
|
||||
DEFAULT_DOOR: string;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user