editSummary

This commit is contained in:
Mikola 2023-11-30 16:42:50 +03:00
parent c514062efe
commit ca2e917fc4

View File

@ -1,8 +1,8 @@
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import { CKEditor } from "@ckeditor/ckeditor5-react";
import React, { useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { Navigate } from "react-router-dom";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import { CKEditor } from "@ckeditor/ckeditor5-react";
import { getProfileInfo } from "@redux/outstaffingSlice";
@ -29,8 +29,8 @@ export const Summary = () => {
const profileInfo = useSelector(getProfileInfo);
const [openGit, setOpenGit] = useState(false);
const [gitInfo, setGitInfo] = useState([]);
const [editSummeryOpen, setEditSummeryOpen] = useState(false)
const [summery, setSummery] = useState('')
const [editSummeryOpen, setEditSummeryOpen] = useState(false);
const [summery, setSummery] = useState("");
useEffect(() => {
apiRequest(
@ -39,18 +39,16 @@ export const Summary = () => {
}, []);
useEffect(() => {
setSummery(profileInfo.vc_text)
}, [profileInfo])
setSummery(profileInfo.vc_text);
}, [profileInfo]);
function editSummery() {
apiRequest("/resume/edit-text", {
method: "PUT",
data: {
resume: summery
resume: summery,
},
}).then(() => {
});
}).then(() => {});
}
return (
<div className="summary">
@ -120,16 +118,19 @@ export const Summary = () => {
<div className="experience__block">
<div className="summary__sections__head">
<h3>Описание опыта работы</h3>
<button className={editSummeryOpen ? 'edit' : ''} onClick={() => {
<button
className={editSummeryOpen ? "edit" : ""}
onClick={() => {
if (editSummeryOpen) {
editSummery()
editSummery();
}
setEditSummeryOpen(!editSummeryOpen)
}}>{
editSummeryOpen ? 'Сохранить' : 'Редактировать раздел'
}</button>
setEditSummeryOpen(!editSummeryOpen);
}}
>
{editSummeryOpen ? "Сохранить" : "Редактировать раздел"}
</button>
</div>
{editSummeryOpen ?
{editSummeryOpen ? (
<CKEditor
editor={ClassicEditor}
data={summery}
@ -152,13 +153,12 @@ export const Summary = () => {
setSummery(data);
}}
/>
:
) : (
<div
className="experience__content"
dangerouslySetInnerHTML={{ __html: summery }}
>
</div>
}
></div>
)}
</div>
</div>
)}