From 594784e77a1578822301849e5f1eec7891500cb1 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Fri, 22 Nov 2024 13:25:41 +0100 Subject: [PATCH] fix removing custom profile image bug --- .../Profile/Subcomponents/GroupSubheaderForm.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx b/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx index cd4084dd..afd43c2f 100644 --- a/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx +++ b/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx @@ -30,13 +30,16 @@ export const GroupSubheaderForm = ({ useEffect(() => { if (groupTypes && groupStates) { const groupType = groupTypes.find((gt) => gt.groupTypes_id.name === state.group_type) - // eslint-disable-next-line no-console - console.log(state.group_type) + const customImage = !groupTypes.some( + (gt) => gt.groupTypes_id.image === state.image || !state.image, + ) setState((prevState) => ({ ...prevState, color: groupType?.groupTypes_id.color || groupTypes[0].groupTypes_id.color, marker_icon: groupType?.groupTypes_id.markerIcon || groupTypes[0].groupTypes_id.markerIcon, - image: groupType?.groupTypes_id.image || groupTypes[0].groupTypes_id.image, + image: customImage + ? state.image + : groupType?.groupTypes_id.image || groupTypes[0].groupTypes_id.image, status: state.status || groupStates[0], group_type: state.group_type || groupTypes[0].groupTypes_id.name, }))