import { Text } from "@allurereport/web-components"; import { type ComponentChildren, createContext } from "preact"; import { useContext, useState } from "preact/hooks"; import * as styles from "./styles.scss"; type TestResultTabsContextT = { currentTab: string | undefined; setCurrentTab: (id: string) => void; }; const TestResultTabsContext = createContext(null); export const useTestResultTabsContext = () => { const context = useContext(TestResultTabsContext); if (!context) { throw new Error("TestResultTabs components must be used within a TestResultTabs component"); } return context; }; export const TestResultTabsProvider = (props: { initialTab?: string; children: ComponentChildren }) => { const { children, initialTab } = props; const [currentTab, setCurrentTab] = useState(initialTab); return ( {children} ); }; export const TestResultTabs = (props: { children: ComponentChildren; initialTab?: string }) => { return ; }; export const TestResultTabsList = (props: { children: ComponentChildren }) => { return
{props.children}
; }; export const TestResultTab = (props: { id: string; children: ComponentChildren; disabled?: boolean }) => { const { id, children } = props; const { currentTab, setCurrentTab } = useTestResultTabsContext(); const isCurrentTab = currentTab === id; const handleTabClick = () => { if (isCurrentTab) { return; } setCurrentTab(id); }; return ( ); };