From efb91abd42aa89b1bdceec59f20841737cfffa34 Mon Sep 17 00:00:00 2001 From: Bram Adams <3282661+bramses@users.noreply.github.com> Date: Tue, 10 Sep 2024 02:56:38 -0400 Subject: [PATCH] refactor: Update EntryPage and SearchResults components for improved styling and organization --- src/components/EntryPage.tsx | 242 +++++++++++++++++++++-------------- 1 file changed, 143 insertions(+), 99 deletions(-) diff --git a/src/components/EntryPage.tsx b/src/components/EntryPage.tsx index 272da2b..1026472 100644 --- a/src/components/EntryPage.tsx +++ b/src/components/EntryPage.tsx @@ -163,6 +163,23 @@ const EntryPage = () => { } }; + const renderResultData = (result: any) => { + if (result.parentData) { + return result.parentData.data; + } + if (result.data.split(' ').length > 2200) { + return ( + <> + {splitIntoWords(result.data, 22, 0)}... + + ...{splitIntoWords(result.data, 22, 22)}... + + + ); + } + return result.data; + }; + useEffect(() => { if (!data) { const asyncFn = async () => { @@ -498,111 +515,138 @@ const EntryPage = () => {

Related Entries

{searchResults.map((result) => ( -
-
- -
- favicon - - {result.data.split(' ').length > 12 ? ( - <> - {splitIntoWords(result.data, 12, 0)}... - - ...{splitIntoWords(result.data, 20, 12)}... - - - ) : ( - result.data - )} - -
+ <> +
+
+ +
+ favicon + + {renderResultData(result)} + +
+
+ {result.parentData ? ( +
+ {firstLastName.firstName && firstLastName.lastName ? ( + <> + {firstLastName.firstName[0]} + {firstLastName.lastName[0]} + + ) : ( + 'YCB' + )} +
+ ) : null} + + {result.parentData + ? result.data + : result.parentData && ( + + {result.parentData.data} + + )} + +
+
- {result.parentData && ( - {result.parentData.data} + Created: {new Date(result.createdAt).toLocaleString()} + {result.createdAt !== result.updatedAt && ( + <> + {' '} + | Last Updated:{' '} + {new Date(result.updatedAt).toLocaleString()}{' '} + )}
- - {/* when was the entry created and updated */} -
- Added to yCb: {new Date(result.createdAt).toLocaleString()} - {result.createdAt !== result.updatedAt && ( - <> - {' '} - | Last Updated: {new Date( - result.updatedAt, - ).toLocaleString()}{' '} - - )} + + {toHostname(result.metadata.author)} + +
- + addToCollection( + result.id, + result.data, + buildingCollection, + setBuildingCollection, + setCheckedButtons, + ) + } > - {toHostname(result.metadata.author)} - - + {checkedButtons[result.id] ? ( + + + + ) : ( + + + + )} +
- -
+
+ ))}