diff --git a/flourish-client/src/App.tsx b/flourish-client/src/App.tsx
index 808f72f..fb8aac6 100644
--- a/flourish-client/src/App.tsx
+++ b/flourish-client/src/App.tsx
@@ -1,18 +1,23 @@
import { Box } from "@chakra-ui/react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
-// import { customLayoutPaths } from "./assets/data/app";
+import { setupInterceptors } from "./api/config/apiConfig";
+import { nav } from "./assets/data/routes";
+import { useAppSelector } from "./hooks/useStore";
import Auth from "./pages/auth";
import SignIn from "./pages/auth/signin";
import SignUp from "./pages/auth/signup";
+import Dashboard from "./pages/dashboard";
+import Questionnaire from "./pages/dashboard/questionnaire";
import Homepage from "./pages/homepage";
-import { useAppSelector } from "./hooks/useStore";
+import QuestionnaireDetails from "./pages/dashboard/questionnaire/QuestionnaireDetails";
+import QuestionnaireList from "./pages/dashboard/questionnaire/QuestionnaireList";
const App = () => {
- // const currentRoute = window.location.pathname;
- // const isLayout = !customLayoutPaths.includes(currentRoute);
-
const isSignedIn = useAppSelector((state) => state.flags.isSignedIn);
+ const token = useAppSelector((state) => state?.user?.token);
+
+ if (token) setupInterceptors(token);
return (
{
} />
{!isSignedIn && (
- }>
+ }>
} />
- } />
- } />
+ } />
+ } />
+
+ )}
+
+ {isSignedIn && (
+ }>
+ }>
+ } />
+ } />
+
+ Members} />
+ Members} />
+ sessionRequest}
+ />
+ Overview} />
)}
+ 404} />
diff --git a/flourish-client/src/api/apiAuth.ts b/flourish-client/src/api/apiAuth.ts
new file mode 100644
index 0000000..10331ee
--- /dev/null
+++ b/flourish-client/src/api/apiAuth.ts
@@ -0,0 +1,18 @@
+import { api as apiData } from "../assets/data/server";
+import { SignIn, SignUp } from "../types/Form";
+import { User } from "../types/User";
+import { api } from "./config/apiConfig";
+
+export const apiSignIn = async (data: SignIn): Promise => {
+ const response = await api.post(apiData.signIn, {
+ ...data,
+ });
+
+ return response.data;
+};
+
+export const apiSignUp = async (data: SignUp): Promise => {
+ await api.post(apiData.signUp[data.type], {
+ ...(data as SignIn),
+ });
+};
diff --git a/flourish-client/src/api/apiQuestionnaire.ts b/flourish-client/src/api/apiQuestionnaire.ts
new file mode 100644
index 0000000..a94a1b0
--- /dev/null
+++ b/flourish-client/src/api/apiQuestionnaire.ts
@@ -0,0 +1,9 @@
+import { api as apiData } from "../assets/data/server";
+import { Questionnaire } from "../types/Questionnaire";
+import { api } from "./config/apiConfig";
+
+export const getQuestionnaire = async (): Promise => {
+ const response = await api.get(apiData.questionnaire.adminCounselor, {});
+
+ return response.data;
+};
diff --git a/flourish-client/src/api/apiSignIn.ts b/flourish-client/src/api/apiSignIn.ts
deleted file mode 100644
index c9d6675..0000000
--- a/flourish-client/src/api/apiSignIn.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { api as apiData } from "../assets/data/server";
-import { SignIn } from "../types/Form";
-import { api } from "./config/apiConfig";
-
-export const apiSignIn = async (data: SignIn) => {
- const response = await api.post(apiData.signIn, {
- ...data,
- });
-
- return response.data.token;
-};
diff --git a/flourish-client/src/api/apiSignUp.ts b/flourish-client/src/api/apiSignUp.ts
deleted file mode 100644
index bc5642e..0000000
--- a/flourish-client/src/api/apiSignUp.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { api as apiData } from "../assets/data/server";
-import { SignIn, SignUp } from "../types/Form";
-import { api } from "./config/apiConfig";
-
-export const apiSignUp = async (data: SignUp) => {
- const response = await api.post(apiData.signUp[data.type], {
- ...(data as SignIn),
- });
-
- return response.data;
-};
diff --git a/flourish-client/src/api/config/apiConfig.ts b/flourish-client/src/api/config/apiConfig.ts
index cdb6adb..1346b85 100644
--- a/flourish-client/src/api/config/apiConfig.ts
+++ b/flourish-client/src/api/config/apiConfig.ts
@@ -1,9 +1,13 @@
import axios, { AxiosError, AxiosInstance } from "axios";
+
import { api as apiData } from "../../assets/data/server";
export const api: AxiosInstance = axios.create({
baseURL: apiData.base,
timeout: 30000, // 30 seconds
+ headers: {
+ "Content-Type": "application/json",
+ },
});
const errorHandler = (error: AxiosError) => {
@@ -22,3 +26,10 @@ const errorHandler = (error: AxiosError) => {
api.interceptors.response.use(undefined, (error) => {
return errorHandler(error);
});
+
+export const setupInterceptors = (token: string) => {
+ api.interceptors.request.use((config) => {
+ config.headers.Authorization = `token ${token}`;
+ return config;
+ });
+};
diff --git a/flourish-client/src/assets/data/auth.ts b/flourish-client/src/assets/data/auth.ts
index 1da2680..b62f7f9 100644
--- a/flourish-client/src/assets/data/auth.ts
+++ b/flourish-client/src/assets/data/auth.ts
@@ -1,4 +1,4 @@
-import { nav } from "./nav";
+import { routes } from "./routes";
export const headerContent = {
signIn: {
@@ -16,12 +16,12 @@ export const headerContent = {
export const footerContent = {
signIn: {
title: "Sign Up",
- href: nav.signUp,
+ href: routes.signUp,
description: "Don't have an account?",
},
signUp: {
title: "Sign In",
- href: nav.signIn,
+ href: routes.signIn,
description: "Already have an account?",
},
};
diff --git a/flourish-client/src/assets/data/dashboard/dashboard.tsx b/flourish-client/src/assets/data/dashboard/dashboard.tsx
new file mode 100644
index 0000000..fdcfb52
--- /dev/null
+++ b/flourish-client/src/assets/data/dashboard/dashboard.tsx
@@ -0,0 +1,28 @@
+import { RxDashboard, RxQuestionMarkCircled } from "react-icons/rx";
+
+import { userTypes } from "../../../types/User";
+import { nav, routes } from "../routes";
+
+export const menu = {
+ [userTypes.ADMIN]: [
+ {
+ title: "Dashboard",
+ href: routes.dashboard,
+ icon: ,
+ exclude: [nav.questionnaire],
+ },
+ {
+ title: "Questionnaires",
+ href: routes.questionnaire,
+ icon: ,
+ },
+ ],
+};
+
+export const navBar = {
+ [userTypes.ADMIN]: [
+ { title: "Members", href: routes.members },
+ { title: "Session Request", href: routes.sessionRequest },
+ { title: "Overview", href: routes.overview },
+ ],
+};
diff --git a/flourish-client/src/assets/data/dashboard/questionnaire/questionnaire.tsx b/flourish-client/src/assets/data/dashboard/questionnaire/questionnaire.tsx
new file mode 100644
index 0000000..62fce5c
--- /dev/null
+++ b/flourish-client/src/assets/data/dashboard/questionnaire/questionnaire.tsx
@@ -0,0 +1,38 @@
+import { IoAddCircleOutline, IoRemoveCircleOutline } from "react-icons/io5";
+
+export const questionnaireData = {
+ name: { title: "Questionnaire Group", placeholder: "Enter a name" },
+ questionnaires: "All Questionnaires",
+ questionnaireField: {
+ title: "Question",
+ placeholder: "Enter a question",
+ },
+ options: "Options and Points",
+ optionField: {
+ option: "Option",
+ points: "Points",
+ },
+
+ button: {
+ questionnaire: {
+ add: {
+ title: "Add a Questionnaire",
+ icon: ,
+ },
+ remove: {
+ title: "",
+ icon: ,
+ },
+ },
+ option: {
+ title: "Add a option",
+ icon: ,
+ },
+ save: {
+ title: "Save",
+ },
+ reset: {
+ title: "Reset",
+ },
+ },
+};
diff --git a/flourish-client/src/assets/data/nav.ts b/flourish-client/src/assets/data/nav.ts
deleted file mode 100644
index 3036b49..0000000
--- a/flourish-client/src/assets/data/nav.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-export const nav = {
- home: "/",
- auth: "/auth",
- signIn: "/auth/signin",
- signUp: "/auth/signup",
- dashboard: "/dashboard",
-};
-
-export const header = [
- { title: "Resources", href: "/resources" },
- {
- title: "Support",
- href: "/support",
- },
-];
-
-export const headerNav = {
- signIn: { title: "Sign In", href: nav.signIn },
- dashboard: {
- title: "Dashboard",
- href: "/dashboard",
- },
-};
diff --git a/flourish-client/src/assets/data/routes.ts b/flourish-client/src/assets/data/routes.ts
new file mode 100644
index 0000000..271899e
--- /dev/null
+++ b/flourish-client/src/assets/data/routes.ts
@@ -0,0 +1,48 @@
+export const nav = {
+ home: "",
+ auth: "auth",
+ dashboard: "dashboard",
+ signIn: "signin",
+ signUp: "signup",
+ questionnaire: "questionnaires",
+ resource: "resource",
+ support: "support",
+ members: "members",
+ sessionRequest: "session-request",
+ overview: "overview",
+};
+
+export const routes = {
+ home: `/${nav.home}`,
+ auth: `/${nav.auth}`,
+ signIn: `/${nav.auth}/${nav.signIn}`,
+ signUp: `/${nav.auth}/${nav.signUp}`,
+ dashboard: `/${nav.dashboard}`,
+ questionnaire: `/${nav.dashboard}/${nav.questionnaire}`,
+ resource: `/${nav.resource}`,
+ support: `/${nav.support}`,
+ members: `/${nav.dashboard}/${nav.members}`,
+ sessionRequest: `/${nav.dashboard}/${nav.sessionRequest}`,
+ overview: `/${nav.dashboard}/${nav.overview}`,
+};
+
+export const header = [
+ { title: "Resources", href: routes.resource },
+ {
+ title: "Support",
+ href: routes.support,
+ },
+];
+
+export const headerNav = {
+ signIn: { title: "Sign In", href: routes.signIn },
+ dashboard: {
+ title: "Dashboard",
+ href: routes.dashboard,
+ },
+};
+
+export const signOut = {
+ title: "Sign Out",
+ href: routes.home,
+};
diff --git a/flourish-client/src/assets/data/server.ts b/flourish-client/src/assets/data/server.ts
index 7d99db7..987168e 100644
--- a/flourish-client/src/assets/data/server.ts
+++ b/flourish-client/src/assets/data/server.ts
@@ -1,11 +1,14 @@
import { userTypes } from "../../types/User";
export const api = {
- base: "https://flourish.onrender.com",
+ base: "https://flourish.onrender.com/",
signUp: {
- [userTypes.CLIENT]: "/client/signup",
- [userTypes.ADMIN]: "/adminCounselor/signup",
- [userTypes.COUNSELOR]: "counselor/signup",
+ [userTypes.CLIENT]: "client/signup/",
+ [userTypes.ADMIN]: "adminCounselor/signup/",
+ [userTypes.COUNSELOR]: "counselor/signup/",
+ },
+ signIn: "login/",
+ questionnaire: {
+ [userTypes.ADMIN]: "adminCounselor/questionnaire/",
},
- signIn: "/login",
};
diff --git a/flourish-client/src/assets/img/logo.png b/flourish-client/src/assets/img/logo.png
index bb1d53b..1d67172 100644
Binary files a/flourish-client/src/assets/img/logo.png and b/flourish-client/src/assets/img/logo.png differ
diff --git a/flourish-client/src/assets/svg/Auth.tsx b/flourish-client/src/assets/svg/Auth.tsx
index 1c8147d..0522efc 100644
--- a/flourish-client/src/assets/svg/Auth.tsx
+++ b/flourish-client/src/assets/svg/Auth.tsx
@@ -1,10 +1,10 @@
import { SVGProps } from "react";
import { useLocation } from "react-router-dom";
-import { nav } from "../data/nav";
+import { routes } from "../data/routes";
const SignIn = (props: SVGProps) => {
const { pathname } = useLocation();
- const isSignUp = pathname !== nav.signUp;
+ const isSignUp = pathname !== routes.signUp;
return (