Web:Client:Removed function from render.

This commit is contained in:
Vlada Gazizova 2022-11-23 10:53:37 +03:00
parent cfcf747466
commit 9560bf0923

View File

@ -160,11 +160,11 @@ const Appearance = (props) => {
}, []);
useEffect(() => {
const colorCheckImg = appearanceTheme.find(
(theme) => theme.id == selectThemeId
).text.accent;
onColorCheck(appearanceTheme);
}, [appearanceTheme]);
setColorCheckImg(colorCheckImg);
useEffect(() => {
onColorCheck(appearanceTheme);
if (appearanceTheme.find((theme) => theme.id == selectThemeId).name) {
setIsDisabledEditButton(true);
@ -215,6 +215,16 @@ const Appearance = (props) => {
previewAccent,
]);
const onColorCheck = useCallback(
(themes) => {
const colorCheckImg = themes.find((theme) => theme.id == selectThemeId)
?.text.accent;
setColorCheckImg(colorCheckImg);
},
[selectThemeId]
);
const onColorCheckImgHover = useCallback(
(e) => {
const id = e.target.id;
@ -241,18 +251,6 @@ const Appearance = (props) => {
setSelectThemeId(item.id);
};
const onShowCheck = useCallback(
(colorNumber) => {
return (
selectThemeId &&
selectThemeId === colorNumber && (
<ReactSVG className="check-img" src={checkImg} />
)
);
},
[selectThemeId]
);
const onSave = useCallback(async () => {
setIsDisabledSaveButton(true);
@ -307,6 +305,7 @@ const Appearance = (props) => {
}
}, [
selectThemeId,
selectedThemeId,
setVisibleDialog,
deleteAppearanceTheme,
getAppearanceTheme,
@ -585,7 +584,9 @@ const Appearance = (props) => {
onClick={() => onColorSelection(item)}
onMouseOver={onColorCheckImgHover}
>
{onShowCheck(item.id)}
{selectThemeId === item.id && (
<ReactSVG className="check-img" src={checkImg} />
)}
{selectThemeId !== item.id && checkImgHover}
</StyledTheme>
@ -610,8 +611,9 @@ const Appearance = (props) => {
onClick={() => onColorSelection(item)}
onMouseOver={onColorCheckImgHover}
>
{onShowCheck(item.id)}
{selectThemeId === item.id && (
<ReactSVG className="check-img" src={checkImg} />
)}
{selectThemeId !== item.id && checkImgHover}
</StyledTheme>
);