Skip to content

Commit

Permalink
Merge pull request #1287 from ita-social-projects/feature/issue-1463
Browse files Browse the repository at this point in the history
Feature/issue 1463
  • Loading branch information
NastiaVeret authored Jun 6, 2024
2 parents 99efb3f + dbae607 commit 4a315de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,13 @@ const NewStreetcode = () => {
id: inputInfo?.id ?? 0,
title: inputInfo?.title,
textContent: inputInfo?.textContent ?? " ",
additionalText: inputInfo?.additionalText === '<p>Текст підготовлений спільно з</p>'
? '' : inputInfo?.additionalText,
additionalText:
inputInfo?.textContent !== "<p><br></p>"
? inputInfo?.additionalText ===
"<p>Текст підготовлений спільно з</p>"
? ""
: inputInfo?.additionalText
: "",
streetcodeId: parseId,
};
validateQuillTexts(text.textContent, text.additionalText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/jsx-props-no-multi-spaces */

import { observer } from 'mobx-react-lite';
import { useRef } from 'react';
import { useEffect, useRef, useState } from 'react';
import ReactQuill from 'react-quill';

import FormItem from 'antd/es/form/FormItem';
Expand All @@ -23,9 +23,20 @@ const AdditionalTextBlockAdminForm = ({
}: Props) => {
const maxLength = character_limit || 200;
const editorRef = useRef<ReactQuill | null>(null);
const [isTextContentEmpty, setIsTextContentEmpty] = useState(true);
const [isTitleEmpty, setIsTitleEmpty] = useState(true);

useEffect(() => {
setIsTextContentEmpty(!inputInfo?.textContent || inputInfo.textContent === "<p><br></p>");
}, [inputInfo?.textContent]);

useEffect(() => {
setIsTitleEmpty(!inputInfo?.title || inputInfo.title === "");
}, [inputInfo?.title]);

return (
<FormItem label="Авторство">
<div className={isTextContentEmpty || isTitleEmpty ? "disabled" : ""}>
<Editor
qRef={editorRef}
value={(text === undefined || text === '') ? 'Текст підготовлений спільно з' : text}
Expand All @@ -34,7 +45,9 @@ const AdditionalTextBlockAdminForm = ({
onChange('additionalText', editor);
}}
maxChars={maxLength}
readOnly={isTitleEmpty || isTextContentEmpty}
/>
</div>
</FormItem>
);
};
Expand Down

0 comments on commit 4a315de

Please sign in to comment.