@campxdev/shared 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +34 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +16 -0
- package/.storybook/preview.js +9 -0
- package/antd.customize.less +73 -0
- package/exports.ts +20 -0
- package/package.json +78 -0
- package/public/dean.JPG +0 -0
- package/public/download.png +0 -0
- package/public/illustrations/bookmark.svg +19 -0
- package/public/illustrations/girl-writing.png +0 -0
- package/public/illustrations/whiteboard.svg +24 -0
- package/public/images/AnimatedUploadFile.gif +0 -0
- package/public/images/doc@2x.png +0 -0
- package/public/images/greenTick.png +0 -0
- package/public/images/jpg.png +0 -0
- package/public/images/paperclip@2x.png +0 -0
- package/public/images/pdf.png +0 -0
- package/public/images/ppt.png +0 -0
- package/public/images/profileImage.jpg +0 -0
- package/public/images/profileImage.png +0 -0
- package/public/index.html +50 -0
- package/public/logo.png +0 -0
- package/public/logo_campx_full.png +0 -0
- package/public/logo_square.svg +21 -0
- package/public/omr_sign.jpg +0 -0
- package/src/App.tsx +35 -0
- package/src/assets/fonts/avenir/Avenir.ttc +0 -0
- package/src/assets/fonts/avenir/index.ts +2 -0
- package/src/assets/fonts/poppins/Poppins-Bold.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Italic.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Light.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-LightItalic.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Medium.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-MediumItalic.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-SemiBold.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-SemiBoldItalic.ttf +0 -0
- package/src/assets/fonts/poppins/index.ts +7 -0
- package/src/assets/images/File bundle-bro.svg +122 -0
- package/src/assets/images/Filebundle.png +0 -0
- package/src/assets/images/NoPart.png +0 -0
- package/src/assets/images/ResultProcess.png +0 -0
- package/src/assets/images/ResultProcess.svg +99 -0
- package/src/assets/images/attachment.svg +1 -0
- package/src/assets/images/avatar.png +0 -0
- package/src/assets/images/index.ts +19 -0
- package/src/assets/images/pdf.png +0 -0
- package/src/assets/images/taskAttachment.png +0 -0
- package/src/assets/images/welcomeimage.jpg +0 -0
- package/src/assets/static_files/External_Marks_Import .xlsx +0 -0
- package/src/assets/static_files/Leads_Sample.xlsx +0 -0
- package/src/assets/static_files/Subject_Topic_Import_Sheet.xlsx +0 -0
- package/src/assets/static_files/admissions_Sample.xlsx +0 -0
- package/src/assets/static_files/barcodes_template.xlsx +0 -0
- package/src/assets/static_files/hostel_rooms_import.xlsx +0 -0
- package/src/assets/static_files/index.ts +24 -0
- package/src/assets/static_files/sample_admissions.xlsx +0 -0
- package/src/assets/static_files/sample_admissions_report.xlsx +0 -0
- package/src/assets/static_files/sample_curriculum_subjects_template.xlsx +0 -0
- package/src/assets/static_files/sample_import_students_new.xlsx +0 -0
- package/src/assets/static_files/sample_internal_marks.xlsx +0 -0
- package/src/assets/static_files/sample_student_subjects_template.xlsx +0 -0
- package/src/components/ActionButton.tsx +28 -0
- package/src/components/Attachment.tsx +26 -0
- package/src/components/AutocompleteSearch/AutocompleteSearch.tsx +57 -0
- package/src/components/AutocompleteSearch/index.tsx +1 -0
- package/src/components/Breadcrumbs.tsx +73 -0
- package/src/components/Card.tsx +97 -0
- package/src/components/CardsGrid.tsx +28 -0
- package/src/components/Chips.tsx +77 -0
- package/src/components/Detail.tsx +15 -0
- package/src/components/DetailsGrid.tsx +52 -0
- package/src/components/DividerHeading.tsx +40 -0
- package/src/components/DrawerWrapper/DialogWrapper.tsx +63 -0
- package/src/components/DrawerWrapper/DrawerTemplate.tsx +53 -0
- package/src/components/DrawerWrapper/DrawerWrapper.tsx +53 -0
- package/src/components/DropDownButton.tsx +184 -0
- package/src/components/ErrorBoundary.js +45 -0
- package/src/components/ErrorBox.tsx +42 -0
- package/src/components/FloatingContainer.tsx +26 -0
- package/src/components/FullCalendar/Actions.tsx +162 -0
- package/src/components/FullCalendar/FullCalendarWrapper.tsx +54 -0
- package/src/components/HookForm/AutoCompleteSearch.tsx +143 -0
- package/src/components/HookForm/DatePicker.tsx +65 -0
- package/src/components/HookForm/DateTimePicker.tsx +70 -0
- package/src/components/HookForm/FormLabel.tsx +14 -0
- package/src/components/HookForm/MultiCheckbox.tsx +82 -0
- package/src/components/HookForm/MultiSelect.tsx +100 -0
- package/src/components/HookForm/RadioGroup.tsx +113 -0
- package/src/components/HookForm/SingleCheckbox.tsx +46 -0
- package/src/components/HookForm/SingleSelect.tsx +93 -0
- package/src/components/HookForm/TextField.tsx +74 -0
- package/src/components/HookForm/TimePicker.tsx +82 -0
- package/src/components/HookForm/index.ts +23 -0
- package/src/components/IconButtons/IconButtons.tsx +137 -0
- package/src/components/IconButtons/Icons.tsx +269 -0
- package/src/components/IconButtons/assets/edit.svg +4 -0
- package/src/components/IconButtons/assets/eye.svg +6 -0
- package/src/components/IconButtons/assets/trash.svg +7 -0
- package/src/components/IconButtons/index.tsx +8 -0
- package/src/components/IconLabel.tsx +37 -0
- package/src/components/Image/Image.tsx +43 -0
- package/src/components/Image/broken-image.png +0 -0
- package/src/components/Image/index.tsx +1 -0
- package/src/components/ImageUpload.tsx +98 -0
- package/src/components/Input/AutoCompleteSearch.tsx +143 -0
- package/src/components/Input/DatePicker.tsx +60 -0
- package/src/components/Input/DateRangePicker.tsx +131 -0
- package/src/components/Input/DateTimePicker.tsx +70 -0
- package/src/components/Input/FormLabel.tsx +14 -0
- package/src/components/Input/MultiCheckbox.tsx +79 -0
- package/src/components/Input/MultiSelect.tsx +52 -0
- package/src/components/Input/RadioGroup.tsx +55 -0
- package/src/components/Input/SingleCheckbox.tsx +23 -0
- package/src/components/Input/SingleSelect.tsx +139 -0
- package/src/components/Input/TextField.tsx +50 -0
- package/src/components/Input/TimePicker.tsx +82 -0
- package/src/components/Input/index.ts +26 -0
- package/src/components/JsonPreview/JsonPreview.tsx +7 -0
- package/src/components/JsonPreview/index.tsx +1 -0
- package/src/components/LabelValue/LabelValue.tsx +21 -0
- package/src/components/LabelValue/index.tsx +1 -0
- package/src/components/Layout/ChangePassword.tsx +49 -0
- package/src/components/Layout/Header/AppHeader.tsx +150 -0
- package/src/components/Layout/Header/CogWheelMenu.tsx +35 -0
- package/src/components/Layout/Header/FreshDeskHelpButton.tsx +19 -0
- package/src/components/Layout/Header/MainAppHeader.tsx +6 -0
- package/src/components/Layout/Header/Notification.tsx +13 -0
- package/src/components/Layout/Header/UserBox.tsx +51 -0
- package/src/components/Layout/Header/applications.tsx +39 -0
- package/src/components/Layout/Header/icons.tsx +57 -0
- package/src/components/Layout/Header/index.tsx +1 -0
- package/src/components/Layout/Header/styles.tsx +48 -0
- package/src/components/LinearProgress/LinearProgress.tsx +27 -0
- package/src/components/LinearProgress/index.tsx +1 -0
- package/src/components/MediaRow/MediaRow.tsx +69 -0
- package/src/components/MediaRow/index.tsx +1 -0
- package/src/components/MenuButton.tsx +105 -0
- package/src/components/ModalButtons/DialogButton.tsx +84 -0
- package/src/components/ModalButtons/DrawerButton.tsx +89 -0
- package/src/components/ModalButtons/index.tsx +4 -0
- package/src/components/NoDataIllustration/NoDataIllustration.tsx +32 -0
- package/src/components/NoDataIllustration/index.tsx +1 -0
- package/src/components/PageContent.tsx +14 -0
- package/src/components/PageHeader.tsx +52 -0
- package/src/components/PopupConfirm/ConfirmContextProvider.tsx +22 -0
- package/src/components/PopupConfirm/PopupConfirm.tsx +33 -0
- package/src/components/PopupConfirm/index.tsx +1 -0
- package/src/components/PopupConfirm/useConfirm.ts +47 -0
- package/src/components/Row/Row.tsx +24 -0
- package/src/components/Row/index.tsx +1 -0
- package/src/components/SearchBar/SearchBar.tsx +53 -0
- package/src/components/SearchBar/index.tsx +1 -0
- package/src/components/Spinner.tsx +18 -0
- package/src/components/StepsHeader/StepsHeader.tsx +115 -0
- package/src/components/StepsHeader/index.tsx +1 -0
- package/src/components/Styled/OutlinedIconButton.tsx +7 -0
- package/src/components/Styled/index.tsx +1 -0
- package/src/components/StyledTableContainer.tsx +33 -0
- package/src/components/Swiper/Swiper.tsx +39 -0
- package/src/components/Swiper/index.tsx +1 -0
- package/src/components/SwitchButton/SwitchButton.tsx +41 -0
- package/src/components/SwitchButton/index.tsx +1 -0
- package/src/components/TableComponent/BatchActionsHeader.tsx +58 -0
- package/src/components/TableComponent/Icons/index.tsx +50 -0
- package/src/components/TableComponent/ReactTable.tsx +293 -0
- package/src/components/TableComponent/RenderTableBody.tsx +65 -0
- package/src/components/TableComponent/TableFooter/TableFooter.tsx +102 -0
- package/src/components/TableComponent/TableFooter/index.tsx +1 -0
- package/src/components/TableComponent/TableFooter/styles.tsx +28 -0
- package/src/components/TableComponent/index.tsx +219 -0
- package/src/components/TableComponent/no-data-illu.svg +1 -0
- package/src/components/TableComponent/react-table-config.d.ts +129 -0
- package/src/components/TableComponent/styles.tsx +173 -0
- package/src/components/TableComponent/types.ts +57 -0
- package/src/components/Tabs/Tabs.tsx +52 -0
- package/src/components/Tabs/TabsContainer.tsx +50 -0
- package/src/components/Tabs/index.tsx +1 -0
- package/src/components/Tabs/styles.tsx +55 -0
- package/src/components/ToastContainer/ToastContainer.tsx +42 -0
- package/src/components/ToastContainer/index.tsx +1 -0
- package/src/components/UploadButton/UploadButton.tsx +98 -0
- package/src/components/UploadButton/index.tsx +1 -0
- package/src/components/UploadButton/types.ts +14 -0
- package/src/components/UploadDocument/UploadDocument.tsx +108 -0
- package/src/components/UploadDocument/index.tsx +1 -0
- package/src/components/UploadFileDialog/UploadFileDialog.tsx +240 -0
- package/src/components/UploadFileDialog/index.tsx +1 -0
- package/src/components/index.ts +59 -0
- package/src/config/axios.ts +138 -0
- package/src/constants/UIConstants.ts +97 -0
- package/src/constants/formValidations.ts +6 -0
- package/src/constants/index.ts +4 -0
- package/src/constants/permissions.ts +67 -0
- package/src/constants/validateMessages.ts +12 -0
- package/src/contexts/Providers.tsx +24 -0
- package/src/contexts/QueryClientProvider.tsx +22 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useFetch.ts +53 -0
- package/src/hooks/useRouter.ts +31 -0
- package/src/index.tsx +9 -0
- package/src/layouts/ComponentsLayout.tsx +3 -0
- package/src/pages/LoginPage/LoginPage.tsx +166 -0
- package/src/pages/LoginPage/index.ts +1 -0
- package/src/pages/LoginPage/styles.tsx +121 -0
- package/src/pages/index.ts +4 -0
- package/src/permissions/PageWithPermission.tsx +58 -0
- package/src/permissions/PermissionDeniedPage.tsx +23 -0
- package/src/permissions/PermissionsStore.ts +289 -0
- package/src/permissions/ValidateAccess.tsx +18 -0
- package/src/permissions/index.ts +3 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/shared-state/AssetsStore.ts +15 -0
- package/src/shared-state/UserStore.ts +13 -0
- package/src/shared-state/index.ts +3 -0
- package/src/stories/Button.stories.tsx +41 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Header.stories.tsx +25 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Page.stories.tsx +26 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/TextField.stories.tsx +18 -0
- package/src/stories/TextField.tsx +49 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/src/theme/App.less +3 -0
- package/src/theme/MuiThemeProvider.tsx +11 -0
- package/src/theme/customCssBaseline.ts +78 -0
- package/src/theme/index.css +75 -0
- package/src/theme/muiTheme.ts +516 -0
- package/src/theme/theme.d.ts +75 -0
- package/src/utils/alphabet.ts +23 -0
- package/src/utils/arrayPadEnd.ts +3 -0
- package/src/utils/formatCurrency.ts +9 -0
- package/src/utils/getUrlParams.ts +5 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/ordinalSuffixOf.ts +14 -0
- package/src/utils/romanize.ts +40 -0
- package/src/utils/withRouteWrapper.tsx +25 -0
- package/src/utils/withSuspense.tsx +6 -0
- package/styled-components.tsx +60 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import ChevronRight from '@mui/icons-material/ChevronRight'
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Button,
|
|
5
|
+
Card as MuiCard,
|
|
6
|
+
CardActions,
|
|
7
|
+
CardContent,
|
|
8
|
+
CardHeader,
|
|
9
|
+
CardMedia,
|
|
10
|
+
styled,
|
|
11
|
+
} from '@mui/material'
|
|
12
|
+
import { ReactNode } from 'react'
|
|
13
|
+
|
|
14
|
+
interface CardProps {
|
|
15
|
+
title: string | ReactNode
|
|
16
|
+
subheader?: string | ReactNode
|
|
17
|
+
children?: ReactNode
|
|
18
|
+
footer?: {
|
|
19
|
+
buttonText?: string | ReactNode
|
|
20
|
+
onClick: () => void
|
|
21
|
+
endIcon?: ReactNode
|
|
22
|
+
buttonProps?: any
|
|
23
|
+
}
|
|
24
|
+
image?: {
|
|
25
|
+
url: string
|
|
26
|
+
height: number
|
|
27
|
+
}
|
|
28
|
+
moreActions?: ReactNode
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function Card({
|
|
32
|
+
title,
|
|
33
|
+
subheader,
|
|
34
|
+
children,
|
|
35
|
+
footer,
|
|
36
|
+
image,
|
|
37
|
+
moreActions,
|
|
38
|
+
}: CardProps) {
|
|
39
|
+
const handleClick = (e) => {
|
|
40
|
+
e.preventDefault()
|
|
41
|
+
e.stopPropagation()
|
|
42
|
+
footer?.onClick()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<StyledCard>
|
|
47
|
+
<CardMedia component="img" height={image?.height} image={image?.url} />
|
|
48
|
+
<Box sx={{ position: 'relative', width: '100%' }}>
|
|
49
|
+
<StyledMoreActions>{moreActions}</StyledMoreActions>
|
|
50
|
+
<CardHeader title={title} subheader={subheader} />
|
|
51
|
+
</Box>
|
|
52
|
+
<CardContent sx={{ height: 'fit-content' }}>{children}</CardContent>
|
|
53
|
+
{footer && (
|
|
54
|
+
<StyledCardActions>
|
|
55
|
+
<Button
|
|
56
|
+
variant="text"
|
|
57
|
+
fullWidth
|
|
58
|
+
onClick={handleClick}
|
|
59
|
+
endIcon={footer?.endIcon ?? <ChevronRight />}
|
|
60
|
+
{...footer?.buttonProps}
|
|
61
|
+
>
|
|
62
|
+
{footer?.buttonText ?? 'View'}
|
|
63
|
+
</Button>
|
|
64
|
+
</StyledCardActions>
|
|
65
|
+
)}
|
|
66
|
+
</StyledCard>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const StyledMoreActions = styled(Box)(({ theme }) => ({
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
right: '10px',
|
|
73
|
+
top: '15px',
|
|
74
|
+
}))
|
|
75
|
+
|
|
76
|
+
const StyledCard = styled(MuiCard)(({ theme }) => ({
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
width: '100%',
|
|
80
|
+
height: '100%',
|
|
81
|
+
'& .MuiCardContent-root': {
|
|
82
|
+
flexGrow: 1,
|
|
83
|
+
},
|
|
84
|
+
'& .MuiCardHeader-root': {
|
|
85
|
+
alignItems: 'baseline',
|
|
86
|
+
gap: '6px',
|
|
87
|
+
},
|
|
88
|
+
}))
|
|
89
|
+
|
|
90
|
+
const StyledCardActions = styled(CardActions)(({ theme }) => ({
|
|
91
|
+
borderTop: theme.borders.grayLight,
|
|
92
|
+
'& .MuiButton-root': {
|
|
93
|
+
justifyContent: 'space-between',
|
|
94
|
+
height: '40px',
|
|
95
|
+
padding: '20px',
|
|
96
|
+
},
|
|
97
|
+
}))
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Box, SxProps } from '@mui/material'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
export default function CardsGrid({
|
|
4
|
+
cardWidth,
|
|
5
|
+
gap,
|
|
6
|
+
children,
|
|
7
|
+
sx,
|
|
8
|
+
}: {
|
|
9
|
+
cardWidth: number
|
|
10
|
+
gap: number
|
|
11
|
+
children: React.ReactNode
|
|
12
|
+
sx?: SxProps
|
|
13
|
+
}) {
|
|
14
|
+
return (
|
|
15
|
+
<Box
|
|
16
|
+
sx={{
|
|
17
|
+
width: '100%',
|
|
18
|
+
display: 'grid',
|
|
19
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${cardWidth}px, 1fr))`,
|
|
20
|
+
alignItems: 'start',
|
|
21
|
+
gap: `${gap}px`,
|
|
22
|
+
...sx,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Box>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Chip, Stack, styled } from '@mui/material'
|
|
2
|
+
import { ReactNode, useEffect, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
type IChip = {
|
|
5
|
+
label: string
|
|
6
|
+
value: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ChipsProps {
|
|
10
|
+
list: { label: string | ReactNode; value: string | number }[]
|
|
11
|
+
selected: string[] | string | number
|
|
12
|
+
onSelected: (selected: IChip[] | any) => void
|
|
13
|
+
direction?: 'row' | 'column'
|
|
14
|
+
singleSelection?: boolean
|
|
15
|
+
toggle?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function Chips({
|
|
19
|
+
list = [],
|
|
20
|
+
selected: _selected,
|
|
21
|
+
onSelected,
|
|
22
|
+
direction = 'row',
|
|
23
|
+
singleSelection = true,
|
|
24
|
+
toggle = false,
|
|
25
|
+
}: ChipsProps) {
|
|
26
|
+
const [selected, setSelected] = useState<any[] | any>([])
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setSelected(_selected)
|
|
30
|
+
}, [_selected])
|
|
31
|
+
|
|
32
|
+
const handleChange = (value) => {
|
|
33
|
+
if (singleSelection) {
|
|
34
|
+
if (selected === value && !toggle) {
|
|
35
|
+
setSelected('')
|
|
36
|
+
onSelected('')
|
|
37
|
+
} else {
|
|
38
|
+
setSelected(value)
|
|
39
|
+
onSelected(value)
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (selected.includes(value)) {
|
|
43
|
+
setSelected((prev) => prev.filter((item) => item !== value))
|
|
44
|
+
onSelected(selected.filter((item) => item !== value))
|
|
45
|
+
} else {
|
|
46
|
+
setSelected([...selected, value])
|
|
47
|
+
onSelected([...selected, value])
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isSelected = (value) =>
|
|
53
|
+
singleSelection ? selected === value : selected.includes(value)
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Stack gap={'8px'} direction={direction} flexWrap={'wrap'}>
|
|
57
|
+
{list.map((item, index) => (
|
|
58
|
+
<StyledChip
|
|
59
|
+
key={index}
|
|
60
|
+
color={'primary'}
|
|
61
|
+
label={item.label}
|
|
62
|
+
clickable
|
|
63
|
+
variant={isSelected(item?.value) ? 'outlined' : 'filled'}
|
|
64
|
+
onClick={() => handleChange(item?.value)}
|
|
65
|
+
/>
|
|
66
|
+
))}
|
|
67
|
+
</Stack>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const StyledChip = styled(Chip)(({ theme }) => ({
|
|
72
|
+
minWidth: '100px',
|
|
73
|
+
'&.MuiButtonBase-root.MuiChip-filled': {
|
|
74
|
+
background: theme.palette.secondary.light,
|
|
75
|
+
color: theme.palette.text.primary,
|
|
76
|
+
},
|
|
77
|
+
}))
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Box, BoxProps, styled, useTheme } from '@mui/material'
|
|
2
|
+
import LabelValue from './LabelValue'
|
|
3
|
+
import { ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
interface DetailsGridProps {
|
|
6
|
+
colCount: number
|
|
7
|
+
inverseLabels?: boolean
|
|
8
|
+
list: { label: ReactNode; value?: ReactNode }[]
|
|
9
|
+
noBorder?: boolean
|
|
10
|
+
space?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const StyledGrid = styled(Box, {
|
|
14
|
+
shouldForwardProp: (prop) => prop !== 'noBorder',
|
|
15
|
+
})<{ cols: number; noBorder: boolean; space: number }>(
|
|
16
|
+
({ theme, cols, noBorder, space }) => ({
|
|
17
|
+
padding: noBorder ? '1rem' : '20px',
|
|
18
|
+
marginTop: noBorder ? 0 : '1rem',
|
|
19
|
+
border: noBorder ? 'none' : theme.borders.grayLight,
|
|
20
|
+
display: 'grid',
|
|
21
|
+
gridTemplateColumns: `repeat(${cols}, 1fr)`,
|
|
22
|
+
gap: `${space}px`,
|
|
23
|
+
borderRadius: '10px',
|
|
24
|
+
[`& > :not(:nth-of-type(${cols}n))`]: {
|
|
25
|
+
borderRight: theme.borders.grayLight,
|
|
26
|
+
},
|
|
27
|
+
'& > :last-child': {
|
|
28
|
+
borderRight: 'none',
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export default function DetailsGrid({
|
|
34
|
+
colCount,
|
|
35
|
+
inverseLabels = false,
|
|
36
|
+
list,
|
|
37
|
+
noBorder = false,
|
|
38
|
+
space = 16,
|
|
39
|
+
}: DetailsGridProps) {
|
|
40
|
+
return (
|
|
41
|
+
<StyledGrid cols={colCount} space={space} noBorder={noBorder}>
|
|
42
|
+
{list?.map((item, index) => (
|
|
43
|
+
<LabelValue
|
|
44
|
+
reverse={inverseLabels}
|
|
45
|
+
label={item?.label}
|
|
46
|
+
value={item?.value}
|
|
47
|
+
key={index}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</StyledGrid>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Box, styled, Typography } from '@mui/material'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
export default function DividerHeading({
|
|
5
|
+
title,
|
|
6
|
+
actions,
|
|
7
|
+
}: {
|
|
8
|
+
title: string
|
|
9
|
+
actions?: ReactNode
|
|
10
|
+
}) {
|
|
11
|
+
return (
|
|
12
|
+
<StyledContainer>
|
|
13
|
+
<Typography variant="h6">{title}</Typography>
|
|
14
|
+
{actions && <Box>{actions}</Box>}
|
|
15
|
+
</StyledContainer>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const StyledContainer = styled(Box)(({ theme }) => ({
|
|
20
|
+
margin: '20px 0',
|
|
21
|
+
borderBottom: theme.borders.grayLight,
|
|
22
|
+
display: 'flex',
|
|
23
|
+
justifyContent: 'space-between',
|
|
24
|
+
position: 'relative',
|
|
25
|
+
alignItems: 'baseline',
|
|
26
|
+
'& .MuiTypography-root': {
|
|
27
|
+
marginRight: 'auto',
|
|
28
|
+
},
|
|
29
|
+
'&::before': {
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
left: 0,
|
|
32
|
+
bottom: -2,
|
|
33
|
+
borderRadius: '2px',
|
|
34
|
+
content: '""',
|
|
35
|
+
display: 'block',
|
|
36
|
+
width: '60px',
|
|
37
|
+
height: '4px',
|
|
38
|
+
backgroundColor: theme.palette.common.yellow,
|
|
39
|
+
},
|
|
40
|
+
}))
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Close } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
alpha,
|
|
4
|
+
Box,
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogProps,
|
|
8
|
+
IconButton,
|
|
9
|
+
styled,
|
|
10
|
+
Typography,
|
|
11
|
+
} from '@mui/material'
|
|
12
|
+
import { ReactNode } from 'react'
|
|
13
|
+
|
|
14
|
+
const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
15
|
+
height: '64px',
|
|
16
|
+
backgroundColor: alpha(theme.palette.text.secondary, 0.1),
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'space-between',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
padding: '0.6rem 1rem',
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
interface Props extends DialogProps {
|
|
24
|
+
onClose: () => void
|
|
25
|
+
children: ReactNode
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function DialogWrapper({
|
|
29
|
+
title,
|
|
30
|
+
open,
|
|
31
|
+
onClose,
|
|
32
|
+
children,
|
|
33
|
+
...props
|
|
34
|
+
}: Props) {
|
|
35
|
+
return (
|
|
36
|
+
<Dialog
|
|
37
|
+
fullWidth
|
|
38
|
+
maxWidth="md"
|
|
39
|
+
sx={{
|
|
40
|
+
zIndex: 500,
|
|
41
|
+
minHeight: '70vh',
|
|
42
|
+
}}
|
|
43
|
+
onClose={onClose}
|
|
44
|
+
open={open}
|
|
45
|
+
{...props}
|
|
46
|
+
PaperProps={{
|
|
47
|
+
sx: {
|
|
48
|
+
borderRadius: '10px',
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<StyledDialogHeader>
|
|
53
|
+
<Typography fontWeight={600}>{title}</Typography>
|
|
54
|
+
<IconButton onClick={onClose}>
|
|
55
|
+
<Close />
|
|
56
|
+
</IconButton>
|
|
57
|
+
</StyledDialogHeader>
|
|
58
|
+
<DialogContent sx={{ padding: '20px' }}>
|
|
59
|
+
<>{children}</>
|
|
60
|
+
</DialogContent>
|
|
61
|
+
</Dialog>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Close } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
alpha,
|
|
4
|
+
Box,
|
|
5
|
+
Drawer,
|
|
6
|
+
IconButton,
|
|
7
|
+
styled,
|
|
8
|
+
Typography,
|
|
9
|
+
} from '@mui/material'
|
|
10
|
+
|
|
11
|
+
const StyledDrawerHeader = styled(Box)(({ theme }) => ({
|
|
12
|
+
height: '64px',
|
|
13
|
+
backgroundColor: alpha(theme.palette.text.secondary, 0.1),
|
|
14
|
+
display: 'flex',
|
|
15
|
+
justifyContent: 'space-between',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
padding: '0.6rem 1rem',
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
const StyledDrawerContent = styled(Box)(({ theme }) => ({
|
|
21
|
+
padding: '1rem',
|
|
22
|
+
height: 'calc(100vh - 64px)',
|
|
23
|
+
overflowY: 'auto',
|
|
24
|
+
paddingBottom: '4rem',
|
|
25
|
+
}))
|
|
26
|
+
|
|
27
|
+
export const DrawerTemplate = ({ handleClose, modal, setModal }) => {
|
|
28
|
+
return (
|
|
29
|
+
<Drawer
|
|
30
|
+
anchor="right"
|
|
31
|
+
elevation={10}
|
|
32
|
+
onClose={handleClose}
|
|
33
|
+
open={modal.open}
|
|
34
|
+
sx={{
|
|
35
|
+
zIndex: 500,
|
|
36
|
+
'& .MuiDrawer-paper': {
|
|
37
|
+
boxSizing: 'border-box',
|
|
38
|
+
width: 600,
|
|
39
|
+
},
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<StyledDrawerHeader>
|
|
43
|
+
<Typography fontWeight={600}>{modal.title}</Typography>
|
|
44
|
+
<IconButton onClick={() => setModal({ ...modal, open: false })}>
|
|
45
|
+
<Close />
|
|
46
|
+
</IconButton>
|
|
47
|
+
</StyledDrawerHeader>
|
|
48
|
+
<StyledDrawerContent>
|
|
49
|
+
{modal.content({ close: handleClose })}
|
|
50
|
+
</StyledDrawerContent>
|
|
51
|
+
</Drawer>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createContext, useContext, useState } from 'react'
|
|
2
|
+
import { DrawerTemplate } from './DrawerTemplate'
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
title: string
|
|
6
|
+
modalType?: 'dialog' | 'drawer'
|
|
7
|
+
content: ({ close }: { close: () => void }) => any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ContextType = (props: IProps) => void
|
|
11
|
+
|
|
12
|
+
const DialogContext = createContext<ContextType>(null)
|
|
13
|
+
|
|
14
|
+
export default function DialogProvider({ children }) {
|
|
15
|
+
const [modal, setModal] = useState({
|
|
16
|
+
title: '',
|
|
17
|
+
open: false,
|
|
18
|
+
content: ({ close }) => null,
|
|
19
|
+
modalType: 'drawer',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const handleClose = () => {
|
|
23
|
+
setModal({
|
|
24
|
+
...modal,
|
|
25
|
+
open: false,
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const showModal = (props) => {
|
|
30
|
+
setModal({
|
|
31
|
+
...modal,
|
|
32
|
+
open: true,
|
|
33
|
+
title: props.title,
|
|
34
|
+
content: props.content,
|
|
35
|
+
// modalType: props.modalType ?? 'drawer',
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<DialogContext.Provider value={showModal}>
|
|
41
|
+
{children}
|
|
42
|
+
<>
|
|
43
|
+
<DrawerTemplate
|
|
44
|
+
handleClose={handleClose}
|
|
45
|
+
modal={modal}
|
|
46
|
+
setModal={setModal}
|
|
47
|
+
/>
|
|
48
|
+
</>
|
|
49
|
+
</DialogContext.Provider>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const useModal = () => useContext(DialogContext)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { KeyboardArrowDown, MoreVert } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Button,
|
|
5
|
+
ButtonProps,
|
|
6
|
+
CircularProgress,
|
|
7
|
+
IconButton,
|
|
8
|
+
IconButtonProps,
|
|
9
|
+
ListItemIcon,
|
|
10
|
+
ListItemText,
|
|
11
|
+
Menu,
|
|
12
|
+
MenuItem,
|
|
13
|
+
MenuListProps,
|
|
14
|
+
MenuProps,
|
|
15
|
+
styled,
|
|
16
|
+
} from '@mui/material'
|
|
17
|
+
import { ReactNode, useState } from 'react'
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
label?: string
|
|
21
|
+
icon?: {
|
|
22
|
+
icon: ReactNode
|
|
23
|
+
iconProps?: IconButtonProps
|
|
24
|
+
outlined?: boolean
|
|
25
|
+
}
|
|
26
|
+
loading?: boolean
|
|
27
|
+
menu?: {
|
|
28
|
+
label: string | ReactNode
|
|
29
|
+
icon?: ReactNode
|
|
30
|
+
onClick: (props?: any) => any
|
|
31
|
+
}[]
|
|
32
|
+
buttonProps?: ButtonProps
|
|
33
|
+
menuProps?: Omit<MenuProps, 'open'>
|
|
34
|
+
menuListProps?: MenuListProps
|
|
35
|
+
renderMenuItems?: Array<ReactNode>
|
|
36
|
+
}
|
|
37
|
+
const defaultIcon = {
|
|
38
|
+
icon: <MoreVert color="primary" />,
|
|
39
|
+
outlined: true,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default function DropDownButton({
|
|
43
|
+
label,
|
|
44
|
+
icon = defaultIcon,
|
|
45
|
+
menu = [],
|
|
46
|
+
buttonProps,
|
|
47
|
+
menuProps,
|
|
48
|
+
menuListProps,
|
|
49
|
+
loading = false,
|
|
50
|
+
renderMenuItems = [],
|
|
51
|
+
}: Props) {
|
|
52
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
|
|
53
|
+
const open = Boolean(anchorEl)
|
|
54
|
+
|
|
55
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
56
|
+
setAnchorEl(event.currentTarget)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const handleClose = () => {
|
|
60
|
+
setAnchorEl(null)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{!label ? (
|
|
66
|
+
<StyledIconButton
|
|
67
|
+
outlined={icon?.outlined ?? false}
|
|
68
|
+
onClick={handleClick}
|
|
69
|
+
{...icon.iconProps}
|
|
70
|
+
>
|
|
71
|
+
{icon.icon}
|
|
72
|
+
</StyledIconButton>
|
|
73
|
+
) : (
|
|
74
|
+
<StyledDropDownButton
|
|
75
|
+
onClick={handleClick}
|
|
76
|
+
disabled={loading}
|
|
77
|
+
endIcon={
|
|
78
|
+
loading ? (
|
|
79
|
+
<CircularProgress size="20px" thickness={1.7} />
|
|
80
|
+
) : (
|
|
81
|
+
<KeyboardArrowDown />
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
{...buttonProps}
|
|
85
|
+
>
|
|
86
|
+
{label}
|
|
87
|
+
</StyledDropDownButton>
|
|
88
|
+
)}
|
|
89
|
+
<Menu
|
|
90
|
+
elevation={3}
|
|
91
|
+
id="basic-menu"
|
|
92
|
+
anchorEl={anchorEl}
|
|
93
|
+
open={open}
|
|
94
|
+
onClose={handleClose}
|
|
95
|
+
MenuListProps={{ sx: { padding: 0 }, ...menuListProps }}
|
|
96
|
+
anchorOrigin={{
|
|
97
|
+
vertical: 'bottom',
|
|
98
|
+
horizontal: 'right',
|
|
99
|
+
}}
|
|
100
|
+
transformOrigin={{
|
|
101
|
+
vertical: 'top',
|
|
102
|
+
horizontal: 'right',
|
|
103
|
+
}}
|
|
104
|
+
{...menuProps}
|
|
105
|
+
>
|
|
106
|
+
<RenderMenuItems
|
|
107
|
+
menu={menu}
|
|
108
|
+
renderMenuItems={renderMenuItems}
|
|
109
|
+
handleClose={handleClose}
|
|
110
|
+
/>
|
|
111
|
+
</Menu>
|
|
112
|
+
</>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const RenderMenuItems = ({ renderMenuItems, menu, handleClose }) => {
|
|
117
|
+
if (renderMenuItems?.length) {
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
{renderMenuItems.map((Item, index) => (
|
|
121
|
+
<StyledMenuItem
|
|
122
|
+
disableRipple
|
|
123
|
+
sx={{
|
|
124
|
+
minWidth: '120px',
|
|
125
|
+
width: '100%',
|
|
126
|
+
padding: 0,
|
|
127
|
+
'&:hover': { background: 'none' },
|
|
128
|
+
}}
|
|
129
|
+
key={index}
|
|
130
|
+
>
|
|
131
|
+
{Item}
|
|
132
|
+
</StyledMenuItem>
|
|
133
|
+
))}
|
|
134
|
+
</>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
if (menu?.length) {
|
|
138
|
+
return (
|
|
139
|
+
<>
|
|
140
|
+
{menu.map((item, index) => (
|
|
141
|
+
<StyledMenuItem
|
|
142
|
+
sx={{ minWidth: '120px', width: '100%' }}
|
|
143
|
+
key={index}
|
|
144
|
+
onClick={() => {
|
|
145
|
+
handleClose()
|
|
146
|
+
item.onClick()
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
|
|
150
|
+
<ListItemText>{item.label}</ListItemText>
|
|
151
|
+
</StyledMenuItem>
|
|
152
|
+
))}
|
|
153
|
+
</>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const StyledIconButton = styled(IconButton, {
|
|
159
|
+
shouldForwardProp: (prop) => prop !== 'outlined',
|
|
160
|
+
})<{ outlined?: boolean }>(({ theme, outlined }) => ({
|
|
161
|
+
...(outlined && {
|
|
162
|
+
border: `1px solid ${theme.palette.primary.main}`,
|
|
163
|
+
borderRadius: '5px',
|
|
164
|
+
}),
|
|
165
|
+
}))
|
|
166
|
+
|
|
167
|
+
const StyledMenuItem = styled(MenuItem)(({}) => ({
|
|
168
|
+
display: 'flex',
|
|
169
|
+
alignItems: 'center',
|
|
170
|
+
'& .MuiListItemIcon-root': {
|
|
171
|
+
minWidth: '24px',
|
|
172
|
+
},
|
|
173
|
+
'& .MuiSvgIcon-root': {
|
|
174
|
+
height: '18px',
|
|
175
|
+
width: '18px',
|
|
176
|
+
},
|
|
177
|
+
'& .MuiTypography-root': {
|
|
178
|
+
fontWeight: 600,
|
|
179
|
+
},
|
|
180
|
+
}))
|
|
181
|
+
|
|
182
|
+
const StyledDropDownButton = styled(Button)(({}) => ({
|
|
183
|
+
padding: '0 14px',
|
|
184
|
+
}))
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export default class ErrorBoundary extends React.Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props)
|
|
6
|
+
this.state = { hasError: false, error: null, errorInfo: null }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static getDerivedStateFromError(error) {
|
|
10
|
+
// Update state so the next render will show the fallback UI.
|
|
11
|
+
return { hasError: true }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
componentDidCatch(error, errorInfo) {
|
|
15
|
+
// You can also log the error to an error reporting service
|
|
16
|
+
console.log(error)
|
|
17
|
+
console.log(errorInfo)
|
|
18
|
+
this.setState({
|
|
19
|
+
...this.state,
|
|
20
|
+
error,
|
|
21
|
+
errorInfo,
|
|
22
|
+
})
|
|
23
|
+
// logErrorToMyService(error, errorInfo);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render() {
|
|
27
|
+
if (this.state.hasError) {
|
|
28
|
+
// You can render any custom fallback UI
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
<h1>Something went wrong.</h1>
|
|
32
|
+
{this.state.error && (
|
|
33
|
+
<div>
|
|
34
|
+
<pre>Error: {this.state.error.message}</pre>
|
|
35
|
+
<pre>{this.state.errorInfo.componentStack}</pre>
|
|
36
|
+
<pre>{this.state.error.stack}</pre>
|
|
37
|
+
</div>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return this.props.children
|
|
44
|
+
}
|
|
45
|
+
}
|