⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
ui improvements
Danieldebfd36eb849
diff --git a/.env.sample b/.env.sampleindex 2140dd20..a1703b8e 100644--- a/.env.sample+++ b/.env.sample@@ -18,8 +18,9 @@ EMAIL_FROM=EMAIL_SERVER=# Stripe settings (You don't need these, it's for the cloud instance payments)+NEXT_PUBLC_STRIPE_IS_ACTIVE=STRIPE_SECRET_KEY=PRICE_ID=-TRIAL_PERIOD_DAYS=+NEXT_PUBLIC_TRIAL_PERIOD_DAYS=NEXT_PUBLIC_STRIPE_BILLING_PORTAL_URL=BASE_URL=http://localhost:3000\ No newline at end of filediff --git a/layouts/AuthRedirect.tsx b/layouts/AuthRedirect.tsxindex a5fd1ade..82471392 100644--- a/layouts/AuthRedirect.tsx+++ b/layouts/AuthRedirect.tsx@@ -18,57 +18,57 @@ export default function AuthRedirect({ children }: Props) {useInitialData();- useEffect(() => {- if (!router.pathname.startsWith("/public")) {- if (- emailEnabled &&- status === "authenticated" &&- (data.user.isSubscriber === true ||- data.user.isSubscriber === undefined) &&- !data.user.username- ) {- router.push("/choose-username").then(() => {- setRedirect(false);- });- } else if (- status === "authenticated" &&- data.user.isSubscriber === false- ) {- router.push("/subscribe").then(() => {- setRedirect(false);- });- } else if (- status === "authenticated" &&- (router.pathname === "/login" ||- router.pathname === "/register" ||- router.pathname === "/confirmation" ||- router.pathname === "/subscribe" ||- router.pathname === "/choose-username" ||- router.pathname === "/forgot")- ) {- router.push("/").then(() => {- setRedirect(false);- });- } else if (- status === "unauthenticated" &&- !(- router.pathname === "/login" ||- router.pathname === "/register" ||- router.pathname === "/confirmation" ||- router.pathname === "/forgot"- )- ) {- router.push("/login").then(() => {- setRedirect(false);- });- } else if (status === "loading") setRedirect(true);- else setRedirect(false);- } else {- setRedirect(false);- }- }, [status]);+ // useEffect(() => {+ // if (!router.pathname.startsWith("/public")) {+ // if (+ // emailEnabled &&+ // status === "authenticated" &&+ // (data.user.isSubscriber === true ||+ // data.user.isSubscriber === undefined) &&+ // !data.user.username+ // ) {+ // router.push("/choose-username").then(() => {+ // setRedirect(false);+ // });+ // } else if (+ // status === "authenticated" &&+ // data.user.isSubscriber === false+ // ) {+ // router.push("/subscribe").then(() => {+ // setRedirect(false);+ // });+ // } else if (+ // status === "authenticated" &&+ // (router.pathname === "/login" ||+ // router.pathname === "/register" ||+ // router.pathname === "/confirmation" ||+ // router.pathname === "/subscribe" ||+ // router.pathname === "/choose-username" ||+ // router.pathname === "/forgot")+ // ) {+ // router.push("/").then(() => {+ // setRedirect(false);+ // });+ // } else if (+ // status === "unauthenticated" &&+ // !(+ // router.pathname === "/login" ||+ // router.pathname === "/register" ||+ // router.pathname === "/confirmation" ||+ // router.pathname === "/forgot"+ // )+ // ) {+ // router.push("/login").then(() => {+ // setRedirect(false);+ // });+ // } else if (status === "loading") setRedirect(true);+ // else setRedirect(false);+ // } else {+ // setRedirect(false);+ // }+ // }, [status]);- if (status !== "loading" && !redirect) return <>{children}</>;- else return <></>;- // return <>{children}</>;+ // if (status !== "loading" && !redirect) return <>{children}</>;+ // else return <></>;+ return <>{children}</>;}diff --git a/lib/api/checkSubscription.ts b/lib/api/checkSubscription.tsindex 67f001ce..6537c221 100644--- a/lib/api/checkSubscription.ts+++ b/lib/api/checkSubscription.ts@@ -19,9 +19,10 @@ export default async function checkSubscription(const isSubscriber = listByEmail.data.some((customer, i) => {const hasValidSubscription = customer.subscriptions?.data.some((subscription) => {- const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;- const secondsInTwoWeeks = TRIAL_PERIOD_DAYS- ? Number(TRIAL_PERIOD_DAYS) * 86400+ const NEXT_PUBLIC_TRIAL_PERIOD_DAYS =+ process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS;+ const secondsInTwoWeeks = NEXT_PUBLIC_TRIAL_PERIOD_DAYS+ ? Number(NEXT_PUBLIC_TRIAL_PERIOD_DAYS) * 86400: 1209600;subscriptionCanceledAt = subscription.canceled_at;diff --git a/lib/api/paymentCheckout.ts b/lib/api/paymentCheckout.tsindex 56101307..06dd7e3c 100644--- a/lib/api/paymentCheckout.ts+++ b/lib/api/paymentCheckout.ts@@ -17,7 +17,8 @@ export default async function paymentCheckout(const isExistingCostomer = listByEmail?.data[0]?.id || undefined;- const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;+ const NEXT_PUBLIC_TRIAL_PERIOD_DAYS =+ process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS;const session = await stripe.checkout.sessions.create({customer: isExistingCostomer ? isExistingCostomer : undefined,line_items: [@@ -34,7 +35,9 @@ export default async function paymentCheckout(enabled: true,},subscription_data: {- trial_period_days: TRIAL_PERIOD_DAYS ? Number(TRIAL_PERIOD_DAYS) : 14,+ trial_period_days: NEXT_PUBLIC_TRIAL_PERIOD_DAYS+ ? Number(NEXT_PUBLIC_TRIAL_PERIOD_DAYS)+ : 14,},});diff --git a/lib/api/updateCustomerEmail.ts b/lib/api/updateCustomerEmail.tsindex 07af401b..95ebc60d 100644--- a/lib/api/updateCustomerEmail.ts+++ b/lib/api/updateCustomerEmail.ts@@ -18,9 +18,10 @@ export default async function updateCustomerEmail(const customer = listByEmail.data.find((customer, i) => {const hasValidSubscription = customer.subscriptions?.data.some((subscription) => {- const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;- const secondsInTwoWeeks = TRIAL_PERIOD_DAYS- ? Number(TRIAL_PERIOD_DAYS) * 86400+ const NEXT_PUBLIC_TRIAL_PERIOD_DAYS =+ process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS;+ const secondsInTwoWeeks = NEXT_PUBLIC_TRIAL_PERIOD_DAYS+ ? Number(NEXT_PUBLIC_TRIAL_PERIOD_DAYS) * 86400: 1209600;const isNotCanceledOrHasTime = !(diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].tsindex e760f2e5..bdf85c5e 100644--- a/pages/api/auth/[...nextauth].ts+++ b/pages/api/auth/[...nextauth].ts@@ -93,9 +93,10 @@ export const authOptions: AuthOptions = {const STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY;const PRICE_ID = process.env.PRICE_ID;- const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;- const secondsInTwoWeeks = TRIAL_PERIOD_DAYS- ? Number(TRIAL_PERIOD_DAYS) * 86400+ const NEXT_PUBLIC_TRIAL_PERIOD_DAYS =+ process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS;+ const secondsInTwoWeeks = NEXT_PUBLIC_TRIAL_PERIOD_DAYS+ ? Number(NEXT_PUBLIC_TRIAL_PERIOD_DAYS) * 86400: 1209600;const subscriptionIsTimesUp =token.subscriptionCanceledAt &&diff --git a/pages/choose-username.tsx b/pages/choose-username.tsxindex a3fcfb14..7f49afda 100644--- a/pages/choose-username.tsx+++ b/pages/choose-username.tsx@@ -42,23 +42,17 @@ export default function Subscribe() {return (<>+ <Image+ src="/linkwarden.png"+ width={1694}+ height={483}+ alt="Linkwarden"+ className="h-12 w-fit mx-auto mt-10"+ /><div className="p-2 mt-10 mx-auto flex flex-col gap-3 justify-between sm:w-[28rem] w-80 bg-slate-50 rounded-md border border-sky-100">- <div className="flex flex-col gap-2 justify-between items-center mb-5">- <Image- src="/linkwarden.png"- width={1694}- height={483}- alt="Linkwarden"- className="h-12 w-fit mx-auto"- />-- <div className="text-center">- <p className="text-3xl text-sky-500">One Last Step...</p>- <p className="font-semibold text-sky-400">- Please choose a username to start using your account.- </p>- </div>- </div>+ <p className="text-xl text-sky-500 w-fit font-bold">+ Choose a Username (Last step)+ </p><div><p className="text-sm text-sky-500 w-fit font-semibold mb-1">@@ -85,7 +79,7 @@ export default function Subscribe() {<SubmitButtononClick={submitUsername}- label="Choose Username"+ label="Complete Registration"className="mt-2 w-full text-center"loading={submitLoader}/>@@ -97,6 +91,9 @@ export default function Subscribe() {Sign Out</div></div>+ <p className="text-center text-xs text-gray-500 my-10">+ © {new Date().getFullYear()} Linkwarden. All rights reserved.{" "}+ </p></>);}diff --git a/pages/forgot.tsx b/pages/forgot.tsxindex 2b1f23d4..8770e560 100644--- a/pages/forgot.tsx+++ b/pages/forgot.tsx@@ -39,20 +39,21 @@ export default function Forgot() {return (<>+ <Image+ src="/linkwarden.png"+ width={1694}+ height={483}+ alt="Linkwarden"+ className="h-12 w-fit mx-auto mt-10"+ /><div className="p-2 mt-10 mx-auto flex flex-col gap-3 justify-between sm:w-[28rem] w-80 bg-slate-50 rounded-md border border-sky-100">- <div className="flex flex-col gap-2 sm:flex-row justify-between items-center mb-5">- <Image- src="/linkwarden.png"- width={1694}- height={483}- alt="Linkwarden"- className="h-12 w-fit"- />- <div className="text-center sm:text-right">- <p className="text-3xl text-sky-500">Password Reset</p>- </div>- </div>-+ <p className="text-xl text-sky-500 w-fit font-bold">Fogot Password?</p>+ <p className="text-md text-gray-500 mt-1">+ Enter your Email so we can send you a link to recover your account.+ </p>+ <p className="text-md text-gray-500 mt-1">+ Make sure to change your password in the profile settings afterwards.+ </p><div><p className="text-sm text-sky-500 w-fit font-semibold mb-1">Email</p>@@ -63,10 +64,6 @@ export default function Forgot() {onChange={(e) => setForm({ ...form, email: e.target.value })}className="w-full rounded-md p-2 mx-auto border-sky-100 border-solid border outline-none focus:border-sky-500 duration-100"/>- <p className="text-md text-gray-500 mt-1">- Make sure to change your password in the profile settings- afterwards.- </p></div><SubmitButton@@ -81,6 +78,9 @@ export default function Forgot() {</Link></div></div>+ <p className="text-center text-xs text-gray-500 my-10">+ © {new Date().getFullYear()} Linkwarden. All rights reserved.{" "}+ </p></>);}diff --git a/pages/login.tsx b/pages/login.tsxindex f17798c5..afb64f1a 100644--- a/pages/login.tsx+++ b/pages/login.tsx@@ -46,23 +46,20 @@ export default function Login() {return (<>+ <Image+ src="/linkwarden.png"+ width={1694}+ height={483}+ alt="Linkwarden"+ className="h-12 w-fit mx-auto mt-10"+ />+ <p className="text-xl font-semibold text-sky-500 text-center">+ Sign in to your account+ </p><div className="p-2 my-10 mx-auto flex flex-col gap-3 justify-between sm:w-[28rem] w-80 bg-slate-50 rounded-md border border-sky-100">- <div className="text-right flex flex-col gap-2 sm:flex-row justify-between items-center mb-5">- <Image- src="/linkwarden.png"- width={1694}- height={483}- alt="Linkwarden"- className="h-12 w-fit"- />- <div className="text-center sm:text-right">- <p className="text-3xl text-sky-500">Welcome back</p>- <p className="text-md font-semibold text-sky-400">- Sign in to your account- </p>- </div>- </div>-+ <p className="text-xl text-sky-500 w-fit font-bold">+ Enter your credentials+ </p><div><p className="text-sm text-sky-500 w-fit font-semibold mb-1">Username@@ -112,6 +109,9 @@ export default function Login() {</Link></div></div>+ <p className="text-center text-xs text-gray-500 mb-10">+ © {new Date().getFullYear()} Linkwarden. All rights reserved.{" "}+ </p></>);}diff --git a/pages/register.tsx b/pages/register.tsxindex c047e17c..877651ac 100644--- a/pages/register.tsx+++ b/pages/register.tsx@@ -90,23 +90,26 @@ export default function Register() {return (<>+ <Image+ src="/linkwarden.png"+ width={1694}+ height={483}+ alt="Linkwarden"+ className="h-12 w-fit mx-auto mt-10"+ />+ <div className="text-center">+ <p className="text-xl font-semibold text-sky-500">+ {process.env.NEXT_PUBLIC_STRIPE_IS_ACTIVE+ ? `Start using our premium services with a ${+ process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS || 14+ }-day free trial!`+ : "Create a new account"}+ </p>+ </div><div className="p-2 mx-auto my-10 flex flex-col gap-3 justify-between sm:w-[28rem] w-80 bg-slate-50 rounded-md border border-sky-100">- <div className="flex flex-col gap-2 sm:flex-row justify-between items-center mb-5">- <Image- src="/linkwarden.png"- width={1694}- height={483}- alt="Linkwarden"- className="h-12 w-fit"- />- <div className="text-center sm:text-right">- <p className="text-3xl text-sky-500">Get started</p>- <p className="text-md font-semibold text-sky-400">- Create a new account- </p>- </div>- </div>-+ <p className="text-xl text-sky-500 w-fit font-bold">+ Enter your details+ </p><div><p className="text-sm text-sky-500 w-fit font-semibold mb-1">Display Name@@ -197,6 +200,9 @@ export default function Register() {</Link></div></div>+ <p className="text-center text-xs text-gray-500 mb-10">+ © {new Date().getFullYear()} Linkwarden. All rights reserved.{" "}+ </p></>);}diff --git a/pages/subscribe.tsx b/pages/subscribe.tsxindex c1b427ee..32582fe2 100644--- a/pages/subscribe.tsx+++ b/pages/subscribe.tsx@@ -26,23 +26,18 @@ export default function Subscribe() {return (<>+ <Image+ src="/linkwarden.png"+ width={1694}+ height={483}+ alt="Linkwarden"+ className="h-12 w-fit mx-auto mt-10"+ />+ <p className="text-xl font-semibold text-sky-500 text-center">+ {process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS || 14} days free trial, then+ $5/month afterwards+ </p><div className="p-2 mt-10 mx-auto flex flex-col gap-3 justify-between sm:w-[28rem] w-80 bg-slate-50 rounded-md border border-sky-100">- <div className="flex flex-col gap-2 sm:flex-row justify-between items-center mb-5">- <Image- src="/linkwarden.png"- width={1694}- height={483}- alt="Linkwarden"- className="h-12 w-fit"- />- <div className="text-center sm:text-right">- <p className="text-3xl text-sky-500">14 days free trial</p>- <p className="text-md font-semibold text-sky-400">- Then $5/month afterwards- </p>- </div>- </div>-<div><p className="text-md text-gray-500 mt-1">You will be redirected to Stripe.@@ -70,6 +65,9 @@ export default function Subscribe() {Sign Out</div></div>+ <p className="text-center text-xs text-gray-500 my-10">+ © {new Date().getFullYear()} Linkwarden. All rights reserved.{" "}+ </p></>);}diff --git a/types/enviornment.d.ts b/types/enviornment.d.tsindex 96553283..5bf5055d 100644--- a/types/enviornment.d.ts+++ b/types/enviornment.d.ts@@ -17,10 +17,11 @@ declare global {EMAIL_FROM?: string;EMAIL_SERVER?: string;+ NEXT_PUBLC_STRIPE_IS_ACTIVE?: boolean;STRIPE_SECRET_KEY?: string;PRICE_ID?: string;NEXT_PUBLIC_STRIPE_BILLING_PORTAL_URL?: string;- TRIAL_PERIOD_DAYS?: string;+ NEXT_PUBLIC_TRIAL_PERIOD_DAYS?: string;BASE_URL?: string;}}