guardian routes

This commit is contained in:
Mikola 2024-03-15 18:19:48 +03:00
parent f2ad6b43bd
commit 78f2b34810
7 changed files with 72 additions and 86 deletions

View File

@ -9,9 +9,11 @@ import {
} from "react-router-dom"; } from "react-router-dom";
import { getNotification } from "@redux/outstaffingSlice"; import { getNotification } from "@redux/outstaffingSlice";
import { Notification } from "@components/Notification/Notification";
import { MainPage } from "@pages/MainPage/MainPage"; import { MainPage } from "@pages/MainPage/MainPage";
import { Notification } from "@components/Notification/Notification";
import "assets/fonts/stylesheet.css"; import "assets/fonts/stylesheet.css";
import "assets/global.scss"; import "assets/global.scss";

View File

@ -92,7 +92,7 @@ export const ProfileHeader = () => {
}, []); }, []);
const handler = (e) => { const handler = (e) => {
e.preventDefault() e.preventDefault();
localStorage.clear(); localStorage.clear();
dispatch(auth(false)); dispatch(auth(false));
navigate("/auth"); navigate("/auth");

View File

@ -1,23 +1,22 @@
import React from "react"; import React from "react";
import { useMemo } from "react"; import { useMemo } from "react";
import { PartnerPage } from "@pages/roles/PartnerPage";
import { DeveloperPage } from "@pages/roles/DeveloperPage";
import { GuestPage } from "@pages/roles/GuestPage";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { selectAuth } from "@redux/outstaffingSlice"; import { selectAuth } from "@redux/outstaffingSlice";
import { DeveloperPage } from "@pages/roles/DeveloperPage";
import { GuestPage } from "@pages/roles/GuestPage";
import { PartnerPage } from "@pages/roles/PartnerPage";
export const MainPage = () => { export const MainPage = () => {
const roleId = localStorage.getItem("role_status") const roleId = localStorage.getItem("role_status");
const isAuth = useSelector(selectAuth); const isAuth = useSelector(selectAuth);
const user_roles = { const user_roles = {
developer: 4, developer: 4,
partner: 18 partner: 18
} };
const CurrentRolePage = useMemo( const CurrentRolePage = useMemo(() => getRolePage(Number(roleId)), [isAuth]);
() => getRolePage(Number(roleId)),
[isAuth]
);
function getRolePage(roleId) { function getRolePage(roleId) {
switch (roleId) { switch (roleId) {
@ -30,7 +29,5 @@ export const MainPage = () => {
} }
} }
return( return <CurrentRolePage />;
<CurrentRolePage /> };
)
}

View File

@ -65,10 +65,7 @@ export const PartnerCategories = () => {
{ {
label: "Резюме", label: "Резюме",
renderCell: (item) => ( renderCell: (item) => (
<Link <Link className="table__link" to={`/candidate/${item.user_id}`}>
className="table__link"
to={`/candidate/${item.user_id}`}
>
Резюме Резюме
</Link> </Link>
) )

View File

@ -1,20 +1,22 @@
import React from "react"; import React from "react";
import { Navigate, Route, Routes } from "react-router-dom";; import { Navigate, Route, Routes } from "react-router-dom";
import { PartnerSettings } from "@pages/PartnerSettings/PartnerSettings";
import { PartnerTreaties } from "@pages/PartnerTreaties/PartnerTreaties";
import { Payouts } from "@pages/Payouts/Payouts";
import { Profile } from "@pages/Profile/Profile"; import { Profile } from "@pages/Profile/Profile";
import { ProfileCalendar } from "@components/ProfileCalendar/ProfileCalendar"; import { ProjectTracker } from "@pages/ProjectTracker/ProjectTracker";
import { ReportForm } from "@components/ReportForm/ReportForm"; import { PassingTests } from "@pages/Quiz/PassingTests";
import { ViewReport } from "@pages/ViewReport/ViewReport"; import { QuizPage } from "@pages/Quiz/QuizPage";
import { QuizReportPage } from "@pages/Quiz/QuizReportPage";
import Statistics from "@pages/Statistics/Statistics";
import { Summary } from "@pages/Summary/Summary"; import { Summary } from "@pages/Summary/Summary";
import { Tracker } from "@pages/Tracker/Tracker"; import { Tracker } from "@pages/Tracker/Tracker";
import Statistics from "@pages/Statistics/Statistics"; import { ViewReport } from "@pages/ViewReport/ViewReport";
import { Payouts } from "@pages/Payouts/Payouts";
import { PartnerTreaties } from "@pages/PartnerTreaties/PartnerTreaties";
import { QuizPage } from "@pages/Quiz/QuizPage";
import { PassingTests } from "@pages/Quiz/PassingTests";
import { QuizReportPage } from "@pages/Quiz/QuizReportPage";
import { PartnerSettings } from "@pages/PartnerSettings/PartnerSettings";
import { ProjectTracker } from "@pages/ProjectTracker/ProjectTracker";
import { TicketFullScreen } from "@components/Modal/Tracker/TicketFullScreen/TicketFullScreen"; import { TicketFullScreen } from "@components/Modal/Tracker/TicketFullScreen/TicketFullScreen";
import { ProfileCalendar } from "@components/ProfileCalendar/ProfileCalendar";
import { ReportForm } from "@components/ReportForm/ReportForm";
export const DeveloperPage = () => { export const DeveloperPage = () => {
return ( return (
@ -24,21 +26,13 @@ export const DeveloperPage = () => {
path="/tracker/task/:id" path="/tracker/task/:id"
element={<TicketFullScreen />} element={<TicketFullScreen />}
></Route> ></Route>
<Route <Route exact path="/tracker/project/:id" element={<ProjectTracker />} />
exact
path="/tracker/project/:id"
element={<ProjectTracker />}
/>
<Route exact path="profile"> <Route exact path="profile">
<Route index element={<Profile />} /> <Route index element={<Profile />} />
<Route exact path="calendar" element={<ProfileCalendar />} /> <Route exact path="calendar" element={<ProfileCalendar />} />
<Route exact path="calendar/report" element={<ReportForm />} /> <Route exact path="calendar/report" element={<ReportForm />} />
<Route <Route exact path="calendar/view/:date/:id" element={<ViewReport />} />
exact
path="calendar/view/:date/:id"
element={<ViewReport />}
/>
<Route exact path="summary" element={<Summary />} /> <Route exact path="summary" element={<Summary />} />
<Route exact path="tracker" element={<Tracker />} /> <Route exact path="tracker" element={<Tracker />} />
<Route exact path="statistics/:id" element={<Statistics />} /> <Route exact path="statistics/:id" element={<Statistics />} />
@ -53,5 +47,5 @@ export const DeveloperPage = () => {
</Route> </Route>
<Route path="*" element={<Navigate to="/profile" replace />} /> <Route path="*" element={<Navigate to="/profile" replace />} />
</Routes> </Routes>
) );
} };

View File

@ -1,22 +1,24 @@
import React from "react"; import React from "react";
import { Navigate, Route, Routes } from "react-router-dom"; import { Navigate, Route, Routes } from "react-router-dom";
import { TrackerIntro } from "@pages/TrackerIntro/TrackerIntro";
import { TrackerAuth } from "@pages/TrackerAuth/TrackerAuth";
import { Forms } from "@pages/Forms/Forms";
import { TrackerRegistration } from "@pages/TrackerRegistration/TrackerRegistration";
import { CompanyInfo } from "@pages/CompanyInfo/CompanyInfo";
import { RegistrationSetting } from "@pages/RegistrationSetting/RegistrationSetting";
import CatalogSpecialists from "@pages/CatalogSpecialists/CatalogSpecialists";
import { FreeDevelopers } from "@components/FreeDevelopers/FreeDevelopers";
import { AuthForCandidate } from "@pages/AuthForCandidate/AuthForCandidate";
import { RegistrationForCandidate } from "@pages/RegistrationForCandidate/RegistrationForCandidate";
import { FrequentlyAskedQuestions } from "@pages/FrequentlyAskedQuestions/FrequentlyAskedQuestions";
import { Blog } from "@pages/Blog/Blog";
import { Article } from "@pages/Article/Article"; import { Article } from "@pages/Article/Article";
import { FrequentlyAskedQuestion } from "@pages/FrequentlyAskedQuestion/FrequentlyAskedQuestion";
import { SingleReportPage } from "@pages/SingleReportPage/SingleReportPage";
import { ProfileCandidate } from "@pages/ProfileCandidate/ProfileCandidate";
import { Auth } from "@pages/Auth/Auth"; import { Auth } from "@pages/Auth/Auth";
import { AuthForCandidate } from "@pages/AuthForCandidate/AuthForCandidate";
import { Blog } from "@pages/Blog/Blog";
import CatalogSpecialists from "@pages/CatalogSpecialists/CatalogSpecialists";
import { CompanyInfo } from "@pages/CompanyInfo/CompanyInfo";
import { Forms } from "@pages/Forms/Forms";
import { FrequentlyAskedQuestion } from "@pages/FrequentlyAskedQuestion/FrequentlyAskedQuestion";
import { FrequentlyAskedQuestions } from "@pages/FrequentlyAskedQuestions/FrequentlyAskedQuestions";
import { ProfileCandidate } from "@pages/ProfileCandidate/ProfileCandidate";
import { RegistrationForCandidate } from "@pages/RegistrationForCandidate/RegistrationForCandidate";
import { RegistrationSetting } from "@pages/RegistrationSetting/RegistrationSetting";
import { SingleReportPage } from "@pages/SingleReportPage/SingleReportPage";
import { TrackerAuth } from "@pages/TrackerAuth/TrackerAuth";
import { TrackerIntro } from "@pages/TrackerIntro/TrackerIntro";
import { TrackerRegistration } from "@pages/TrackerRegistration/TrackerRegistration";
import { FreeDevelopers } from "@components/FreeDevelopers/FreeDevelopers";
export const GuestPage = () => { export const GuestPage = () => {
return ( return (
@ -68,5 +70,5 @@ export const GuestPage = () => {
<Route index element={<ProfileCandidate />} /> <Route index element={<ProfileCandidate />} />
</Route> </Route>
</Routes> </Routes>
) );
} };

View File

@ -1,23 +1,25 @@
import React from "react"; import React from "react";
import { Navigate, Route, Routes } from "react-router-dom"; import { Navigate, Route, Routes } from "react-router-dom";
import { Candidate } from "@components/Candidate/Candidate";
import { FormPage } from "@pages/FormPage/FormPage"; import { FormPage } from "@pages/FormPage/FormPage";
import { Calendar } from "@components/Calendar/Calendar";
import { ProjectTracker } from "@pages/ProjectTracker/ProjectTracker";
import { TicketFullScreen } from "@components/Modal/Tracker/TicketFullScreen/TicketFullScreen";
import { Profile } from "@pages/Profile/Profile";
import { Home } from "@pages/Home/Home"; import { Home } from "@pages/Home/Home";
import { ViewReport } from "@pages/ViewReport/ViewReport";
import { Tracker } from "@pages/Tracker/Tracker";
import Statistics from "@pages/Statistics/Statistics";
import { PartnerRequests } from "@pages/PartnerRequests/PartnerRequests";
import { PartnerAddRequest } from "@pages/PartnerAddRequest/PartnerAddRequest"; import { PartnerAddRequest } from "@pages/PartnerAddRequest/PartnerAddRequest";
import { PartnerBid } from "@pages/PartnerBid/PartnerBid"; import { PartnerBid } from "@pages/PartnerBid/PartnerBid";
import { PartnerCategories } from "@pages/PartnerСategories/PartnerСategories";
import { PartnerEmployeeReport } from "@pages/PartnerEmployeeReport/PartnerEmployeeReport"; import { PartnerEmployeeReport } from "@pages/PartnerEmployeeReport/PartnerEmployeeReport";
import { PartnerTreaties } from "@pages/PartnerTreaties/PartnerTreaties";
import { PartnerEmployees } from "@pages/PartnerEmployees/PartnerEmployees"; import { PartnerEmployees } from "@pages/PartnerEmployees/PartnerEmployees";
import { PartnerRequests } from "@pages/PartnerRequests/PartnerRequests";
import { PartnerSettings } from "@pages/PartnerSettings/PartnerSettings"; import { PartnerSettings } from "@pages/PartnerSettings/PartnerSettings";
import { PartnerTreaties } from "@pages/PartnerTreaties/PartnerTreaties";
import { PartnerCategories } from "@pages/PartnerСategories/PartnerСategories";
import { Profile } from "@pages/Profile/Profile";
import { ProjectTracker } from "@pages/ProjectTracker/ProjectTracker";
import Statistics from "@pages/Statistics/Statistics";
import { Tracker } from "@pages/Tracker/Tracker";
import { ViewReport } from "@pages/ViewReport/ViewReport";
import { Calendar } from "@components/Calendar/Calendar";
import { Candidate } from "@components/Candidate/Candidate";
import { TicketFullScreen } from "@components/Modal/Tracker/TicketFullScreen/TicketFullScreen";
export const PartnerPage = () => { export const PartnerPage = () => {
return ( return (
@ -31,20 +33,12 @@ export const PartnerPage = () => {
path="/tracker/task/:id" path="/tracker/task/:id"
element={<TicketFullScreen />} element={<TicketFullScreen />}
></Route> ></Route>
<Route <Route exact path="/tracker/project/:id" element={<ProjectTracker />} />
exact
path="/tracker/project/:id"
element={<ProjectTracker />}
/>
<Route exact path="profile"> <Route exact path="profile">
<Route index element={<Profile />} /> <Route index element={<Profile />} />
<Route exact path="catalog" element={<Home />} /> <Route exact path="catalog" element={<Home />} />
<Route <Route exact path="calendar/view/:date/:id" element={<ViewReport />} />
exact
path="calendar/view/:date/:id"
element={<ViewReport />}
/>
<Route exact path="tracker" element={<Tracker />} /> <Route exact path="tracker" element={<Tracker />} />
<Route exact path="statistics/:id" element={<Statistics />} /> <Route exact path="statistics/:id" element={<Statistics />} />
<Route exact path="settings" element={<PartnerSettings />} /> <Route exact path="settings" element={<PartnerSettings />} />
@ -67,5 +61,5 @@ export const PartnerPage = () => {
</Route> </Route>
<Route path="*" element={<Navigate to="/profile" replace />} /> <Route path="*" element={<Navigate to="/profile" replace />} />
</Routes> </Routes>
) );
} };