refactor redux data model

This commit is contained in:
seavor 2026-04-15 21:48:03 -05:00
parent ae1bc3da38
commit 0ff391491d
243 changed files with 5212 additions and 5963 deletions

View file

@ -1,14 +1,12 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { ServerSelectors } from '@app/store';
import { ServerSelectors, useAppSelector } from '@app/store';
import { App } from '@app/types';
import { useAppSelector } from '@app/store';
import { AuthenticationService } from '@app/api';
const AuthGuard = () => {
const state = useAppSelector(s => ServerSelectors.getState(s));
return !AuthenticationService.isConnected(state)
const isConnected = useAppSelector(ServerSelectors.getIsConnected);
return !isConnected
? <Navigate to={App.RouteEnum.LOGIN} />
: <div></div>;
};

View file

@ -1,14 +1,12 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { ServerSelectors } from '@app/store';
import { AuthenticationService } from '@app/api';
import { ServerSelectors, useAppSelector } from '@app/store';
import { App } from '@app/types';
import { useAppSelector } from '@app/store';
const ModGuard = () => {
const user = useAppSelector(state => ServerSelectors.getUser(state));
return !AuthenticationService.isModerator(user)
const isModerator = useAppSelector(ServerSelectors.getIsUserModerator);
return !isModerator
? <Navigate to={App.RouteEnum.SERVER} />
: <></>;
};