Compare commits

..

No commits in common. "d3ab2a8f7d977831144e4f7a5505100d6495c675" and "553d7496330bc26b14cc273e8b5ac69e893e247f" have entirely different histories.

7 changed files with 20 additions and 61 deletions

View File

@ -5,13 +5,11 @@ import { Spin } from "antd";
import { hasAbility } from "./utils/hasAbility"; import { hasAbility } from "./utils/hasAbility";
import { renderRoutesRecursively } from "./Components/Routes/RenderRoutesRecursively"; import { renderRoutesRecursively } from "./Components/Routes/RenderRoutesRecursively";
import { RenderRouteElement } from "./Components/Routes/RenderRouteElement"; import { RenderRouteElement } from "./Components/Routes/RenderRouteElement";
import { UserTypeEnum } from "./enums/UserType";
import { RoleByType } from "./utils/RoleByType";
const Page404 = lazy(() => import("./Layout/Ui/NotFoundPage")); const Page404 = lazy(() => import("./Layout/Ui/NotFoundPage"));
const Auth = lazy(() => import("./Pages/Auth/Page")); const Auth = lazy(() => import("./Pages/Auth/Page"));
const App = () => {
const App = () => {
return ( return (
<Routes> <Routes>
<Route <Route
@ -33,14 +31,10 @@ const App = () => {
} }
/> />
{renderRoutesRecursively(menuItems)} {renderRoutesRecursively(menuItems)}
{CrudRoute.map((route) => { {CrudRoute.map((route) => {
const useAbility = hasAbility(route.abilities, route.abilities_value); const useAbility = hasAbility(route.abilities, route.abilities_value);
if(!RoleByType(route)){
return false ;
}
if (!useAbility) { if (!useAbility) {
return false; return false;
} }

View File

@ -12,7 +12,6 @@ import { MenuItem } from "../../Components/Layout/SideBar/MenuItem";
import { CiMenuBurger, CiSettings } from "react-icons/ci"; import { CiMenuBurger, CiSettings } from "react-icons/ci";
import { IoIosMenu } from "react-icons/io"; import { IoIosMenu } from "react-icons/io";
import { HiMenuAlt2, HiMenuAlt3 } from "react-icons/hi"; import { HiMenuAlt2, HiMenuAlt3 } from "react-icons/hi";
import { RoleByType } from "../../utils/RoleByType";
const SideBar = ({ const SideBar = ({
isOpen, isOpen,
@ -50,10 +49,6 @@ const SideBar = ({
if (!useAbility) { if (!useAbility) {
return <React.Fragment key={index}></React.Fragment>; return <React.Fragment key={index}></React.Fragment>;
} }
if(!RoleByType(item)){
return <React.Fragment key={index}></React.Fragment> ;
}
return ( return (
<MenuItem <MenuItem
key={index} key={index}

View File

@ -36,7 +36,6 @@ import { hasAbility } from "./utils/hasAbility";
import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "./enums/abilities"; import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "./enums/abilities";
import { ParamsEnum } from "./enums/params"; import { ParamsEnum } from "./enums/params";
import { TbCategory } from "react-icons/tb"; import { TbCategory } from "react-icons/tb";
import { UserTypeEnum } from "./enums/UserType";
export const menuItems: TMenuItem[] = [ export const menuItems: TMenuItem[] = [
{ {
@ -48,7 +47,6 @@ export const menuItems: TMenuItem[] = [
abilities: ABILITIES_ENUM?.PASS, abilities: ABILITIES_ENUM?.PASS,
abilities_value: ABILITIES_VALUES_ENUM.INDEX, abilities_value: ABILITIES_VALUES_ENUM.INDEX,
prevPath: 0, prevPath: 0,
type:UserTypeEnum?.PASS
}, },
{ {
header: "page_header.grade", header: "page_header.grade",
@ -89,7 +87,6 @@ export const menuItems: TMenuItem[] = [
abilities: ABILITIES_ENUM?.STUDENT, abilities: ABILITIES_ENUM?.STUDENT,
abilities_value: ABILITIES_VALUES_ENUM.INDEX, abilities_value: ABILITIES_VALUES_ENUM.INDEX,
prevPath: 0, prevPath: 0,
type:UserTypeEnum.RE_SELLER
}, },
{ {
header: "page_header.reSeller", header: "page_header.reSeller",

View File

@ -18,14 +18,23 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: var(--white); color: var(--white);
h1 {
font-size: 1.5vw;
font-weight: 400;
}
p {
font-size: 1vw;
font-weight: 200;
}
} }
} }
.AuthForm { .AuthForm {
img {
height: 440px; width: 5vw;
width: 600px; }
height: 30vw;
width: 40vw;
min-width: 300px; min-width: 300px;
box-shadow: 2px 2px 8px 3px rgba(0, 0, 0, 0.2); box-shadow: 2px 2px 8px 3px rgba(0, 0, 0, 0.2);
@ -33,7 +42,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 40px; padding: 3vw;
border-radius: 10px; border-radius: 10px;
gap: 10px; gap: 10px;
.AuthInput { .AuthInput {
@ -43,13 +52,13 @@
.Input { .Input {
border-radius: 5px !important; border-radius: 5px !important;
border-color: rgba(128, 128, 128, 0.152); border-color: rgba(128, 128, 128, 0.152);
height: 40px; height: 3vw;
} }
} }
.AuthSelect { .AuthSelect {
min-width: 100% !important; min-width: 100% !important;
.Select { .Select {
height: 40px; height: 3vw;
} }
.ant-select-single.ant-select-lg { .ant-select-single.ant-select-lg {
width: 100%; width: 100%;
@ -69,7 +78,7 @@
} }
} }
.form-label { .form-label {
font-size: 20px; font-size: 1vw;
color: #202c4b; color: #202c4b;
} }
} }

View File

@ -1,6 +0,0 @@
export enum UserTypeEnum {
ADMIN = "admin",
RE_SELLER = "reseller",
PASS="pass"
}

View File

@ -2,7 +2,6 @@ import { ReactElement, LazyExoticComponent, ReactNode } from "react";
import { Mark_State, Payment_type, term_type } from "./Item"; import { Mark_State, Payment_type, term_type } from "./Item";
import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "../enums/abilities"; import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "../enums/abilities";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { UserTypeEnum } from "../enums/UserType";
export type ChildrenType = { export type ChildrenType = {
children: ReactNode; children: ReactNode;
@ -16,7 +15,6 @@ type TMenuItemBase = {
withOutLayout?: boolean; withOutLayout?: boolean;
abilities: ABILITIES_ENUM; abilities: ABILITIES_ENUM;
abilities_value: ABILITIES_VALUES_ENUM; abilities_value: ABILITIES_VALUES_ENUM;
type?:UserTypeEnum
prevPath: number; prevPath: number;
}; };
@ -40,7 +38,6 @@ export type TCrudRoute = {
element: ReactElement | LazyExoticComponent<any>; element: ReactElement | LazyExoticComponent<any>;
abilities: ABILITIES_ENUM; abilities: ABILITIES_ENUM;
abilities_value: ABILITIES_VALUES_ENUM; abilities_value: ABILITIES_VALUES_ENUM;
type?:UserTypeEnum
prevPath: number; prevPath: number;
}; };
@ -51,6 +48,7 @@ export interface CardData {
percentage: number; percentage: number;
Good?: boolean; Good?: boolean;
} }
export const nationalities: { value: string; label: string }[] = [ export const nationalities: { value: string; label: string }[] = [
{ label: "select.nationalities.Afghan", value: "Afghan" }, { label: "select.nationalities.Afghan", value: "Afghan" },
{ label: "select.nationalities.Albanian", value: "Albanian" }, { label: "select.nationalities.Albanian", value: "Albanian" },

View File

@ -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;
}