Replace useless ternarys with logical ANDs

This commit is contained in:
Isaac Wise
2024-07-22 22:34:36 -05:00
parent 2264abd384
commit e79b98d3b0
25 changed files with 195 additions and 212 deletions
+2 -2
View File
@@ -72,7 +72,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
<div className="divider mb-3 mt-1"></div>
{link.url ? (
{link.url && (
<Link
href={link.url}
className="truncate text-neutral flex gap-2 mb-5 w-fit max-w-full"
@@ -82,7 +82,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
<i className="bi-link-45deg text-xl" />
<p>{shortenedURL}</p>
</Link>
) : undefined}
)}
<div className="w-full">
<p className="mb-2">{t("name")}</p>
+2 -2
View File
@@ -128,7 +128,7 @@ export default function NewLinkModal({ onClose }: Props) {
</div>
</div>
<div className={"mt-2"}>
{optionsExpanded ? (
{optionsExpanded && (
<div className="mt-5">
<div className="grid sm:grid-cols-2 gap-3">
<div>
@@ -163,7 +163,7 @@ export default function NewLinkModal({ onClose }: Props) {
</div>
</div>
</div>
) : undefined}
)}
</div>
<div className="flex justify-between items-center mt-5">
<div
+2 -2
View File
@@ -86,7 +86,7 @@ export default function NewUserModal({ onClose }: Props) {
/>
</div>
{emailEnabled ? (
{emailEnabled && (
<div>
<p className="mb-2">{t("email")}</p>
<TextInput
@@ -96,7 +96,7 @@ export default function NewUserModal({ onClose }: Props) {
value={form.email}
/>
</div>
) : undefined}
)}
<div>
<p className="mb-2">
@@ -150,16 +150,16 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
<p className="text-xl font-thin">{t("preserved_formats")}</p>
<div className="divider mb-2 mt-1"></div>
{screenshotAvailable(link) ||
pdfAvailable(link) ||
readabilityAvailable(link) ||
monolithAvailable(link) ? (
pdfAvailable(link) ||
readabilityAvailable(link) ||
monolithAvailable(link) ? (
<p className="mb-3">{t("available_formats")}</p>
) : (
""
)}
<div className={`flex flex-col gap-3`}>
{monolithAvailable(link) ? (
{monolithAvailable(link) && (
<PreservedFormatRow
name={t("webpage")}
icon={"bi-filetype-html"}
@@ -167,9 +167,9 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
activeLink={link}
downloadable={true}
/>
) : undefined}
)}
{screenshotAvailable(link) ? (
{screenshotAvailable(link) && (
<PreservedFormatRow
name={t("screenshot")}
icon={"bi-file-earmark-image"}
@@ -181,9 +181,9 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
activeLink={link}
downloadable={true}
/>
) : undefined}
)}
{pdfAvailable(link) ? (
{pdfAvailable(link) && (
<PreservedFormatRow
name={t("pdf")}
icon={"bi-file-earmark-pdf"}
@@ -191,16 +191,16 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
activeLink={link}
downloadable={true}
/>
) : undefined}
)}
{readabilityAvailable(link) ? (
{readabilityAvailable(link) && (
<PreservedFormatRow
name={t("readable")}
icon={"bi-file-earmark-text"}
format={ArchivedFormat.readability}
activeLink={link}
/>
) : undefined}
)}
{!isReady() && !atLeastOneFormatAvailable() ? (
<div className={`w-full h-full flex flex-col justify-center p-10`}>
@@ -213,7 +213,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
<p className="text-center text-2xl">{t("preservation_in_queue")}</p>
<p className="text-center text-lg">{t("check_back_later")}</p>
</div>
) : !isReady() && atLeastOneFormatAvailable() ? (
) : !isReady() && atLeastOneFormatAvailable() && (
<div className={`w-full h-full flex flex-col justify-center p-5`}>
<BeatLoader
color="oklch(var(--p))"
@@ -223,12 +223,11 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
<p className="text-center">{t("there_are_more_formats")}</p>
<p className="text-center text-sm">{t("check_back_later")}</p>
</div>
) : undefined}
)}
<div
className={`flex flex-col sm:flex-row gap-3 items-center justify-center ${
isReady() ? "sm:mt " : ""
}`}
className={`flex flex-col sm:flex-row gap-3 items-center justify-center ${isReady() ? "sm:mt " : ""
}`}
>
<Link
href={`https://web.archive.org/web/${link?.url?.replace(
+4 -4
View File
@@ -157,7 +157,7 @@ export default function UploadFileModal({ onClose }: Props) {
</div>
<div className="sm:col-span-2 col-span-5">
<p className="mb-2">{t("collection")}</p>
{link.collection.name ? (
{link.collection.name && (
<CollectionSelection
onChange={setCollection}
defaultValue={{
@@ -165,10 +165,10 @@ export default function UploadFileModal({ onClose }: Props) {
value: link.collection.id,
}}
/>
) : null}
)}
</div>
</div>
{optionsExpanded ? (
{optionsExpanded && (
<div className="mt-5">
<div className="grid sm:grid-cols-2 gap-3">
<div>
@@ -203,7 +203,7 @@ export default function UploadFileModal({ onClose }: Props) {
</div>
</div>
</div>
) : undefined}
)}
<div className="flex justify-between items-center mt-5">
<div
onClick={() => setOptionsExpanded(!optionsExpanded)}