UNPKG

@nitin15j/plugin-dora-frontend

Version:
85 lines (82 loc) 3.25 kB
import { jsxs, jsx } from 'react/jsx-runtime'; import { makeStyles } from '@material-ui/core/styles'; import { Box, Grid, Paper, Typography } from '@material-ui/core'; import { useState } from 'react'; import { Alert } from '@material-ui/lab'; import { TeamPerformance } from './components/TeamPerformance.esm.js'; import { TeamSelector } from './components/TeamSelector.esm.js'; import { TimeRangeSelector } from '../shared/components/TimeRangeSelector.esm.js'; import { useAllTeamsMetrics } from './hooks/useAllTeamsMetrics.esm.js'; import { useUserTeams } from '../common/hooks/useUserTeams.esm.js'; const useStyles = makeStyles({ container: { padding: "1rem" }, paper: { padding: "1rem", marginBottom: "1rem" }, title: { marginBottom: "1rem", fontSize: "1.25rem", fontWeight: 500 }, content: { position: "relative" }, error: { marginBottom: "1rem" } }); const LeadDashboard = () => { const classes = useStyles(); const [selectedTeam, setSelectedTeam] = useState(null); const [selectedTimeRange, setSelectedTimeRange] = useState("last7days"); const { teams: userTeams, loading: userTeamsLoading, error: userTeamsError } = useUserTeams(); const { teams: allTeamsData, loading: allTeamsLoading, error: allTeamsError } = useAllTeamsMetrics( userTeams || [], selectedTimeRange ); const isLoading = selectedTeam ? allTeamsLoading : userTeamsLoading || allTeamsLoading; let errorMessage = null; if (userTeamsError) { errorMessage = `Failed to load user teams: ${userTeamsError}`; } else if (allTeamsError) { errorMessage = `Failed to load team metrics: ${allTeamsError}`; } else if (userTeams && userTeams.length === 0) { errorMessage = "No teams found for your user account. Please check your entity relations."; } return /* @__PURE__ */ jsxs("div", { className: classes.container, children: [ /* @__PURE__ */ jsx(Box, { mb: 3, children: /* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [ /* @__PURE__ */ jsx(Box, { flex: 1 }), /* @__PURE__ */ jsx( TimeRangeSelector, { selectedRange: selectedTimeRange, onRangeChange: setSelectedTimeRange } ), /* @__PURE__ */ jsx(Box, { flex: 1, display: "flex", justifyContent: "flex-end", children: /* @__PURE__ */ jsx( TeamSelector, { selectedTeam, onTeamChange: setSelectedTeam } ) }) ] }) }), errorMessage && /* @__PURE__ */ jsx(Alert, { severity: "error", className: classes.error, children: errorMessage }), /* @__PURE__ */ jsx("div", { className: classes.content, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 3, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Paper, { className: classes.paper, children: [ /* @__PURE__ */ jsx(Typography, { className: classes.title, children: "Team Performance" }), /* @__PURE__ */ jsx( TeamPerformance, { selectedTeam, allTeamsData, isLoading } ) ] }) }) }) }) ] }); }; export { LeadDashboard }; //# sourceMappingURL=LeadDashboard.esm.js.map