From ff31732ba3782a4ea177797fb52866106a4d3982 Mon Sep 17 00:00:00 2001 From: Isaac Wise Date: Sat, 27 Jul 2024 16:17:38 -0500 Subject: [PATCH] remove more ternaries --- components/CollectionCard.tsx | 4 +-- components/Dropdown.tsx | 33 +++++++++---------- .../InputSelect/CollectionSelection.tsx | 10 ++++++ components/ModalContent/EditLinkModal.tsx | 4 +-- components/ModalContent/NewLinkModal.tsx | 4 +-- components/Navbar.tsx | 4 +-- components/ProfileDropdown.tsx | 9 +++-- components/ToggleDarkMode.tsx | 15 +++++---- components/UserListing.tsx | 4 +-- layouts/SettingsLayout.tsx | 4 +-- .../migration/importFromWallabag.ts | 29 ++++++++-------- lib/api/storage/moveFile.ts | 2 +- lib/api/storage/readFile.ts | 8 ++--- pages/admin.tsx | 4 +-- pages/collections/[id].tsx | 4 +-- pages/dashboard.tsx | 8 ++--- pages/public/collections/[id].tsx | 4 +-- 17 files changed, 80 insertions(+), 70 deletions(-) diff --git a/components/CollectionCard.tsx b/components/CollectionCard.tsx index cd7d80e..7ac8371 100644 --- a/components/CollectionCard.tsx +++ b/components/CollectionCard.tsx @@ -148,13 +148,13 @@ export default function CollectionCard({ collection, className }: Props) { ); }) .slice(0, 3)} - {collection.members.length - 3 > 0 ? ( + {collection.members.length - 3 > 0 && (
+{collection.members.length - 3}
- ) : null} + )} { setDropdownHeight(e.height); @@ -69,16 +69,15 @@ export default function Dropdown({ style={ points ? { - position: "fixed", - top: `${pos?.y}px`, - left: `${pos?.x}px`, - } + position: "fixed", + top: `${pos?.y}px`, + left: `${pos?.x}px`, + } : undefined } onClickOutside={onClickOutside} - className={`${ - className || "" - } py-1 shadow-md border border-neutral-content bg-base-200 rounded-md flex flex-col z-20`} + className={`${className || "" + } py-1 shadow-md border border-neutral-content bg-base-200 rounded-md flex flex-col z-20`} > {items.map((e, i) => { const inner = e && ( @@ -102,5 +101,5 @@ export default function Dropdown({ ); })} - ) : null; + ); } diff --git a/components/InputSelect/CollectionSelection.tsx b/components/InputSelect/CollectionSelection.tsx index 37899ee..6354f7e 100644 --- a/components/InputSelect/CollectionSelection.tsx +++ b/components/InputSelect/CollectionSelection.tsx @@ -6,6 +6,16 @@ import { Options } from "./types"; import CreatableSelect from "react-select/creatable"; import Select, { ActionMeta } from "react-select"; +interface Option { + label: string; + value: number; + ownerId: number; + count?: { + links: number; + }; + parentId?: number; +} + type Props = { onChange: (newValue: unknown, actionMeta: ActionMeta) => void; showDefaultValue?: boolean; diff --git a/components/ModalContent/EditLinkModal.tsx b/components/ModalContent/EditLinkModal.tsx index b509aa8..91b9aad 100644 --- a/components/ModalContent/EditLinkModal.tsx +++ b/components/ModalContent/EditLinkModal.tsx @@ -98,7 +98,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {

{t("collection")}

- {link.collection.name ? ( + {link.collection.name && ( - ) : null} + )}
diff --git a/components/ModalContent/NewLinkModal.tsx b/components/ModalContent/NewLinkModal.tsx index 680f9ef..26471a3 100644 --- a/components/ModalContent/NewLinkModal.tsx +++ b/components/ModalContent/NewLinkModal.tsx @@ -116,7 +116,7 @@ export default function NewLinkModal({ onClose }: Props) {

{t("collection")}

- {link.collection.name ? ( + {link.collection.name && ( - ) : null} + )}
diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 888c56b..d4907ac 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -111,7 +111,7 @@ export default function Navbar() { - {sidebar ? ( + {sidebar && (
@@ -119,7 +119,7 @@ export default function Navbar() {
- ) : null} + )} {newLinkModal && ( setNewLinkModal(false)} /> )} diff --git a/components/ProfileDropdown.tsx b/components/ProfileDropdown.tsx index 21ce54e..400969b 100644 --- a/components/ProfileDropdown.tsx +++ b/components/ProfileDropdown.tsx @@ -32,9 +32,8 @@ export default function ProfileDropdown() { />