From 7610b12ac09f66ab421bce71256b72edc844746f Mon Sep 17 00:00:00 2001 From: vargajoe Date: Tue, 26 Sep 2023 15:14:51 +0200 Subject: [PATCH] undo refactor icon conditions --- .../reference-grid/reference-picker.tsx | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx b/packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx index 28264d128..efbdb2444 100644 --- a/packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx +++ b/packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx @@ -47,28 +47,25 @@ export const ReferencePicker: React.FC { - if (props.repository.schemas.isContentFromType(item, 'User')) { - const avatarUrl = item.Avatar?.Url - if (avatarUrl) { - return - } - - return ( + const renderIcon = (item: GenericContentWithIsParent | User) => + props.repository.schemas.isContentFromType(item, 'User') ? ( + (item as User).Avatar?.Url ? ( + + ) : ( {item.DisplayName?.split(' ') .map((namePart) => namePart[0]) .join('.')} ) - } - - if (props.renderIcon) { - return props.renderIcon(item) - } - - return renderIconDefault(iconName(item.IsFolder)) - } + ) : props.renderIcon ? ( + props.renderIcon(item) + ) : ( + renderIconDefault(iconName(item.IsFolder)) + ) return (