formatted

This commit is contained in:
Amirhossein Mahmoodi
2024-07-09 13:58:13 +03:30
parent 863bdaca95
commit bc73725138
82 changed files with 2206 additions and 3082 deletions

View File

@@ -1,16 +1,16 @@
'use client'
"use client";
import createCache from "@emotion/cache";
import {prefixer} from "stylis";
import { prefixer } from "stylis";
import stylisRTLPlugin from "stylis-plugin-rtl";
import {CacheProvider} from "@emotion/react";
import { CacheProvider } from "@emotion/react";
const cache = createCache({
key: 'mui-rtl',
key: "mui-rtl",
stylisPlugins: [prefixer, stylisRTLPlugin],
});
const cacheProviderRtl = (props) => {
return <CacheProvider value={cache}>{props.children}</CacheProvider>;
}
};
export default cacheProviderRtl
export default cacheProviderRtl;

View File

@@ -1,4 +1,4 @@
'use client'
"use client";
import { toast } from "react-toastify";
import {
errorClientToast,
@@ -6,56 +6,55 @@ import {
errorServerToast,
errorTooManyToast,
errorUnauthorizedToast,
errorValidationToast
errorValidationToast,
} from "@/core/components/toasts/error";
const isServerError = status => status >= 500 && status <= 599;
const isClientError = status => status >= 400 && status <= 499;
const isServerError = (status) => status >= 500 && status <= 599;
const isClientError = (status) => status >= 400 && status <= 499;
const errorServer = (response, notification, toastContainer) => {
if (notification) errorServerToast(toastContainer)
}
if (notification) errorServerToast(toastContainer);
};
const errorClient = (response, notification, toastContainer) => {
switch (response.status) {
case 401:
if (notification) errorUnauthorizedToast(toastContainer)
if (notification) errorUnauthorizedToast(toastContainer);
break;
case 422:
if ('type' in response.data) {
if ("type" in response.data) {
if (Array.isArray(response.data.message)) {
response.data.message.map((item) => {
if (notification) errorLogicToast(item, toastContainer)
})
if (notification) errorLogicToast(item, toastContainer);
});
} else {
if (notification) errorLogicToast(response.data.message, toastContainer)
if (notification) errorLogicToast(response.data.message, toastContainer);
}
break;
}
if (notification) {
const errorsMap = Object.keys(response.data.errors)
const errorsArray = response.data.errors
const errorsMap = Object.keys(response.data.errors);
const errorsArray = response.data.errors;
errorsMap.map((item, index) => {
errorValidationToast(errorsArray[item][0], toastContainer);
})
});
}
break;
case 429:
if (notification) errorTooManyToast(toastContainer)
break
if (notification) errorTooManyToast(toastContainer);
break;
default:
if (notification) errorClientToast(toastContainer)
break
if (notification) errorClientToast(toastContainer);
break;
}
}
};
export const errorResponse = (response, notification, toastContainer) => {
if (notification) toast.dismiss({ container: toastContainer })
if (notification) toast.dismiss({ container: toastContainer });
if (isServerError(response.status)) {
errorServer(response, notification, toastContainer)
errorServer(response, notification, toastContainer);
} else if (isClientError(response.status)) {
errorClient(response, notification, toastContainer)
errorClient(response, notification, toastContainer);
}
}
};

View File

@@ -7,4 +7,4 @@ export const flattenArrayOfObjects = (array, key) => {
}
return acc;
}, []);
};
};

View File

@@ -2,346 +2,346 @@ import { AirlineSeatReclineNormal, Assessment, Repartition, Security, SpaceDashb
export const pageMenu = [
{
id: 'dashboard',
label: 'پیشخوان',
id: "dashboard",
label: "پیشخوان",
type: "page",
route: "/dashboard",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'userManagement',
label: 'مدیریت کاربران',
id: "userManagement",
label: "مدیریت کاربران",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/user_management",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'projectsManagment',
label: 'پروژه های راهداری',
id: "projectsManagment",
label: "پروژه های راهداری",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'projectsManagmentFinance',
label: 'ثبت قرارداد و پروژه',
id: "projectsManagmentFinance",
label: "ثبت قرارداد و پروژه",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/finance",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'projectsManagmentList',
label: 'لیست پروژه ها',
id: "projectsManagmentList",
label: "لیست پروژه ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/projects_list",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'projectsManagmentProposal',
label: 'پروژه های پیشنهادی',
id: "projectsManagmentProposal",
label: "پروژه های پیشنهادی",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/proposal",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'projectsManagmentLawmaker',
label: 'درخواست نمایندگان',
id: "projectsManagmentLawmaker",
label: "درخواست نمایندگان",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/lawmakers",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'projectsManagmentMap',
label: 'پراکندگی بر روی نقشه',
id: "projectsManagmentMap",
label: "پراکندگی بر روی نقشه",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=rahdari_projects",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
],
},
{
id: 'roadItemManagment',
label: 'فعالیت های روزانه',
id: "roadItemManagment",
label: "فعالیت های روزانه",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadItemManagmentSupervisor',
label: 'ارزیابی',
id: "roadItemManagmentSupervisor",
label: "ارزیابی",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadItemManagmentSupervisorCartable',
label: 'کارتابل',
id: "roadItemManagmentSupervisorCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/supervisor/cartable",
},
]
],
},
{
id: 'roadItemManagmentOparation',
label: 'عملیات',
id: "roadItemManagmentOparation",
label: "عملیات",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadItemManagmentOparationCreate',
label: 'ثبت فعالیت',
id: "roadItemManagmentOparationCreate",
label: "ثبت فعالیت",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/create",
},
{
id: 'roadItemManagmentOparationCartable',
label: 'کارتابل',
id: "roadItemManagmentOparationCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/operator/cartable",
},
]
],
},
{
id: 'roadItemManagmentMap',
label: 'پراکندگی بر روی نقشه',
id: "roadItemManagmentMap",
label: "پراکندگی بر روی نقشه",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_items",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'roadItemManagmentReport',
label: 'گزارش ها',
id: "roadItemManagmentReport",
label: "گزارش ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
],
},
{
id: 'roadPatrolManagment',
label: 'گشت راهداری و ترابری',
id: "roadPatrolManagment",
label: "گشت راهداری و ترابری",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadPatrolManagmentSupervisor',
label: 'ارزیابی',
id: "roadPatrolManagmentSupervisor",
label: "ارزیابی",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadPatrolManagmentSupervisorCartable',
label: 'کارتابل',
id: "roadPatrolManagmentSupervisorCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/road_patrols/supervisor/cartable",
},
]
],
},
{
id: 'roadPatrolManagmentOparation',
label: 'عملیات',
id: "roadPatrolManagmentOparation",
label: "عملیات",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadPatrolManagmentOparationCreate',
label: 'ثبت اقدام',
id: "roadPatrolManagmentOparationCreate",
label: "ثبت اقدام",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/create",
},
{
id: 'roadPatrolManagmentOparationCartable',
label: 'کارتابل',
id: "roadPatrolManagmentOparationCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/cartable",
},
]
],
},
{
id: 'roadPatrolManagmentMap',
label: 'پراکندگی بر روی نقشه',
id: "roadPatrolManagmentMap",
label: "پراکندگی بر روی نقشه",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_patrols",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'roadPatrolManagmentReport',
label: 'گزارش ها',
id: "roadPatrolManagmentReport",
label: "گزارش ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
],
},
{
id: 'safetyAndPrivacyManagment',
label: 'نگهداری حریم راه',
id: "safetyAndPrivacyManagment",
label: "نگهداری حریم راه",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'safetyAndPrivacyManagmentOparation',
label: 'عملیات',
id: "safetyAndPrivacyManagmentOparation",
label: "عملیات",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'safetyAndPrivacyManagmentOparationCreate',
label: 'ثبت فعالیت',
id: "safetyAndPrivacyManagmentOparationCreate",
label: "ثبت فعالیت",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/safety_and_privacy/operator/first_step",
},
{
id: 'safetyAndPrivacyManagmentOparationCartable',
label: 'کارتابل',
id: "safetyAndPrivacyManagmentOparationCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/operator/cartable",
},
]
],
},
{
id: 'safetyAndPrivacyManagmentMap',
label: 'پراکندگی بر روی نقشه',
id: "safetyAndPrivacyManagmentMap",
label: "پراکندگی بر روی نقشه",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'safetyAndPrivacyManagmentReport',
label: 'گزارش ها',
id: "safetyAndPrivacyManagmentReport",
label: "گزارش ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
],
},
{
id: 'roadObservationsManagment',
label: 'واکنش سریع',
id: "roadObservationsManagment",
label: "واکنش سریع",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadObservationsManagmentSupervisor',
label: 'ارزیابی',
id: "roadObservationsManagmentSupervisor",
label: "ارزیابی",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadObservationsManagmentSupervisorCartable',
label: 'کارتابل',
id: "roadObservationsManagmentSupervisorCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/supervisor/cartable",
},
]
],
},
{
id: 'roadObservationsManagmentList',
label: 'رسیدگی به شکایات',
id: "roadObservationsManagmentList",
label: "رسیدگی به شکایات",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'roadObservationsManagmentOparation',
label: 'عملیات',
id: "roadObservationsManagmentOparation",
label: "عملیات",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'roadObservationsManagmentOparationCartable',
label: 'کارتابل',
id: "roadObservationsManagmentOparationCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/operator/cartable",
},
]
],
},
{
id: 'roadObservationsManagmentMap',
label: 'پراکندگی بر روی نقشه',
id: "roadObservationsManagmentMap",
label: "پراکندگی بر روی نقشه",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_observations",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'roadObservationsManagmentReport',
label: 'گزارش ها',
id: "roadObservationsManagmentReport",
label: "گزارش ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/report/index",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
],
},
{
id: 'winterCampManagment',
label: 'قرارگاه زمستانی',
id: "winterCampManagment",
label: "قرارگاه زمستانی",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'winterCampManagmentBlocking',
label: 'محور های انسدادی',
id: "winterCampManagmentBlocking",
label: "محور های انسدادی",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/winter_camp",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'winterCampManagmentFirstRing',
label: 'محور های حلقه اول',
id: "winterCampManagmentFirstRing",
label: "محور های حلقه اول",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=camp",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
{
id: 'winterCampManagmentReport',
label: 'گزارش ها',
id: "winterCampManagmentReport",
label: "گزارش ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=campNew",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
],
},
{
id: 'receiptManagment',
label: 'خسارات وارده بر ابنیه فنی و تاسیسات راه',
id: "receiptManagment",
label: "خسارات وارده بر ابنیه فنی و تاسیسات راه",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'receiptManagmentOparation',
label: 'عملیات',
id: "receiptManagmentOparation",
label: "عملیات",
type: "menu",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
hasSubitems: true,
Subitems: [
{
id: 'receiptManagmentOparationCartable',
label: 'کارتابل',
id: "receiptManagmentOparationCartable",
label: "کارتابل",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt",
},
]
],
},
{
id: 'receiptManagmentReport',
label: 'گزارش ها',
id: "receiptManagmentReport",
label: "گزارش ها",
type: "page",
route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt/report",
icon: <Security sx={{ width: 'inherit', height: 'inherit' }} />,
icon: <Security sx={{ width: "inherit", height: "inherit" }} />,
},
]
}
],
},
// {
// id: "hello",
// type: "menu",
@@ -383,4 +383,4 @@ export const pageMenu = [
// hasSubitems: true,
// showSubitems: false
// },
]
];

View File

@@ -1,4 +1,4 @@
const api = process.env.NEXT_PUBLIC_API_URL
const api = process.env.NEXT_PUBLIC_API_URL;
export const GET_USER_ROUTE = api + '/webapi/user/get-permission'
export const GET_LOGIN_ROUTE = api + '/test_login'
export const GET_USER_ROUTE = api + "/webapi/user/get-permission";
export const GET_LOGIN_ROUTE = api + "/login_dev";

View File

@@ -1,10 +1,10 @@
'use client'
"use client";
import { toast } from "react-toastify";
import { successToast } from "@/core/components/toasts/success";
export const successRequest = (notification, toastContainer) => {
if (notification) {
toast.dismiss({ container: toastContainer })
successToast(toastContainer)
toast.dismiss({ container: toastContainer });
successToast(toastContainer);
}
}
};

View File

@@ -1,22 +1,22 @@
'use client'
"use client";
import { createTheme } from "@mui/material";
const theme = createTheme({
direction: 'rtl',
direction: "rtl",
typography: {
fontFamily: `IRANSansFaNum, sans-serif`,
fontSize: 12
fontSize: 12,
},
palette: {
primary: {
main: '#2070af',
contrastText: '#fff'
main: "#2070af",
contrastText: "#fff",
},
primary2: {
main: '#015688',
contrastText: '#fff'
main: "#015688",
contrastText: "#fff",
},
}
},
});
export default theme
export default theme;

View File

@@ -1,162 +1,120 @@
import { alpha, darken } from "@mui/material";
export const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
export const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, "_");
export const parseFromValuesOrFunc = (
fn,
arg
) => (fn instanceof Function ? fn(arg) : fn);
export const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
export const getCommonToolbarStyles = ({
table,
}) => ({
alignItems: 'flex-start',
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
display: 'grid',
flexWrap: 'wrap-reverse',
minHeight: '3.5rem',
overflow: 'hidden',
position: 'relative',
transition: 'all 150ms ease-in-out',
zIndex: 1,
export const getCommonToolbarStyles = ({ table }) => ({
alignItems: "flex-start",
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
display: "grid",
flexWrap: "wrap-reverse",
minHeight: "3.5rem",
overflow: "hidden",
position: "relative",
transition: "all 150ms ease-in-out",
zIndex: 1,
});
export const getCommonTooltipProps = (
placement,
) => ({
disableInteractive: true,
enterDelay: 500,
enterNextDelay: 500,
placement,
export const getCommonTooltipProps = (placement) => ({
disableInteractive: true,
enterDelay: 500,
enterNextDelay: 500,
placement,
});
export const flipIconStyles = (theme) =>
theme.direction === 'rtl'
? { style: { transform: 'scaleX(-1)' } }
: undefined;
theme.direction === "rtl" ? { style: { transform: "scaleX(-1)" } } : undefined;
export const getCommonPinnedCellStyles = ({
column,
table,
theme,
}) => {
const { baseBackgroundColor } = table.options.mrtTheme;
const isPinned = column?.getIsPinned();
export const getCommonPinnedCellStyles = ({ column, table, theme }) => {
const { baseBackgroundColor } = table.options.mrtTheme;
const isPinned = column?.getIsPinned();
return {
'&[data-pinned="true"]': {
'&:before': {
backgroundColor: alpha(
darken(
baseBackgroundColor,
theme.palette.mode === 'dark' ? 0.05 : 0.01,
),
0.97,
),
boxShadow: column
? isPinned === 'left' && column.getIsLastColumn(isPinned)
? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
: isPinned === 'right' && column.getIsFirstColumn(isPinned)
? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
: undefined
: undefined,
...commonCellBeforeAfterStyles,
},
},
};
return {
'&[data-pinned="true"]': {
"&:before": {
backgroundColor: alpha(darken(baseBackgroundColor, theme.palette.mode === "dark" ? 0.05 : 0.01), 0.97),
boxShadow: column
? isPinned === "left" && column.getIsLastColumn(isPinned)
? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
: isPinned === "right" && column.getIsFirstColumn(isPinned)
? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
: undefined
: undefined,
...commonCellBeforeAfterStyles,
},
},
};
};
export const getCommonMRTCellStyles = ({
column,
header,
table,
tableCellProps,
theme,
}) => {
const {
getState,
options: { enableColumnVirtualization, layoutMode },
} = table;
const { draggingColumn } = getState();
const { columnDef } = column;
const { columnDefType } = columnDef;
export const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme }) => {
const {
getState,
options: { enableColumnVirtualization, layoutMode },
} = table;
const { draggingColumn } = getState();
const { columnDef } = column;
const { columnDefType } = columnDef;
const isColumnPinned =
columnDef.columnDefType !== 'group' && column.getIsPinned();
const isColumnPinned = columnDef.columnDefType !== "group" && column.getIsPinned();
const widthStyles = {
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
header?.id ?? column.id,
)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
header?.id ?? column.id,
)}-size) * 1px)`,
};
const widthStyles = {
minWidth: `max(calc(var(--${header ? "header" : "col"}-${parseCSSVarId(
header?.id ?? column.id
)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
width: `calc(var(--${header ? "header" : "col"}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`,
};
if (layoutMode === 'grid') {
widthStyles.flex = `${[0, false].includes(columnDef.grow)
? 0
: `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
header?.id ?? column.id,
)}-size)`
} 0 auto`;
} else if (layoutMode === 'grid-no-grow') {
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
}
const pinnedStyles = isColumnPinned
? {
...getCommonPinnedCellStyles({ column, table, theme }),
left:
isColumnPinned === 'left'
? `${column.getStart('left')}px`
: undefined,
opacity: 0.97,
position: 'sticky',
right:
isColumnPinned === 'right'
? `${column.getAfter('right')}px`
: undefined,
if (layoutMode === "grid") {
widthStyles.flex = `${
[0, false].includes(columnDef.grow)
? 0
: `var(--${header ? "header" : "col"}-${parseCSSVarId(header?.id ?? column.id)}-size)`
} 0 auto`;
} else if (layoutMode === "grid-no-grow") {
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
}
: {};
return {
backgroundColor: 'inherit',
backgroundImage: 'inherit',
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
justifyContent:
columnDefType === 'group'
? 'center'
: layoutMode?.startsWith('grid')
? tableCellProps.align
: undefined,
opacity:
table.getState().draggingColumn?.id === column.id ||
table.getState().hoveredColumn?.id === column.id
? 0.5
: 1,
position: 'relative',
transition: enableColumnVirtualization
? 'none'
: `padding 150ms ease-in-out`,
zIndex:
column.getIsResizing() || draggingColumn?.id === column.id
? 2
: columnDefType !== 'group' && isColumnPinned
? 1
: 0,
...pinnedStyles,
...widthStyles,
...(parseFromValuesOrFunc(tableCellProps?.sx, theme)),
};
const pinnedStyles = isColumnPinned
? {
...getCommonPinnedCellStyles({ column, table, theme }),
left: isColumnPinned === "left" ? `${column.getStart("left")}px` : undefined,
opacity: 0.97,
position: "sticky",
right: isColumnPinned === "right" ? `${column.getAfter("right")}px` : undefined,
}
: {};
return {
backgroundColor: "inherit",
backgroundImage: "inherit",
display: layoutMode?.startsWith("grid") ? "flex" : undefined,
justifyContent:
columnDefType === "group" ? "center" : layoutMode?.startsWith("grid") ? tableCellProps.align : undefined,
opacity:
table.getState().draggingColumn?.id === column.id || table.getState().hoveredColumn?.id === column.id
? 0.5
: 1,
position: "relative",
transition: enableColumnVirtualization ? "none" : `padding 150ms ease-in-out`,
zIndex:
column.getIsResizing() || draggingColumn?.id === column.id
? 2
: columnDefType !== "group" && isColumnPinned
? 1
: 0,
...pinnedStyles,
...widthStyles,
...parseFromValuesOrFunc(tableCellProps?.sx, theme),
};
};
export const commonCellBeforeAfterStyles = {
content: '""',
height: '100%',
left: 0,
position: 'absolute',
top: 0,
width: '100%',
zIndex: -1,
};
content: '""',
height: "100%",
left: 0,
position: "absolute",
top: 0,
width: "100%",
zIndex: -1,
};