Skip to content

Commit da73da4

Browse files
committed
feat: add ReusableModal component for enhanced modal functionality in Getting Started widget
Signed-off-by: amitamrutiya <amitamrutiya2210@gmail.com>
1 parent 0354b22 commit da73da4

2 files changed

Lines changed: 96 additions & 1 deletion

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { ReactNode } from 'react';
2+
import { Button } from '../../../base';
3+
import { styled } from '../../../theme';
4+
import {
5+
Modal,
6+
ModalBody,
7+
ModalButtonPrimary,
8+
ModalButtonSecondary,
9+
ModalFooter
10+
} from '../../Modal';
11+
12+
const CancelButton = styled(Button)(({ theme }) => ({
13+
borderColor: `${theme.palette.grey[300]} !important`,
14+
color: `${theme.palette.grey[300]} !important`,
15+
width: 'fit-content !important'
16+
}));
17+
18+
const ActionButtons = styled('div')(() => ({
19+
display: 'flex',
20+
flex: 'auto',
21+
justifyContent: 'flex-end',
22+
gap: '1rem'
23+
}));
24+
25+
interface ReusableModalProps {
26+
children: ReactNode;
27+
open: boolean;
28+
isFullScreenModeAllowed?: boolean;
29+
handleClose: () => void;
30+
modalIcon?: ReactNode;
31+
modalTitle?: string;
32+
onAction?: () => void;
33+
onSecondaryAction?: () => void;
34+
actionName?: string;
35+
secondaryActionName?: string;
36+
cancelButton?: boolean;
37+
cancelButtonText?: string;
38+
onCancel?: () => void;
39+
maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
40+
actionButton?: boolean;
41+
secondaryActionButton?: boolean;
42+
}
43+
44+
const ReusableModal = ({
45+
children,
46+
open,
47+
handleClose,
48+
modalIcon,
49+
modalTitle,
50+
onAction,
51+
onSecondaryAction,
52+
actionName,
53+
secondaryActionName,
54+
cancelButton = true,
55+
cancelButtonText,
56+
onCancel,
57+
maxWidth,
58+
actionButton = true,
59+
secondaryActionButton = false
60+
}: ReusableModalProps): JSX.Element => {
61+
return (
62+
<Modal
63+
closeModal={handleClose}
64+
title={modalTitle || ''}
65+
open={open}
66+
headerIcon={modalIcon}
67+
maxWidth={maxWidth ? maxWidth : 'md'}
68+
>
69+
<ModalBody>{children}</ModalBody>
70+
<ModalFooter variant="filled">
71+
<>
72+
{cancelButton && (
73+
<CancelButton variant="outlined" onClick={onCancel}>
74+
{cancelButtonText ? cancelButtonText : 'Cancel'}
75+
</CancelButton>
76+
)}
77+
<ActionButtons>
78+
{secondaryActionButton && (
79+
<ModalButtonSecondary variant="contained" onClick={onSecondaryAction}>
80+
{secondaryActionName ? secondaryActionName : 'Save'}
81+
</ModalButtonSecondary>
82+
)}
83+
{actionButton && (
84+
<ModalButtonPrimary variant="contained" onClick={onAction}>
85+
{actionName ? actionName : 'Save'}
86+
</ModalButtonPrimary>
87+
)}
88+
</ActionButtons>
89+
</>
90+
</ModalFooter>
91+
</Modal>
92+
);
93+
};
94+
95+
export default ReusableModal;

src/custom/DashboardWidgets/GettingStartedWidget/TeamSearchField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* eslint-disable @typescript-eslint/ban-ts-comment */
21
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
// @ts-nocheck
44
import { Autocomplete, Box, Typography } from '@mui/material';
55
import { styled } from '@mui/material/styles';

0 commit comments

Comments
 (0)