mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add elements
This commit is contained in:
parent
938cfcb4b3
commit
6f2cc5bdc6
23 changed files with 241 additions and 104 deletions
39
front/components/modals/CourseEdit/NewElement.tsx
Normal file
39
front/components/modals/CourseEdit/NewElement.tsx
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import React, { useState } from "react";
|
||||
import Modal from "../Modal";
|
||||
|
||||
function NewElementModal({ closeModal, submitElement, chapterId }: any) {
|
||||
const [elementName, setElementName] = useState("");
|
||||
const [elementDescription, setElementDescription] = useState("");
|
||||
|
||||
const handleElementNameChange = (e: any) => {
|
||||
setElementName(e.target.value);
|
||||
};
|
||||
|
||||
const handleElementDescriptionChange = (e: any) => {
|
||||
setElementDescription(e.target.value);
|
||||
};
|
||||
|
||||
const handleSubmit = async (e: any) => {
|
||||
e.preventDefault();
|
||||
console.log({ elementName, elementDescription, chapterId });
|
||||
submitElement({
|
||||
name: elementName,
|
||||
chapterId: chapterId,
|
||||
type: "dynamic",
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal>
|
||||
<h1>
|
||||
Add New Element <button onClick={closeModal}>X</button>
|
||||
</h1>
|
||||
<input type="text" onChange={handleElementNameChange} placeholder="Element Name" /> <br />
|
||||
<input type="text" onChange={handleElementDescriptionChange} placeholder="Element Description" />
|
||||
<br />
|
||||
<button onClick={handleSubmit}>Add Element</button>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
export default NewElementModal;
|
||||
Loading…
Add table
Add a link
Reference in a new issue