|
@@ -3,10 +3,12 @@ import { connect } from "react-redux";
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
|
import { actionSnippetById } from "store/actions/actionSnippetById";
|
|
|
+import { actionSnippetAdd } from "store/actions/actionSnippetAdd";
|
|
|
import { Editor } from "components/Editor";
|
|
|
import "components/EditorsPage.css";
|
|
|
|
|
|
const MyProjectSnippet = ({
|
|
|
+ onSave,
|
|
|
getSnippet,
|
|
|
match: {
|
|
|
params: { id },
|
|
@@ -65,13 +67,35 @@ const MyProjectSnippet = ({
|
|
|
<Editor
|
|
|
data={data}
|
|
|
onChange={({ type, name, text }) =>
|
|
|
- setFiles([...files.slice(0, index), { type, name, text }, ...files.slice(index, 1)])
|
|
|
+ setFiles([...files.slice(0, index), { type, name, text }, ...files.slice(index, 1)])
|
|
|
}
|
|
|
/>
|
|
|
</>
|
|
|
))}
|
|
|
<br />
|
|
|
<div>
|
|
|
+ <div>
|
|
|
+ <button
|
|
|
+ className='button_plus'
|
|
|
+ onClick={newArray => {
|
|
|
+ let editors2 = [...files];
|
|
|
+ editors2.push(newArray);
|
|
|
+ setFiles(editors2);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ +
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ className='button_plus'
|
|
|
+ onClick={newArray => {
|
|
|
+ let editors2 = [...files];
|
|
|
+ editors2.pop(newArray);
|
|
|
+ setFiles(editors2);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ -
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
<div>
|
|
|
<iframe
|
|
|
className='pane'
|
|
@@ -102,6 +126,11 @@ const MyProjectSnippet = ({
|
|
|
style={{ marginBottom: 50 }}
|
|
|
/>
|
|
|
</div>
|
|
|
+ <div>
|
|
|
+ <button className='button_submit' onClick={() => onSave(title, description, files)}>
|
|
|
+ Submit this Editor
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
);
|
|
|
};
|
|
@@ -112,6 +141,6 @@ const ConnectedMyProject = connect(
|
|
|
descriptionText: state?.promise?.findSnippetById?.payload?.data?.SnippetFind?.[0]?.description,
|
|
|
filesArr: state?.promise?.findSnippetById?.payload?.data?.SnippetFind?.[0]?.files,
|
|
|
}),
|
|
|
- { getSnippet: actionSnippetById },
|
|
|
+ { getSnippet: actionSnippetById, onSave: actionSnippetAdd },
|
|
|
)(MyProjectSnippet);
|
|
|
export default ConnectedMyProject;
|