feat: a few tabs for module, deal services tab for mobiles

This commit is contained in:
2025-09-21 09:47:55 +04:00
parent 6e445d5ebf
commit 6d6c430e88
62 changed files with 521 additions and 128 deletions

View File

@ -2,11 +2,12 @@ import React, { FC, ReactNode } from "react";
import { IconEdit, IconHistory } from "@tabler/icons-react";
import { motion } from "framer-motion";
import { Box, Tabs, Text } from "@mantine/core";
import TabsList from "@/app/deals/drawers/DealEditorDrawer/components/TabsList";
import DealStatusHistoryTab from "@/app/deals/drawers/DealEditorDrawer/tabs/DealStatusHistoryTab/DealStatusHistoryTab";
import GeneralTab from "@/app/deals/drawers/DealEditorDrawer/tabs/GeneralTab/GeneralTab";
import useIsMobile from "@/hooks/utils/useIsMobile";
import { DealSchema, ProjectSchema } from "@/lib/client";
import { MODULES } from "@/modules/modules";
import MODULES from "@/modules/modules";
import styles from "../DealEditorDrawer.module.css";
type Props = {
@ -50,29 +51,58 @@ const DealEditorBody: FC<Props> = props => {
</Tabs.Tab>
);
const getModuleTabs = () =>
props.project?.builtInModules.map(module => {
const info = MODULES[module.key].renderInfo;
return getTab(info.key, info.label, info.icon);
});
const getModuleTabs = (): ReactNode[] => {
if (!props.project) return [];
const tabs: ReactNode[] = [];
const getModuleTabPanels = () =>
props.project?.builtInModules.map(module =>
getTabPanel(module.key, MODULES[module.key]?.getTab?.(props))
);
for (const module of props.project.builtInModules) {
const moduleInfo = MODULES[module.key];
for (const tab of moduleInfo.tabs) {
if (
(tab.device === "desktop" && isMobile) ||
(tab.device === "mobile" && !isMobile)
)
continue;
tabs.push(getTab(tab.key, tab.label, tab.icon));
}
}
return tabs;
};
const getModuleTabPanels = () => {
if (!props.project) return [];
const tabPanels: ReactNode[] = [];
for (const module of props.project.builtInModules) {
const moduleInfo = MODULES[module.key];
for (const tab of moduleInfo.tabs) {
if (
(tab.device === "desktop" && isMobile) ||
(tab.device === "mobile" && !isMobile)
)
continue;
tabPanels.push(getTabPanel(tab.key, tab.tab(props)));
}
}
return tabPanels;
};
return (
<Tabs
defaultValue="general"
orientation={isMobile ? "horizontal" : "vertical"}
h={"97vh"}
mih={"97vh"}
h={isMobile ? "min-content" : "97vh"}
mih={isMobile ? "min-content" : "97vh"}
classNames={{ tab: styles.tab }}>
<Tabs.List>
<TabsList>
{getTab("general", "Общая информация", <IconEdit />)}
{getTab("history", "История", <IconHistory />)}
{getModuleTabs()}
</Tabs.List>
</TabsList>
{getTabPanel("general", <GeneralTab {...props} />)}
{getTabPanel("history", <DealStatusHistoryTab {...props} />)}