|
@@ -6,62 +6,34 @@ import { actionSnippetById } from "store/actions/actionSnippetById";
|
|
|
import { Editor } from "components/Editor";
|
|
|
import "components/EditorsPage.css";
|
|
|
|
|
|
-// const [editors, setEditors] = useState(datas);
|
|
|
-// const [title, setTitle] = useState("");
|
|
|
-// const [description, setDescription] = useState("");
|
|
|
-// const [srcDoc, setSrcDoc] = useState("");
|
|
|
-// const [theme, setTheme] = useState();
|
|
|
-// const [font, setFont] = useState();
|
|
|
-
|
|
|
-// useEffect(() => {
|
|
|
-// const timeout = setTimeout(() => {
|
|
|
-// let html, css, javascript;
|
|
|
-// editors.forEach((e) => {
|
|
|
-// if (e.type === "html") html = e.text;
|
|
|
-// if (e.type === "css") css = e.text;
|
|
|
-// if (e.type === "javascript") javascript = e.text;
|
|
|
-// });
|
|
|
-// setSrcDoc(`
|
|
|
-// <html>
|
|
|
-// <body>${html}</body>
|
|
|
-// <style>${css}</style>
|
|
|
-// <script>${javascript}</script>
|
|
|
-// </html>
|
|
|
-// `);
|
|
|
-// }, 250);
|
|
|
-
|
|
|
-// return () => clearTimeout(timeout);
|
|
|
-// }, [editors]);
|
|
|
-
|
|
|
-const ProjectSnippet = ({
|
|
|
+const MyProjectSnippet = ({
|
|
|
getSnippet,
|
|
|
match: {
|
|
|
- params: { _id },
|
|
|
+ params: { id },
|
|
|
},
|
|
|
titleText,
|
|
|
descriptionText,
|
|
|
filesArr,
|
|
|
- nameText,
|
|
|
}) => {
|
|
|
useEffect(() => {
|
|
|
- getSnippet(_id);
|
|
|
- }, [_id, getSnippet]);
|
|
|
- const [editors, setEditors] = useState([]);
|
|
|
+ getSnippet(id);
|
|
|
+ }, [id, getSnippet]);
|
|
|
+ const [files, setFiles] = useState([]);
|
|
|
const [title, setTitle] = useState("");
|
|
|
const [description, setDescription] = useState("");
|
|
|
useEffect(() => {
|
|
|
- setEditors(filesArr);
|
|
|
+ setFiles(filesArr);
|
|
|
setTitle(titleText);
|
|
|
setDescription(descriptionText);
|
|
|
}, [filesArr, titleText, descriptionText]);
|
|
|
const [srcDoc, setSrcDoc] = useState("");
|
|
|
- const html = editors?.filter(e => {
|
|
|
+ const html = files?.filter(e => {
|
|
|
return e?.type === "html";
|
|
|
})[0]?.text;
|
|
|
- const css = editors?.filter(e => {
|
|
|
+ const css = files?.filter(e => {
|
|
|
return e?.type === "css";
|
|
|
})[0]?.text;
|
|
|
- const javascript = editors?.filter(e => {
|
|
|
+ const javascript = files?.filter(e => {
|
|
|
return e?.type === "javascript";
|
|
|
})[0]?.text;
|
|
|
console.log(javascript);
|
|
@@ -81,20 +53,19 @@ const ProjectSnippet = ({
|
|
|
return (
|
|
|
<div>
|
|
|
<div>
|
|
|
- <Link to='/propjects'>
|
|
|
+ <Link to='/projects'>
|
|
|
<button className='btn_search' style={{ margin: 10, marginBottom: 50 }}>
|
|
|
- Back to
|
|
|
+ Back to All Projects
|
|
|
</button>
|
|
|
</Link>
|
|
|
</div>
|
|
|
<br />
|
|
|
- {editors?.map((data, index) => (
|
|
|
+ {files?.map((data, index) => (
|
|
|
<>
|
|
|
<Editor
|
|
|
- onDelete={() => setEditors(editors?.filter(item => item !== data))}
|
|
|
data={data}
|
|
|
onChange={({ type, name, text }) =>
|
|
|
- setEditors([...editors.slice(0, index), { type, name, text }, ...editors.slice(index, 1)])
|
|
|
+ setFiles([...files.slice(0, index), { type, name, text }, ...files.slice(index, 1)])
|
|
|
}
|
|
|
/>
|
|
|
</>
|
|
@@ -135,13 +106,12 @@ const ProjectSnippet = ({
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const ConnectedProject = connect(
|
|
|
+const ConnectedMyProject = connect(
|
|
|
state => ({
|
|
|
titleText: state?.promise?.findSnippetById?.payload?.data?.SnippetFind?.[0]?.title,
|
|
|
descriptionText: state?.promise?.findSnippetById?.payload?.data?.SnippetFind?.[0]?.description,
|
|
|
- nameText: state?.promise?.findSnippetById?.payload?.data?.SnippetFind?.[0]?.name,
|
|
|
filesArr: state?.promise?.findSnippetById?.payload?.data?.SnippetFind?.[0]?.files,
|
|
|
}),
|
|
|
{ getSnippet: actionSnippetById },
|
|
|
-)(ProjectSnippet);
|
|
|
-export default ConnectedProject;
|
|
|
+)(MyProjectSnippet);
|
|
|
+export default ConnectedMyProject;
|