-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndpoints.tsx
More file actions
51 lines (46 loc) · 2.73 KB
/
Copy pathEndpoints.tsx
File metadata and controls
51 lines (46 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from "react";
import {Accordion} from "@/components/ui/accordion.tsx";
import {EndpointAccordion} from "@/components/EndpointAccordion.tsx";
import {StatusCodeFilters} from "@/components/StatusCodeFilters.tsx";
import {useAppContext} from "@/AppProvider.tsx";
interface IProps {
addTestTab: (value: string, event: React.MouseEvent<HTMLElement>) => void;
openEndpoint: string;
setOpenEndpoint: (value: string) => void;
}
export const Endpoints: React.FC<IProps> = ({addTestTab, openEndpoint, setOpenEndpoint}) => {
const {transformedReport, filteredEndpoints, statusFilters, setStatusFilters} = useAppContext();
const declaredEndpoints = transformedReport.filter(endpoint => endpoint.declared);
const filteredDeclaredEndpoints = filteredEndpoints.filter(endpoint => endpoint.declared);
const undeclaredEndpoints = transformedReport.filter(endpoint => !endpoint.declared);
const filteredUndeclaredEndpoints = filteredEndpoints.filter(endpoint => !endpoint.declared);
return (
<div className="border-2 border-black p-3 sm:p-6 rounded-none">
<StatusCodeFilters data={transformedReport} filters={statusFilters} onFiltersChange={setStatusFilters}/>
<div className="flex items-center mb-2">
<h3 className="text-sm font-medium text-gray-700 mr-3"># Endpoints:</h3>
<div className="flex flex-wrap gap-2 font-bold font-mono">
<p className="text-black-400">{filteredDeclaredEndpoints.length}</p> / <p className="text-red-400">{declaredEndpoints.length}</p>
</div>
</div>
{undeclaredEndpoints.length > 0 &&
<div className="flex items-center mb-2">
<h3 className="text-sm font-medium text-gray-700 mr-3"># Faulty operations not in schema:</h3>
<div className="flex flex-wrap gap-2 font-bold font-mono">
<p className="text-black-400">{filteredUndeclaredEndpoints.length}</p> / <p className="text-amber-600">{undeclaredEndpoints.length}</p>
</div>
</div>
}
<Accordion type="single" collapsible value={openEndpoint} onValueChange={setOpenEndpoint} className="w-full">
{
filteredEndpoints.map((item, index) => (
<EndpointAccordion data-testid="endpoint" key={index} value={item.endpoint}
endpoint={item.endpoint} declared={item.declared}
statusCodes={item.httpStatusCodes} faults={item.faults}
addTestTab={addTestTab}/>
))
}
</Accordion>
</div>
)
}