diff --git a/ui/src/components/custom/search/matrixExplorer.tsx b/ui/src/components/custom/search/matrixExplorer.tsx index 76c4e62..6af94f9 100644 --- a/ui/src/components/custom/search/matrixExplorer.tsx +++ b/ui/src/components/custom/search/matrixExplorer.tsx @@ -387,7 +387,6 @@ const MatrixExplorer: React.FC = () => { handleMatrixSelect(matrix.matrixId)} titleColor="#ffffff" /> diff --git a/ui/src/components/custom/search/miniMatrixCard.tsx b/ui/src/components/custom/search/miniMatrixCard.tsx index b9e68eb..ebefa13 100644 --- a/ui/src/components/custom/search/miniMatrixCard.tsx +++ b/ui/src/components/custom/search/miniMatrixCard.tsx @@ -3,14 +3,12 @@ import { Typography, Paper } from "@mui/material"; interface MiniMatrixCardProps { title: string; - description: string; onSelectMatrix: () => void; titleColor?: string; } const MiniMatrixCard: React.FC = ({ title, - description, onSelectMatrix, titleColor = "#ffffff", }) => { @@ -31,10 +29,10 @@ const MiniMatrixCard: React.FC = ({ transform: "translateY(-2px)", boxShadow: "0 4px 8px rgba(0, 0, 0, 0.2)", }, - minHeight: "80px", + minHeight: "60px", display: 'flex', flexDirection: 'column', - gap: 1, + justifyContent: 'center', boxSizing: 'border-box', }} onClick={onSelectMatrix} @@ -52,21 +50,6 @@ const MiniMatrixCard: React.FC = ({ > {title || ""} - - {description || ""} - ); }; diff --git a/ui/src/pages/CreateMatrix.tsx b/ui/src/pages/CreateMatrix.tsx index 8f19c33..1b22a43 100644 --- a/ui/src/pages/CreateMatrix.tsx +++ b/ui/src/pages/CreateMatrix.tsx @@ -23,7 +23,7 @@ import { Modal, IconButton, } from "@mui/material"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import DeleteIcon from "@mui/icons-material/Delete"; import { whoamiUpsert, createMatrix } from "./apiService"; import SendIcon from "@mui/icons-material/Send"; @@ -68,6 +68,27 @@ export const CreateMatrix: React.FC = () => { const [multipliers, setMultipliers] = useState(initialMultipliers); + // Fetch the current user's email when the component loads + useEffect(() => { + const fetchUserEmail = async () => { + try { + const whoamiUpsertResponse = await whoamiUpsert(); + const rawData = whoamiUpsertResponse.data; + const firstObjectEnd = rawData.indexOf("}") + 1; + const firstObjectStr = rawData.substring(0, firstObjectEnd); + const parsedFirstObject = JSON.parse(firstObjectStr); + const { email } = parsedFirstObject; + + // Initialize the participants list with the current user as a host + setParticipantsData([{ email: email, role: "Host" }]); + } catch (error) { + console.error("Error fetching user email:", error); + } + }; + + fetchUserEmail(); + }, []); + const carverOrder = [ { key: "Criticality", header: "C" }, { key: "Accessibility", header: "A" }, @@ -296,7 +317,7 @@ export const CreateMatrix: React.FC = () => { const firstObjectEnd = rawData.indexOf("}") + 1; const firstObjectStr = rawData.substring(0, firstObjectEnd); const parsedFirstObject = JSON.parse(firstObjectStr); - const { userId, email } = parsedFirstObject; + const { userId } = parsedFirstObject; const items = targets.map((target, index) => ({ itemName: target, @@ -308,15 +329,15 @@ export const CreateMatrix: React.FC = () => { recognizability: {}, images: targetImages[index] || [] })); - const hosts = [ - email, - ...participantsData - .map((p) => - p.role === "Host" || p.role === "Host and Participant" ? p.email : null - ) - .filter((email): email is string => email !== null), - ]; + // Get hosts from the participants list + const hosts = participantsData + .map((p) => + p.role === "Host" || p.role === "Host and Participant" ? p.email : null + ) + .filter((email): email is string => email !== null); + + // Get participants from the participants list const participantEmails = participantsData .map((p) => p.role === "Participant" || p.role === "Host and Participant" ? p.email : null diff --git a/ui/src/pages/Profile.tsx b/ui/src/pages/Profile.tsx index e157fe4..383a1d5 100644 --- a/ui/src/pages/Profile.tsx +++ b/ui/src/pages/Profile.tsx @@ -6,8 +6,10 @@ import { Grid, Divider, Skeleton, + Button, } from '@mui/material'; import axios from 'axios'; +import SettingsIcon from '@mui/icons-material/Settings'; interface UserData { userId: number; @@ -79,6 +81,10 @@ const Profile: React.FC = () => { ); + const handleAdvancedSettings = () => { + window.open('https://keycloak.zeus.socom.dev/realms/zeus-apps/account/', '_blank'); + }; + return ( { label="Member Since" value={new Date(userData.createdAt).toLocaleDateString()} /> + + + + ) )} diff --git a/ui/src/pages/ViewMatrix.tsx b/ui/src/pages/ViewMatrix.tsx index 2e3aaf8..b27c0ac 100644 --- a/ui/src/pages/ViewMatrix.tsx +++ b/ui/src/pages/ViewMatrix.tsx @@ -186,7 +186,7 @@ const ViewMatrix: React.FC = () => { const transformItemsForPdf = (items: CarverMatrix["items"]) => { return items.map((item) => { - const getAverageScore = (scores: any) => { + const getAverageScore = (scores: number | Record) => { if (typeof scores === "number") return scores; const values = Object.values(scores || {}).filter( (score) => score !== undefined && score !== null @@ -238,10 +238,11 @@ const ViewMatrix: React.FC = () => { {/* Background Pattern */} @@ -275,6 +276,8 @@ const ViewMatrix: React.FC = () => { gap: 2, position: "relative", zIndex: 1, + overflowY: "auto", + overflowX: "hidden", }} > @@ -494,126 +497,109 @@ const ViewMatrix: React.FC = () => { - {filteredMatrices.length > 0 ? ( - filteredMatrices.map((matrix) => ( - - + {filteredMatrices.length > 0 ? ( + filteredMatrices.map((matrix) => ( + - - {matrix.name} - - - {new Date(matrix.createdAt).toLocaleDateString()} - - - - - {matrix.description || "No description"} - - - - - {matrix.items.length}{" "} - {matrix.items.length === 1 ? "Target" : "Targets"} - - {matrix.randomAssignment && ( - Random + {matrix.name} - )} - {matrix.roleBased && ( - Role Based + {new Date(matrix.createdAt).toLocaleDateString()} - )} - {matrix.fivePointScoring ? ( + + + + {matrix.description || "No description"} + + + { borderRadius: "12px", }} > - 5-Point Scale + {matrix.items.length}{" "} + {matrix.items.length === 1 ? "Target" : "Targets"} - ) : ( + {matrix.randomAssignment && ( + + Random + + )} + {matrix.roleBased && ( + + Role Based + + )} + {matrix.fivePointScoring ? ( + + 5-Point Scale + + ) : ( + + 10-Point Scale + + )} + + + - 10-Point Scale - - )} - - - - - {matrix.roleBased - ? matrix.hosts.includes(userEmail || "") && - matrix.participants.includes(userEmail || "") - ? "Host & Participant" - : matrix.hosts.includes(userEmail || "") - ? "Host" - : "Participant" - : null} - - - {matrix.hosts.includes(userEmail || "") && ( - <> - - - { - e.stopPropagation(); - handleOpenDeleteDialog(matrix); - }} - sx={{ - color: "#f44336", - "&:hover": { - backgroundColor: "rgba(244, 67, 54, 0.1)", - }, + ? "Host" + : "Participant" + : null} + + + {matrix.hosts.includes(userEmail || "") && ( + <> + - - - - - )} - - { - e.stopPropagation(); - const url = `/EditMatrix?matrixId=${matrix.matrixId}`; - navigate(url); - }} - sx={{ - color: "#4D9FFF", - "&:hover": { - backgroundColor: "rgba(77, 159, 255, 0.1)", - }, - }} - > - - - + items={transformItemsForPdf(matrix.items)} + /> + + { + e.stopPropagation(); + handleOpenDeleteDialog(matrix); + }} + sx={{ + color: "#f44336", + "&:hover": { + backgroundColor: "rgba(244, 67, 54, 0.1)", + }, + }} + > + + + + + )} + + { + e.stopPropagation(); + const url = `/EditMatrix?matrixId=${matrix.matrixId}`; + navigate(url); + }} + sx={{ + color: "#4D9FFF", + "&:hover": { + backgroundColor: "rgba(77, 159, 255, 0.1)", + }, + }} + > + + + + - - - )) - ) : ( - - No matrices found. - - )} + + )) + ) : ( + + No matrices found. + + )} +