editSummary

This commit is contained in:
Mikola 2023-11-30 16:42:24 +03:00
parent 690daba9d5
commit c514062efe
2 changed files with 71 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { Navigate } from "react-router-dom"; import { Navigate } from "react-router-dom";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import { CKEditor } from "@ckeditor/ckeditor5-react";
import { getProfileInfo } from "@redux/outstaffingSlice"; import { getProfileInfo } from "@redux/outstaffingSlice";
@ -27,12 +29,29 @@ export const Summary = () => {
const profileInfo = useSelector(getProfileInfo); const profileInfo = useSelector(getProfileInfo);
const [openGit, setOpenGit] = useState(false); const [openGit, setOpenGit] = useState(false);
const [gitInfo, setGitInfo] = useState([]); const [gitInfo, setGitInfo] = useState([]);
const [editSummeryOpen, setEditSummeryOpen] = useState(false)
const [summery, setSummery] = useState('')
useEffect(() => { useEffect(() => {
apiRequest( apiRequest(
`/profile/portfolio-projects?card_id=${localStorage.getItem("cardId")}` `/profile/portfolio-projects?card_id=${localStorage.getItem("cardId")}`
).then((responseGit) => setGitInfo(responseGit)); ).then((responseGit) => setGitInfo(responseGit));
}, []); }, []);
useEffect(() => {
setSummery(profileInfo.vc_text)
}, [profileInfo])
function editSummery() {
apiRequest("/resume/edit-text", {
method: "PUT",
data: {
resume: summery
},
}).then(() => {
});
}
return ( return (
<div className="summary"> <div className="summary">
<ProfileHeader /> <ProfileHeader />
@ -101,12 +120,45 @@ export const Summary = () => {
<div className="experience__block"> <div className="experience__block">
<div className="summary__sections__head"> <div className="summary__sections__head">
<h3>Описание опыта работы</h3> <h3>Описание опыта работы</h3>
<button>Редактировать раздел</button> <button className={editSummeryOpen ? 'edit' : ''} onClick={() => {
if (editSummeryOpen) {
editSummery()
}
setEditSummeryOpen(!editSummeryOpen)
}}>{
editSummeryOpen ? 'Сохранить' : 'Редактировать раздел'
}</button>
</div> </div>
<div {editSummeryOpen ?
className="experience__content" <CKEditor
dangerouslySetInnerHTML={{ __html: profileInfo.vc_text }} editor={ClassicEditor}
></div> data={summery}
config={{
removePlugins: [
"CKFinderUploadAdapter",
"CKFinder",
"EasyImage",
"Image",
"ImageCaption",
"ImageStyle",
"ImageToolbar",
"ImageUpload",
"MediaEmbed",
"BlockQuote",
],
}}
onChange={(event, editor) => {
const data = editor.getData();
setSummery(data);
}}
/>
:
<div
className="experience__content"
dangerouslySetInnerHTML={{ __html: summery }}
>
</div>
}
</div> </div>
</div> </div>
)} )}

View File

@ -220,6 +220,11 @@
white-space: nowrap; white-space: nowrap;
} }
} }
.edit {
background-color: green;
color: white;
}
} }
.skills__section { .skills__section {
@ -287,6 +292,15 @@
} }
} }
.ck-toolbar {
border: none !important;
}
.ck-content {
border: none !important;
padding: 15px 35px 15px 50px !important;
}
&__sectionGit { &__sectionGit {
margin-top: 25px; margin-top: 25px;