This commit is contained in:
Eden Kirin
2024-01-24 12:12:49 +01:00
parent 64688a8eb7
commit 76b1a2d4e9
4 changed files with 65 additions and 1 deletions

View File

@ -1,5 +1,11 @@
import React from "react";
import EnvTabsContainer from "./EnvTabsContainer";
import { EnvTab } from "../types";
export default function Dashboard() {
return <h1>Hello world</h1>;
const onSelectEnvTab = (tab: EnvTab): void => {
console.log("tab changed:", tab);
};
return <EnvTabsContainer onSelect={onSelectEnvTab} />;
}

View File

@ -0,0 +1,39 @@
import React from "react";
import Tabs from "@mui/material/Tabs";
import Tab from "@mui/material/Tab";
import Box from "@mui/material/Box";
import { ENVIRONMENT_TABS } from "../const";
import { EnvTab } from "../types";
interface OnSelectTab {
(tab: EnvTab): void;
}
interface EnvTabsContainerProps {
onSelect: OnSelectTab;
}
export default function EnvTabsContainer({ onSelect }: EnvTabsContainerProps) {
const defaultTab = ENVIRONMENT_TABS[0];
const [selected, setSelected] = React.useState(defaultTab);
const handleChange = (event: React.SyntheticEvent, newValue: EnvTab) => {
setSelected(newValue);
onSelect(newValue);
};
const tabs = ENVIRONMENT_TABS.map((tab, index) => {
return <Tab label={tab.title} key={tab.id} value={tab} />;
});
return (
<Box sx={{ width: "100%" }}>
<Box sx={{ borderBottom: 1, borderColor: "divider" }}>
<Tabs value={selected} onChange={handleChange}>
{tabs}
</Tabs>
</Box>
</Box>
);
}

14
src/const.ts Normal file
View File

@ -0,0 +1,14 @@
import { EnvTab } from "./types";
export const ENVIRONMENT_TABS: EnvTab[] = [
{
title: "DEV",
id: "dev",
dashboardEndpoint: "https://intis-service-checker.dev.televendcloud.com/api/checker/v1/dashboard",
},
{
title: "QA",
id: "qa",
dashboardEndpoint: "https://intis-service-checker.qa.televendcloud.com/api/checker/v1/dashboard",
},
];

5
src/types.tsx Normal file
View File

@ -0,0 +1,5 @@
export type EnvTab = {
title: string;
id: string;
dashboardEndpoint: string;
};