Compare commits
No commits in common. "d3ab2a8f7d977831144e4f7a5505100d6495c675" and "553d7496330bc26b14cc273e8b5ac69e893e247f" have entirely different histories.
d3ab2a8f7d
...
553d749633
|
|
@ -5,13 +5,11 @@ import { Spin } from "antd";
|
|||
import { hasAbility } from "./utils/hasAbility";
|
||||
import { renderRoutesRecursively } from "./Components/Routes/RenderRoutesRecursively";
|
||||
import { RenderRouteElement } from "./Components/Routes/RenderRouteElement";
|
||||
import { UserTypeEnum } from "./enums/UserType";
|
||||
import { RoleByType } from "./utils/RoleByType";
|
||||
|
||||
const Page404 = lazy(() => import("./Layout/Ui/NotFoundPage"));
|
||||
const Auth = lazy(() => import("./Pages/Auth/Page"));
|
||||
const App = () => {
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route
|
||||
|
|
@ -33,14 +31,10 @@ const App = () => {
|
|||
}
|
||||
/>
|
||||
|
||||
|
||||
{renderRoutesRecursively(menuItems)}
|
||||
|
||||
{CrudRoute.map((route) => {
|
||||
const useAbility = hasAbility(route.abilities, route.abilities_value);
|
||||
if(!RoleByType(route)){
|
||||
return false ;
|
||||
}
|
||||
if (!useAbility) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import { MenuItem } from "../../Components/Layout/SideBar/MenuItem";
|
|||
import { CiMenuBurger, CiSettings } from "react-icons/ci";
|
||||
import { IoIosMenu } from "react-icons/io";
|
||||
import { HiMenuAlt2, HiMenuAlt3 } from "react-icons/hi";
|
||||
import { RoleByType } from "../../utils/RoleByType";
|
||||
|
||||
const SideBar = ({
|
||||
isOpen,
|
||||
|
|
@ -50,10 +49,6 @@ const SideBar = ({
|
|||
if (!useAbility) {
|
||||
return <React.Fragment key={index}></React.Fragment>;
|
||||
}
|
||||
if(!RoleByType(item)){
|
||||
|
||||
return <React.Fragment key={index}></React.Fragment> ;
|
||||
}
|
||||
return (
|
||||
<MenuItem
|
||||
key={index}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import { hasAbility } from "./utils/hasAbility";
|
|||
import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "./enums/abilities";
|
||||
import { ParamsEnum } from "./enums/params";
|
||||
import { TbCategory } from "react-icons/tb";
|
||||
import { UserTypeEnum } from "./enums/UserType";
|
||||
|
||||
export const menuItems: TMenuItem[] = [
|
||||
{
|
||||
|
|
@ -48,7 +47,6 @@ export const menuItems: TMenuItem[] = [
|
|||
abilities: ABILITIES_ENUM?.PASS,
|
||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
||||
prevPath: 0,
|
||||
type:UserTypeEnum?.PASS
|
||||
},
|
||||
{
|
||||
header: "page_header.grade",
|
||||
|
|
@ -89,7 +87,6 @@ export const menuItems: TMenuItem[] = [
|
|||
abilities: ABILITIES_ENUM?.STUDENT,
|
||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
||||
prevPath: 0,
|
||||
type:UserTypeEnum.RE_SELLER
|
||||
},
|
||||
{
|
||||
header: "page_header.reSeller",
|
||||
|
|
|
|||
|
|
@ -18,14 +18,23 @@
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--white);
|
||||
|
||||
h1 {
|
||||
font-size: 1.5vw;
|
||||
font-weight: 400;
|
||||
}
|
||||
p {
|
||||
font-size: 1vw;
|
||||
font-weight: 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.AuthForm {
|
||||
|
||||
height: 440px;
|
||||
width: 600px;
|
||||
img {
|
||||
width: 5vw;
|
||||
}
|
||||
height: 30vw;
|
||||
width: 40vw;
|
||||
min-width: 300px;
|
||||
|
||||
box-shadow: 2px 2px 8px 3px rgba(0, 0, 0, 0.2);
|
||||
|
|
@ -33,7 +42,7 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 40px;
|
||||
padding: 3vw;
|
||||
border-radius: 10px;
|
||||
gap: 10px;
|
||||
.AuthInput {
|
||||
|
|
@ -43,13 +52,13 @@
|
|||
.Input {
|
||||
border-radius: 5px !important;
|
||||
border-color: rgba(128, 128, 128, 0.152);
|
||||
height: 40px;
|
||||
height: 3vw;
|
||||
}
|
||||
}
|
||||
.AuthSelect {
|
||||
min-width: 100% !important;
|
||||
.Select {
|
||||
height: 40px;
|
||||
height: 3vw;
|
||||
}
|
||||
.ant-select-single.ant-select-lg {
|
||||
width: 100%;
|
||||
|
|
@ -69,7 +78,7 @@
|
|||
}
|
||||
}
|
||||
.form-label {
|
||||
font-size: 20px;
|
||||
font-size: 1vw;
|
||||
color: #202c4b;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
export enum UserTypeEnum {
|
||||
ADMIN = "admin",
|
||||
RE_SELLER = "reseller",
|
||||
PASS="pass"
|
||||
}
|
||||
|
||||
|
|
@ -2,7 +2,6 @@ import { ReactElement, LazyExoticComponent, ReactNode } from "react";
|
|||
import { Mark_State, Payment_type, term_type } from "./Item";
|
||||
import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "../enums/abilities";
|
||||
import dayjs from "dayjs";
|
||||
import { UserTypeEnum } from "../enums/UserType";
|
||||
|
||||
export type ChildrenType = {
|
||||
children: ReactNode;
|
||||
|
|
@ -16,7 +15,6 @@ type TMenuItemBase = {
|
|||
withOutLayout?: boolean;
|
||||
abilities: ABILITIES_ENUM;
|
||||
abilities_value: ABILITIES_VALUES_ENUM;
|
||||
type?:UserTypeEnum
|
||||
prevPath: number;
|
||||
};
|
||||
|
||||
|
|
@ -40,7 +38,6 @@ export type TCrudRoute = {
|
|||
element: ReactElement | LazyExoticComponent<any>;
|
||||
abilities: ABILITIES_ENUM;
|
||||
abilities_value: ABILITIES_VALUES_ENUM;
|
||||
type?:UserTypeEnum
|
||||
prevPath: number;
|
||||
};
|
||||
|
||||
|
|
@ -51,6 +48,7 @@ export interface CardData {
|
|||
percentage: number;
|
||||
Good?: boolean;
|
||||
}
|
||||
|
||||
export const nationalities: { value: string; label: string }[] = [
|
||||
{ label: "select.nationalities.Afghan", value: "Afghan" },
|
||||
{ label: "select.nationalities.Albanian", value: "Albanian" },
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
import { USER_KEY } from "../config/AppKey";
|
||||
import { UserTypeEnum } from "../enums/UserType";
|
||||
import { getLocalStorage } from "./LocalStorage";
|
||||
|
||||
export const RoleByType = (item: { type?: string }):boolean=>{
|
||||
const type = item?.type ?? UserTypeEnum.ADMIN;
|
||||
const LocalType = getLocalStorage(USER_KEY)?.type ?? undefined ;
|
||||
const isAdmin = LocalType === UserTypeEnum.ADMIN ;
|
||||
const isReSeller = LocalType === UserTypeEnum.RE_SELLER;
|
||||
const isAdminRoute = type === UserTypeEnum.ADMIN ;
|
||||
const isReSellerRoute = type === UserTypeEnum.RE_SELLER;
|
||||
console.log(LocalType);
|
||||
|
||||
if(!LocalType){
|
||||
return false
|
||||
}
|
||||
if(type === UserTypeEnum.PASS) { return true } ;
|
||||
|
||||
if(isAdmin && isReSellerRoute ){
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(isReSeller && !isReSellerRoute ){
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user