fixes and improvements

This commit is contained in:
daniel31x13 2023-12-04 10:24:45 -05:00
parent ee05975e10
commit 1f20180a51
15 changed files with 75 additions and 35 deletions

View File

@ -218,7 +218,7 @@ export default function LinkCard({ link, count, className }: Props) {
width={64}
height={64}
alt=""
className={`absolute w-12 duration-100 bg-white rounded-md p-1 bottom-5 right-5 select-none z-10`}
className={`absolute w-12 duration-100 bg-white shadow rounded-md p-1 bottom-5 right-5 select-none z-10`}
draggable="false"
onError={(e) => {
const target = e.target as HTMLElement;

View File

@ -92,7 +92,7 @@ export default function PreservedFormats() {
{link?.screenshotPath && link?.screenshotPath !== "pending" ? (
<div className="flex justify-between items-center pr-1 border border-neutral-content rounded-md">
<div className="flex gap-2 items-center">
<div className="text-white bg-primary p-2 rounded-l-md">
<div className="bg-primary text-primary-content p-2 rounded-l-md">
<FontAwesomeIcon icon={faFileImage} className="w-6 h-6" />
</div>
@ -131,7 +131,7 @@ export default function PreservedFormats() {
{link?.pdfPath && link.pdfPath !== "pending" ? (
<div className="flex justify-between items-center pr-1 border border-neutral-content rounded-md">
<div className="flex gap-2 items-center">
<div className="text-white bg-primary p-2 rounded-l-md">
<div className="bg-primary text-primary-content p-2 rounded-l-md">
<FontAwesomeIcon icon={faFilePdf} className="w-6 h-6" />
</div>
@ -166,7 +166,7 @@ export default function PreservedFormats() {
<div className="flex flex-col-reverse sm:flex-row gap-5 items-center justify-center">
{link?.collection.ownerId === session.data?.user.id ? (
<div
className={`w-full text-center bg-sky-700 p-1 rounded-md cursor-pointer select-none hover:bg-sky-600 duration-100 ${
className={`btn btn-accent text-white ${
link?.pdfPath &&
link?.screenshotPath &&
link?.pdfPath !== "pending" &&
@ -176,12 +176,14 @@ export default function PreservedFormats() {
}`}
onClick={() => updateArchive()}
>
<p>Update Preserved Formats</p>
<p className="text-xs">(Refresh Link)</p>
<div>
<p>Update Preserved Formats</p>
<p className="text-xs">(Refresh Link)</p>
</div>
</div>
) : undefined}
<Link
href={`https://web.archive.org/web/${link?.url.replace(
href={`https://web.archive.org/web/${link?.url?.replace(
/(^\w+:|^)\/\//,
""
)}`}

View File

@ -110,7 +110,10 @@ export default function EditCollectionModal({
</div>
</div>
<button className="btn btn-accent w-fit ml-auto" onClick={submit}>
<button
className="btn btn-accent text-white w-fit ml-auto"
onClick={submit}
>
Save
</button>
</div>

View File

@ -180,7 +180,7 @@ export default function EditCollectionSharingModal({
setMemberState
)
}
className="btn btn-primary btn-square btn-sm h-10 w-10"
className="btn btn-accent text-white btn-square btn-sm h-10 w-10"
>
<FontAwesomeIcon icon={faUserPlus} className="w-5 h-5" />
</div>
@ -436,7 +436,7 @@ export default function EditCollectionSharingModal({
{permissions === true && (
<button
className="btn btn-accent w-fit ml-auto mt-3"
className="btn btn-accent text-white w-fit ml-auto mt-3"
onClick={submit}
>
Save

View File

@ -159,7 +159,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
</div>
<div className="flex justify-end items-center mt-5">
<button className="btn btn-accent" onClick={submit}>
<button className="btn btn-accent text-white" onClick={submit}>
Save
</button>
</div>

View File

@ -115,7 +115,10 @@ export default function NewCollectionModal({ onClose }: Props) {
</div>
</div>
<button className="btn btn-accent w-fit ml-auto" onClick={submit}>
<button
className="btn btn-accent text-white w-fit ml-auto"
onClick={submit}
>
Create Collection
</button>
</div>

View File

@ -193,7 +193,7 @@ export default function NewLinkModal({ onClose }: Props) {
<p>{optionsExpanded ? "Hide" : "More"} Options</p>
</div>
<button className="btn btn-accent" onClick={submit}>
<button className="btn btn-accent text-white" onClick={submit}>
Create Link
</button>
</div>

View File

@ -110,7 +110,6 @@ export default function UploadFileModal({ onClose }: Props) {
else if (file.type === "image/png") fileType = ArchivedFormat.png;
else if (file.type === "application/pdf") fileType = ArchivedFormat.pdf;
console.log(fileType);
if (fileType !== null) {
setSubmitLoader(true);
@ -227,7 +226,7 @@ export default function UploadFileModal({ onClose }: Props) {
<p>{optionsExpanded ? "Hide" : "More"} Options</p>
</div>
<button className="btn btn-accent" onClick={submit}>
<button className="btn btn-accent text-white" onClick={submit}>
Create Link
</button>
</div>

View File

@ -21,7 +21,7 @@ export default function SubmitButton({
return (
<button
type={type ? type : undefined}
className={`btn btn-primary text-white tracking-wider w-fit flex items-center gap-2 ${
className={`btn btn-accent text-white tracking-wider w-fit flex items-center gap-2 ${
className || ""
}`}
onClick={() => {

View File

@ -75,7 +75,6 @@ export default async function postLink(
name: link.name,
description,
type: linkType,
readabilityPath: "pending",
collection: {
connectOrCreate: {
where: {
@ -118,11 +117,33 @@ export default async function postLink(
? urlHandler(newLink.id, newLink.url, userId)
: undefined;
linkType === "pdf" ? pdfHandler(newLink.id, newLink.url) : undefined;
newLink.url && linkType === "pdf"
? pdfHandler(newLink.id, newLink.url)
: undefined;
linkType === "image"
newLink.url && linkType === "image"
? imageHandler(newLink.id, newLink.url, imageExtension)
: undefined;
!newLink.url && linkType === "pdf"
? await prisma.link.update({
where: { id: newLink.id },
data: {
pdfPath: "pending",
lastPreserved: new Date().toISOString(),
},
})
: undefined;
!newLink.url && linkType === "image"
? await prisma.link.update({
where: { id: newLink.id },
data: {
screenshotPath: "pending",
lastPreserved: new Date().toISOString(),
},
})
: undefined;
return { response: newLink, status: 200 };
}

View File

@ -47,7 +47,7 @@ export default function App({
reverseOrder={false}
toastOptions={{
className:
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-800 dark:text-white",
}}
/>
<Component {...pageProps} />

View File

@ -89,8 +89,6 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
});
form.parse(req, async (err, fields, files) => {
console.log(files);
const allowedMIMETypes = [
"application/pdf",
"image/png",
@ -109,17 +107,31 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
response: `Sorry, we couldn't process your file. Please ensure it's a PDF, PNG, or JPG format and doesn't exceed ${MAX_UPLOAD_SIZE}MB.`,
});
} else {
console.log(files.file[0].mimetype);
const fileBuffer = fs.readFileSync(files.file[0].filepath);
console.log(fileBuffer);
await createFile({
filePath: `archives/${collectionPermissions?.id}/${linkId + suffix}`,
data: fileBuffer,
const linkStillExists = await prisma.link.findUnique({
where: { id: linkId },
});
if (linkStillExists) {
await createFile({
filePath: `archives/${collectionPermissions?.id}/${
linkId + suffix
}`,
data: fileBuffer,
});
await prisma.link.update({
where: { id: linkId },
data: {
screenshotPath: `archives/${collectionPermissions?.id}/${
linkId + suffix
}`,
lastPreserved: new Date().toISOString(),
},
});
}
fs.unlinkSync(files.file[0].filepath);
}

View File

@ -133,7 +133,7 @@ export default function Index() {
</div>
) : null}
</div>
<p className="text-neutral text-xs">
<p className="text-neutral text-sm font-semibold">
By {collectionOwner.name}
{activeCollection.members.length > 0
? ` and ${activeCollection.members.length} others`

View File

@ -169,7 +169,7 @@ export default function PublicCollections() {
) : null}
</div>
<p className="text-neutral text-xs">
<p className="text-neutral text-sm font-semibold">
By {collectionOwner.name}
{collection.members.length > 0
? ` and ${collection.members.length} others`

View File

@ -6,9 +6,9 @@ module.exports = {
themes: [
{
light: {
primary: "#0284c7",
primary: "#0369a1",
secondary: "#0891b2",
accent: "#6366f1",
accent: "#6d28d9",
neutral: "#6b7280",
"neutral-content": "#d1d5db",
"base-100": "#ffffff",
@ -22,9 +22,9 @@ module.exports = {
},
{
dark: {
primary: "#38bdf8",
primary: "#7dd3fc",
secondary: "#22d3ee",
accent: "#6366f1",
accent: "#6d28d9",
neutral: "#9ca3af",
"neutral-content": "#404040",
"base-100": "#171717",