Skip to content

Commit dd94745

Browse files
committed
fix: enum in tabs
1 parent c8a44ab commit dd94745

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/modules/main/AdminView.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Trans, useTranslation } from 'react-i18next';
44
import { TabContext, TabList, TabPanel } from '@mui/lab';
55
import { Badge, Box, Link, Tab, Typography } from '@mui/material';
66

7+
import { UnionOfConst } from '@graasp/sdk';
8+
79
import { AlertTriangle, Info, MessageSquareText, Settings } from 'lucide-react';
810

911
import { GeneralSettings, SettingsKeys } from '@/config/appSetting';
@@ -20,15 +22,16 @@ import {
2022
import SettingsView from '../settings/SettingsView';
2123
import ConversationsView from './ConversationsView';
2224

23-
enum Tabs {
24-
TABLE_VIEW = 'TABLE_VIEW',
25-
SETTINGS_VIEW = 'SETTINGS_VIEW',
26-
ABOUT_VIEW = 'ABOUT_VIEW',
27-
}
25+
const Tabs = {
26+
TABLE_VIEW: 'TABLE_VIEW',
27+
SETTINGS_VIEW: 'SETTINGS_VIEW',
28+
ABOUT_VIEW: 'ABOUT_VIEW',
29+
} as const;
30+
type TabsType = UnionOfConst<typeof Tabs>;
2831

2932
const AdminView = (): JSX.Element => {
3033
const { t } = useTranslation();
31-
const [activeTab, setActiveTab] = useState(Tabs.TABLE_VIEW);
34+
const [activeTab, setActiveTab] = useState<TabsType>(Tabs.TABLE_VIEW);
3235

3336
const { data: generalSettings } = hooks.useAppSettings<GeneralSettings>({
3437
name: SettingsKeys.ChatbotPrompt,
@@ -40,7 +43,7 @@ const AdminView = (): JSX.Element => {
4043
<TabList
4144
textColor="secondary"
4245
indicatorColor="secondary"
43-
onChange={(_, newTab: Tabs) => setActiveTab(newTab)}
46+
onChange={(_, newTab: TabsType) => setActiveTab(newTab)}
4447
centered
4548
>
4649
<Tab

0 commit comments

Comments
 (0)