Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import {
Box,
Chip,
Form,
Stack,
Tooltip,
Typography,
alpha,
useTheme,
} from "@wso2/oxygen-ui";
import { Clock } from "@wso2/oxygen-ui-icons-react";
import type { JSX } from "react";
import type { CaseListItem } from "@models/responses";
import OutstandingCasesSkeleton from "./OutstandingCasesSkeleton";
import { getPriorityColor, getStatusColor } from "@utils/casesTable";
import { formatRelativeTime, resolveColorFromTheme } from "@utils/support";

export interface OutstandingCasesListProps {
cases: CaseListItem[];
isLoading?: boolean;
}

/**
* Renders a list of outstanding case rows for the support overview card.
*
* @param {OutstandingCasesListProps} props - Cases array and loading state.
* @returns {JSX.Element} The list of case rows.
*/
export default function OutstandingCasesList({
cases,
isLoading,
}: OutstandingCasesListProps): JSX.Element {
const theme = useTheme();

if (isLoading) {
return <OutstandingCasesSkeleton />;
}

if (cases.length === 0) {
return (
<Typography variant="body2" color="text.secondary">
No outstanding cases.
</Typography>
);
}

return (
<Box sx={{ display: "flex", flexDirection: "column", gap: 1.5 }}>
{cases.map((c) => {
const colorPath = getStatusColor(c.status?.label);
const resolvedColor = resolveColorFromTheme(colorPath, theme);

return (
<Form.CardButton
key={c.id}
sx={{
p: 2,
display: "flex",
flexDirection: "column",
alignItems: "stretch",
gap: 1,
}}
Comment thread
dileepapeiris marked this conversation as resolved.
Resolved
>
<Form.CardHeader
sx={{ p: 0 }}
title={
<Stack direction="row" spacing={1} alignItems="center">
<Typography
variant="body2"
fontWeight={500}
color="text.primary"
>
{c.number}
</Typography>
<Box
sx={{
width: 8,
height: 8,
borderRadius: "50%",
flexShrink: 0,
bgcolor: `${getPriorityColor(c.severity?.label)}.main`,
}}
/>
Comment thread
dileepapeiris marked this conversation as resolved.
Resolved
<Typography variant="caption" color="text.secondary">
{c.severity?.label ?? "—"}
</Typography>
</Stack>
}
/>

<Form.CardContent sx={{ p: 0 }}>
<Typography
variant="body2"
color="text.primary"
sx={{
overflow: "hidden",
}}
>
{c.title}
</Typography>
</Form.CardContent>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

<Form.CardActions sx={{ p: 0, justifyContent: "space-between" }}>
<Chip
size="small"
variant="outlined"
label={c.status?.label ?? "—"}
icon={<Clock size={12} />}
sx={{
px: 0.5,
bgcolor: alpha(resolvedColor, 0.1),
color: resolvedColor,
borderColor: "transparent",
"& .MuiChip-icon": {
color: "inherit",
},
}}
/>
<Box sx={{ display: "flex", alignItems: "center", gap: 1.5 }}>
{c.assignedEngineer && (
<Tooltip title={`Assigned to ${c.assignedEngineer}`}>
<Typography variant="caption" color="text.secondary">
Assigned to {c.assignedEngineer}
</Typography>
</Tooltip>
)}
<Typography variant="caption" color="text.secondary">
{formatRelativeTime(c.createdOn)}
</Typography>
</Box>
</Form.CardActions>
</Form.CardButton>
);
})}
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import { SUPPORT_OVERVIEW_CASES_LIMIT } from "@/constants/supportConstants";
import { Box, Form, Skeleton } from "@wso2/oxygen-ui";
import { type JSX } from "react";

/**
* Renders a list of loading skeletons for the outstanding cases list.
*
* @returns {JSX.Element} The skeleton list.
*/
export default function OutstandingCasesSkeleton(): JSX.Element {
return (
<Box sx={{ display: "flex", flexDirection: "column", gap: 1.5 }}>
{Array.from({ length: SUPPORT_OVERVIEW_CASES_LIMIT }).map((_, index) => (
<Form.CardButton
key={`skeleton-${index}`}
sx={{
p: 2,
display: "flex",
flexDirection: "column",
alignItems: "stretch",
gap: 1.5,
}}
>
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
<Skeleton variant="text" width={60} height={20} />
<Skeleton variant="circular" width={8} height={8} />
<Skeleton variant="text" width={40} height={16} />
</Box>
<Skeleton variant="text" width="90%" height={24} />
<Box
sx={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<Skeleton variant="rounded" width={80} height={20} />
<Skeleton variant="text" width={100} height={16} />
</Box>
</Form.CardButton>
))}
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import {
Box,
Button,
Paper,
Typography,
alpha,
colors,
useTheme,
} from "@wso2/oxygen-ui";
import { ArrowRight } from "@wso2/oxygen-ui-icons-react";
import type { ComponentType } from "react";
import type { JSX } from "react";

export interface SupportOverviewCardProps {
title: string;
subtitle: string;
icon: ComponentType<{ size?: number; color?: string }>;
iconVariant?: "orange" | "blue";
children: React.ReactNode;
footerButtonLabel: string;
onFooterClick: () => void;
}

/**
* Generic card for support overview sections (Outstanding Cases, Chat History).
*
* @param {SupportOverviewCardProps} props - Title, subtitle, icon, children, footer CTA.
* @returns {JSX.Element} The rendered card.
*/
export default function SupportOverviewCard({
title,
subtitle,
icon: Icon,
iconVariant = "orange",
children,
footerButtonLabel,
onFooterClick,
}: SupportOverviewCardProps): JSX.Element {
const theme = useTheme();
const paletteKey = iconVariant === "blue" ? "info" : "warning";
const iconColor =
iconVariant === "blue" ? colors.blue[600] : colors.orange[600];

return (
<Paper
sx={{
p: 2.5,
display: "flex",
flexDirection: "column",
gap: 2,
}}
>
<Box sx={{ display: "flex", alignItems: "center", gap: 2, mb: 1 }}>
<Paper
sx={{
width: 40,
height: 40,
bgcolor: alpha(theme.palette[paletteKey].light, 0.1),
color: theme.palette[paletteKey].light,
display: "flex",
alignItems: "center",
justifyContent: "center",
flexShrink: 0,
}}
>
<Icon size={20} color={iconColor} />
</Paper>
<Box>
<Typography variant="h6" color="text.primary">
{title}
</Typography>
<Typography variant="body2" color="text.secondary">
{subtitle}
</Typography>
</Box>
</Box>

<Box sx={{ display: "flex", flexDirection: "column", gap: 1.5 }}>
{children}
</Box>

<Box
sx={{
borderTop: 1,
borderColor: "divider",
pt: 2,
mt: 1,
}}
/>
<Button
fullWidth
variant="text"
color="warning"
onClick={onFooterClick}
endIcon={<ArrowRight size={16} />}
sx={{
justifyContent: "space-between",
textTransform: "none",
fontWeight: 500,
}}
>
{footerButtonLabel}
</Button>
</Paper>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import OutstandingCasesList from "@components/support/support-overview-cards/OutstandingCasesList";
import type { CaseListItem } from "@models/responses";

const mockCases: CaseListItem[] = [
{
id: "1",
internalId: "int-1",
number: "CASE-2845",
createdOn: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(),
title: "API Gateway timeout issues",
description: "",
assignedEngineer: "Sarah Chen",
project: { id: "p1", label: "Project 1" },
type: null,
deployment: null,
severity: { id: "1", label: "High" },
status: { id: "1", label: "Work In Progress" },
},
];

describe("OutstandingCasesList", () => {
it("should render empty state when no cases", () => {
render(<OutstandingCasesList cases={[]} />);
expect(screen.getByText("No outstanding cases.")).toBeInTheDocument();
});

it("should render case number, title, severity and status", () => {
render(<OutstandingCasesList cases={mockCases} />);
expect(screen.getByText("CASE-2845")).toBeInTheDocument();
expect(screen.getByText("API Gateway timeout issues")).toBeInTheDocument();
expect(screen.getByText("High")).toBeInTheDocument();
expect(screen.getByText("Work In Progress")).toBeInTheDocument();
expect(screen.getByText(/Assigned to Sarah Chen/)).toBeInTheDocument();
Comment thread
dileepapeiris marked this conversation as resolved.
Resolved
expect(screen.getByText("2 hours ago")).toBeInTheDocument();
});
});
Loading