Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: cleanup eslint errors

Marc Seitz9d7eb9d957e5
diff --git a/components/links/email-protection-section.tsx b/components/links/email-protection-section.tsx
index 28e863fd..44cc288c 100644
--- a/components/links/email-protection-section.tsx
+++ b/components/links/email-protection-section.tsx
@@ -1,13 +1,11 @@
import { Dispatch, SetStateAction, useState } from "react";
import { Switch } from "@/components/ui/switch";
-import { motion } from "framer-motion";
-import { Link } from "@prisma/client";
-import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/contants";
-import { cn, getDateTimeLocal } from "@/lib/utils";
+import { cn } from "@/lib/utils";
+import { DEFAULT_LINK_TYPE } from "./link-sheet";
-export default function EmailProtectionSection({data, setData}: {data: Link, setData: Dispatch<SetStateAction<Link>>}) {
+export default function EmailProtectionSection({data, setData}: {data: DEFAULT_LINK_TYPE, setData: Dispatch<SetStateAction<DEFAULT_LINK_TYPE>>}) {
const [enabled, setEnabled] = useState(true);
function handleCheckedChange() {
@@ -29,7 +27,7 @@ export default function EmailProtectionSection({data, setData}: {data: Link, set
</div>
<Switch
checked={enabled}
- onCheckedChange={(e) => handleCheckedChange()}
+ onCheckedChange={() => handleCheckedChange()}
/>
</div>
</div>
diff --git a/components/links/expiration-section.tsx b/components/links/expiration-section.tsx
index a8071be7..8d295528 100644
--- a/components/links/expiration-section.tsx
+++ b/components/links/expiration-section.tsx
@@ -1,13 +1,13 @@
import { Dispatch, SetStateAction, useState } from "react";
import { Switch } from "@/components/ui/switch";
import { motion } from "framer-motion";
-import { Link } from "@prisma/client";
import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/contants";
import { cn, getDateTimeLocal } from "@/lib/utils";
+import { DEFAULT_LINK_TYPE } from "./link-sheet";
-export default function ExpirationSection({data, setData}: {data: Link, setData: Dispatch<SetStateAction<Link>>}) {
+export default function ExpirationSection({data, setData}: {data: DEFAULT_LINK_TYPE, setData: Dispatch<SetStateAction<DEFAULT_LINK_TYPE>>}) {
const { expiresAt } = data;
const [enabled, setEnabled] = useState(!!expiresAt);
diff --git a/components/links/link-sheet.tsx b/components/links/link-sheet.tsx
index 977a416f..019b3806 100644
--- a/components/links/link-sheet.tsx
+++ b/components/links/link-sheet.tsx
@@ -18,11 +18,24 @@ import { useRouter } from "next/router";
import { useDocumentLinks } from "@/lib/swr/use-document";
import { mutate } from "swr";
+const DEFAULT_LINK_PROPS = {
+ name: null,
+ expiresAt: null,
+ password: null,
+ emailProtected: true,
+};
+
+export type DEFAULT_LINK_TYPE = {
+ name: string | null;
+ expiresAt: Date | null;
+ password: string | null;
+ emailProtected: boolean | true;
+};
export default function LinkSheet({ children }: { children: React.ReactNode }) {
const { links } = useDocumentLinks();
- const [data, setData] = useState<Link>({});
+ const [data, setData] = useState<DEFAULT_LINK_TYPE>(DEFAULT_LINK_PROPS);
const [isLoading, setIsLoading] = useState<boolean>(false);
const router = useRouter();
@@ -90,7 +103,7 @@ export default function LinkSheet({ children }: { children: React.ReactNode }) {
name="link-name"
id="link-name"
placeholder="Recipient's Organization"
- value={data.name ? data.name : null}
+ value={data.name || ''}
className="block w-full rounded-md border-0 py-1.5 text-white bg-black shadow-sm ring-1 ring-inset ring-gray-600 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-gray-300 sm:text-sm sm:leading-6"
onChange={(e) =>
setData({ ...data, name: e.target.value })
diff --git a/components/links/password-section.tsx b/components/links/password-section.tsx
index 3a21c2cf..294e8385 100644
--- a/components/links/password-section.tsx
+++ b/components/links/password-section.tsx
@@ -1,14 +1,14 @@
import { Dispatch, SetStateAction, useState } from "react";
import { Switch } from "@/components/ui/switch";
import { motion } from "framer-motion";
-import { Link } from "@prisma/client";
import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/contants";
import Eye from "@/components/shared/icons/eye"
import { cn } from "@/lib/utils";
+import { DEFAULT_LINK_TYPE } from "./link-sheet";
-export default function PasswordSection({data, setData}: {data: Link, setData: Dispatch<SetStateAction<Link>>}) {
+export default function PasswordSection({data, setData}: {data: DEFAULT_LINK_TYPE, setData: Dispatch<SetStateAction<DEFAULT_LINK_TYPE>>}) {
const { password } = data;
const [enabled, setEnabled] = useState(!!password);
const [showPassword, setShowPassword] = useState(false);