Skip to content

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

feat: store email for recurring doc visits

Marc Seitzcba81acad43b
diff --git a/components/view/access-form/email-section.tsx b/components/view/access-form/email-section.tsx
index 12064cd2..cb641ee3 100644
--- a/components/view/access-form/email-section.tsx
+++ b/components/view/access-form/email-section.tsx
@@ -1,5 +1,6 @@
-import { Dispatch, SetStateAction } from "react";
+import { Dispatch, SetStateAction, useEffect } from "react";
import { DEFAULT_ACCESS_FORM_TYPE } from ".";
+import handle from "@/pages/api/record_reaction";
export default function EmailSection({
data,
@@ -10,6 +11,22 @@ export default function EmailSection({
}) {
const { email } = data;
+ useEffect(() => {
+ // Load email from localStorage when the component mounts
+ const storedEmail = window.localStorage.getItem("papermark.email");
+ if (storedEmail) {
+ setData((prevData) => ({ ...prevData, email: storedEmail }));
+ }
+ }, [setData]);
+
+ const handleEmailChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const newEmail = e.target.value;
+ // Store the new email in localStorage
+ window.localStorage.setItem("papermark.email", newEmail);
+ // Update the state
+ setData({ ...data, email: newEmail });
+ };
+
return (
<div className="pb-5">
<div className="relative rounded-md shadow-sm space-y-2">
@@ -27,9 +44,7 @@ export default function EmailSection({
className="flex 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"
value={email || ""}
placeholder="Enter email"
- onChange={(e) => {
- setData({ ...data, email: e.target.value });
- }}
+ onChange={handleEmailChange}
aria-invalid="true"
/>
<p className="text-sm text-gray-600">