Merge pull request #678 from IsaacWise06/fixes

General Fixes
This commit is contained in:
Daniel
2024-08-18 16:40:48 -04:00
committed by GitHub
53 changed files with 420 additions and 445 deletions
@@ -1,7 +1,11 @@
import React, { useEffect, useState } from "react";
import TextInput from "@/components/TextInput";
import toast from "react-hot-toast";
import { CollectionIncludingMembersAndLinkCount, Member } from "@/types/global";
import {
AccountSettings,
CollectionIncludingMembersAndLinkCount,
Member,
} from "@/types/global";
import getPublicUserData from "@/lib/client/getPublicUserData";
import usePermissions from "@/hooks/usePermissions";
import ProfilePhoto from "../ProfilePhoto";
@@ -65,15 +69,9 @@ export default function EditCollectionSharingModal({
const [memberUsername, setMemberUsername] = useState("");
const [collectionOwner, setCollectionOwner] = useState({
id: null as unknown as number,
name: "",
username: "",
image: "",
archiveAsScreenshot: undefined as unknown as boolean,
archiveAsMonolith: undefined as unknown as boolean,
archiveAsPDF: undefined as unknown as boolean,
});
const [collectionOwner, setCollectionOwner] = useState<
Partial<AccountSettings>
>({});
useEffect(() => {
const fetchOwner = async () => {
@@ -133,7 +131,7 @@ export default function EditCollectionSharingModal({
</div>
)}
{collection.isPublic ? (
{collection.isPublic && (
<div>
<p className="mb-2">{t("sharable_link_guide")}</p>
<div className="w-full hide-scrollbar overflow-x-auto whitespace-nowrap rounded-md p-2 bg-base-200 border-neutral-content border-solid border flex items-center gap-2 justify-between">
@@ -141,7 +139,7 @@ export default function EditCollectionSharingModal({
<CopyButton text={publicCollectionURL} />
</div>
</div>
) : null}
)}
{permissions === true && <div className="divider my-3"></div>}
+4 -4
View File
@@ -77,7 +77,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"
@@ -87,7 +87,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>
@@ -103,7 +103,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
<div className="grid sm:grid-cols-2 gap-3">
<div>
<p className="mb-2">{t("collection")}</p>
{link.collection.name ? (
{link.collection.name && (
<CollectionSelection
onChange={setCollection}
defaultValue={
@@ -113,7 +113,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
}
creatable={false}
/>
) : null}
)}
</div>
<div>
+4 -4
View File
@@ -124,7 +124,7 @@ export default function NewLinkModal({ 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={{
@@ -132,11 +132,11 @@ export default function NewLinkModal({ onClose }: Props) {
value: link.collection.id,
}}
/>
) : null}
)}
</div>
</div>
<div className={"mt-2"}>
{optionsExpanded ? (
{optionsExpanded && (
<div className="mt-5">
<div className="grid sm:grid-cols-2 gap-3">
<div>
@@ -171,7 +171,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
@@ -79,7 +79,7 @@ export default function NewUserModal({ onClose }: Props) {
/>
</div>
{emailEnabled ? (
{emailEnabled && (
<div>
<p className="mb-2">{t("email")}</p>
<TextInput
@@ -89,7 +89,7 @@ export default function NewUserModal({ onClose }: Props) {
value={form.email}
/>
</div>
) : undefined}
)}
<div>
<p className="mb-2">
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
import {
LinkIncludingShortenedCollectionAndTags,
ArchivedFormat,
AccountSettings,
} from "@/types/global";
import toast from "react-hot-toast";
import Link from "next/link";
@@ -35,15 +36,9 @@ export default function PreservedFormatsModal({ onClose, link }: Props) {
let isPublic = router.pathname.startsWith("/public") ? true : undefined;
const [collectionOwner, setCollectionOwner] = useState({
id: null as unknown as number,
name: "",
username: "",
image: "",
archiveAsScreenshot: undefined as unknown as boolean,
archiveAsMonolith: undefined as unknown as boolean,
archiveAsPDF: undefined as unknown as boolean,
});
const [collectionOwner, setCollectionOwner] = useState<
Partial<AccountSettings>
>({});
useEffect(() => {
const fetchOwner = async () => {
@@ -99,7 +94,7 @@ export default function PreservedFormatsModal({ onClose, link }: Props) {
await getLink.mutateAsync({ id: link.id as number });
})();
let interval: any;
let interval: NodeJS.Timeout | null = null;
if (!isReady()) {
interval = setInterval(async () => {
@@ -149,7 +144,7 @@ export default function PreservedFormatsModal({ onClose, link }: Props) {
)}
<div className={`flex flex-col gap-3`}>
{monolithAvailable(link) ? (
{monolithAvailable(link) && (
<PreservedFormatRow
name={t("webpage")}
icon={"bi-filetype-html"}
@@ -157,9 +152,9 @@ export default function PreservedFormatsModal({ onClose, link }: Props) {
link={link}
downloadable={true}
/>
) : undefined}
)}
{screenshotAvailable(link) ? (
{screenshotAvailable(link) && (
<PreservedFormatRow
name={t("screenshot")}
icon={"bi-file-earmark-image"}
@@ -171,9 +166,9 @@ export default function PreservedFormatsModal({ onClose, link }: Props) {
link={link}
downloadable={true}
/>
) : undefined}
)}
{pdfAvailable(link) ? (
{pdfAvailable(link) && (
<PreservedFormatRow
name={t("pdf")}
icon={"bi-file-earmark-pdf"}
@@ -181,16 +176,16 @@ export default function PreservedFormatsModal({ onClose, link }: Props) {
link={link}
downloadable={true}
/>
) : undefined}
)}
{readabilityAvailable(link) ? (
{readabilityAvailable(link) && (
<PreservedFormatRow
name={t("readable")}
icon={"bi-file-earmark-text"}
format={ArchivedFormat.readability}
link={link}
/>
) : undefined}
)}
{!isReady() && !atLeastOneFormatAvailable() ? (
<div className={`w-full h-full flex flex-col justify-center p-10`}>
@@ -203,17 +198,20 @@ export default function PreservedFormatsModal({ onClose, link }: 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() ? (
<div className={`w-full h-full flex flex-col justify-center p-5`}>
<BeatLoader
color="oklch(var(--p))"
className="mx-auto mb-3"
size={20}
/>
<p className="text-center">{t("there_are_more_formats")}</p>
<p className="text-center text-sm">{t("check_back_later")}</p>
</div>
) : undefined}
) : (
!isReady() &&
atLeastOneFormatAvailable() && (
<div className={`w-full h-full flex flex-col justify-center p-5`}>
<BeatLoader
color="oklch(var(--p))"
className="mx-auto mb-3"
size={20}
/>
<p className="text-center">{t("there_are_more_formats")}</p>
<p className="text-center text-sm">{t("check_back_later")}</p>
</div>
)
)}
<div
className={`flex flex-col sm:flex-row gap-3 items-center justify-center ${
+5 -5
View File
@@ -150,7 +150,7 @@ export default function UploadFileModal({ onClose }: Props) {
<label className="btn h-10 btn-sm w-full border border-neutral-content hover:border-neutral-content flex justify-between">
<input
type="file"
accept=".pdf,.png,.jpg,.jpeg,.html"
accept=".pdf,.png,.jpg,.jpeg"
className="cursor-pointer custom-file-input"
onChange={(e) => e.target.files && setFile(e.target.files[0])}
/>
@@ -163,7 +163,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={{
@@ -171,10 +171,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>
@@ -209,7 +209,7 @@ export default function UploadFileModal({ onClose }: Props) {
</div>
</div>
</div>
) : undefined}
)}
<div className="flex justify-between items-center mt-5">
<div
onClick={() => setOptionsExpanded(!optionsExpanded)}