-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConfirmDeclareModal.tsx
124 lines (119 loc) · 3.08 KB
/
ConfirmDeclareModal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { WarningTwoIcon } from '@chakra-ui/icons';
import {
Box,
Button,
HStack,
Icon,
Modal,
ModalBody,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Text,
useTheme,
VStack,
} from '@chakra-ui/react';
interface ConfirmDeclareModalProps {
isOpen: boolean;
onClose: () => void;
onConfirm: () => void;
isSubmitting: boolean;
lessonDate: string;
hasLessonPlan: boolean;
isWithin14Days: boolean;
}
export const ConfirmDeclareModal: React.FC<ConfirmDeclareModalProps> = ({
isOpen,
onClose,
onConfirm,
isSubmitting,
lessonDate,
hasLessonPlan,
isWithin14Days,
}) => {
const theme = useTheme();
const formattedDate = new Date(lessonDate).toLocaleDateString('en-CA', {
month: 'long',
day: 'numeric',
year: 'numeric',
});
return (
<Modal isOpen={isOpen} onClose={onClose} isCentered>
<ModalOverlay />
<ModalContent
maxW="300px"
height={isWithin14Days ? '200px' : '160px'}
borderRadius="lg"
>
<ModalHeader textAlign="center" fontSize="16px" pb={0} pt={5}>
<Text textStyle="h3">
{hasLessonPlan ? 'Confirm Absence' : 'No Lesson Plan Added'}
</Text>
</ModalHeader>
<ModalBody display="flex" justifyContent="center">
<Box maxW="224px" w="100%">
<VStack align="start" pl={1}>
<Text textStyle="subtitle" color="black">
{hasLessonPlan ? (
<>
Please confirm your absence on{' '}
<strong>{formattedDate}.</strong>
</>
) : (
<>
Declare absence on <strong>{formattedDate}</strong> without
adding a lesson plan?
</>
)}
</Text>
{isWithin14Days && (
<HStack align="center" spacing={3}>
<Icon
as={WarningTwoIcon}
boxSize="20px"
color={theme.colors.warningOrange[300]}
/>
<Text
textStyle="body"
color={theme.colors.warningOrange[300]}
>
You are submitting a late report. Please aim to report
absences at least 14 days in advance.
</Text>
</HStack>
)}
</VStack>
</Box>
</ModalBody>
<ModalFooter
display="flex"
justifyContent="center"
gap={5}
px={0}
pt={0}
>
<Button
onClick={onClose}
flex="1"
maxW="104px"
h="40px"
variant="outline"
>
Back
</Button>
<Button
colorScheme="blue"
onClick={onConfirm}
isLoading={isSubmitting}
flex="1"
maxW="104px"
h="40px"
>
Confirm
</Button>
</ModalFooter>
</ModalContent>
</Modal>
);
};