From 69c924caec703ac46d176dfa9ec410892bc7e18e Mon Sep 17 00:00:00 2001
From: Thomas
Date: Fri, 12 Apr 2024 12:26:22 -0400
Subject: [PATCH] Added authenticated route and initial function to retrieve
list of RSC User assessments.
---
backend/Dockerfile | 2 +-
backend/src/api/app.ts | 4 +++
.../components/ReadySetCyber/RSCDashboard.tsx | 29 ++++++++++++++-----
3 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/backend/Dockerfile b/backend/Dockerfile
index a45d7240..b1be91bb 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -1,7 +1,7 @@
FROM node:18-alpine3.17
USER root
-RUN apk update && apk upgrade
+RUN apk update && apk upgrade && apk add --no-cache g++ make py3-pip
WORKDIR /app
COPY ./package* ./
diff --git a/backend/src/api/app.ts b/backend/src/api/app.ts
index 0b8af9dc..b18816fe 100644
--- a/backend/src/api/app.ts
+++ b/backend/src/api/app.ts
@@ -21,6 +21,7 @@ import * as savedSearches from './saved-searches';
import rateLimit from 'express-rate-limit';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { UserType } from '../models';
+import * as assessments from './assessments';
if (
(process.env.IS_OFFLINE || process.env.IS_LOCAL) &&
@@ -450,6 +451,9 @@ authenticatedRoute.put(
handlerToExpress(users.registrationDenial)
);
+//Authenticated ReadySetCyber Routes
+authenticatedRoute.get('/assessments', handlerToExpress(assessments.list));
+
//************* */
// V2 Routes //
//************* */
diff --git a/frontend/src/components/ReadySetCyber/RSCDashboard.tsx b/frontend/src/components/ReadySetCyber/RSCDashboard.tsx
index 567e2bd6..ea44d796 100644
--- a/frontend/src/components/ReadySetCyber/RSCDashboard.tsx
+++ b/frontend/src/components/ReadySetCyber/RSCDashboard.tsx
@@ -1,16 +1,31 @@
-import React from 'react';
+import React, { useEffect, useCallback, useState } from 'react';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Divider from '@mui/material/Divider';
import { RSCSideNav } from './RSCSideNav';
-import { RSCResult } from './RSCResult';
+// import { RSCResult } from './RSCResult';
+import { useAuthContext } from 'context';
-import { dummyResults } from './dummyData';
+export const RSCDashboard: React.FC = () => {
+ const { user, apiGet } = useAuthContext();
-const results = dummyResults;
+ const [results, setResults] = React.useState([]);
+
+ const fetchResults = useCallback(async () => {
+ try {
+ const data = await apiGet('/assessments');
+ console.log(data);
+ setResults(data);
+ } catch (e) {
+ console.error(e);
+ }
+ }, [apiGet]);
+
+ useEffect(() => {
+ fetchResults();
+ }, []);
-export const RSCDashboard: React.FC = () => {
return (
@@ -34,7 +49,7 @@ export const RSCDashboard: React.FC = () => {
platform, for free vulnerability scanning services to kickstart
or enhance your cybersecurity measures.
- {results.map((result) => (
+ {/* {results.map((result) => (
{
/>
- ))}
+ ))} */}