-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathEditTemplateModal.tsx
More file actions
74 lines (67 loc) · 2.07 KB
/
EditTemplateModal.tsx
File metadata and controls
74 lines (67 loc) · 2.07 KB
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
import {
Button,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
useColorModeValue,
Textarea,
Text
} from "@chakra-ui/react";
import { useState, useEffect } from "react";
import { DARK_GRAY_COLOR, DARK_HOVER_COLOR } from "../../utils/constants";
interface EditTemplateModalProps {
isModalOpen: boolean;
setIsModalOpen: (value: boolean) => void;
handleConfirm: (newTemplate: string) => void;
template: string | undefined;
assignmentName: string;
}
/** Used when a staff wants to edit the template associated with an assignment or lab */
const EditTemplateModal = (props: EditTemplateModalProps) => {
const { isModalOpen, setIsModalOpen, handleConfirm, template, assignmentName } = props;
const [tempTemplate, setTempTemplate] = useState(template);
useEffect(() => {
setTempTemplate(template);
}, [isModalOpen, template]);
return (
<Modal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)}>
<ModalContent
backgroundColor={useColorModeValue("", DARK_GRAY_COLOR)}
boxShadow={`0 0 1px 2px ${DARK_HOVER_COLOR}`}
>
<ModalHeader>Edit Template for {assignmentName}</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Text>
Include "[this test]" or "[this concept]" as mandatory placeholders for students to fill.
</Text>
<Textarea
value={tempTemplate}
onChange={(e) => setTempTemplate(e.target.value)}
placeholder="Fill in template here"
mt={2}
/>
</ModalBody>
<ModalFooter>
<Button variant="ghost" mr={3} onClick={() => setIsModalOpen(false)}>
Cancel
</Button>
<Button
colorScheme="blue"
mr={3}
onClick={() => {
handleConfirm(tempTemplate ?? "");
setIsModalOpen(false);
}}
>
Confirm
</Button>
</ModalFooter>
</ModalContent>
</Modal>
);
};
export default EditTemplateModal;