Skip to content

Commit

Permalink
feat: some example code for FE
Browse files Browse the repository at this point in the history
  • Loading branch information
mansaj authored and codemist committed Sep 12, 2024
1 parent b0d848b commit f9e6186
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { getCountryCode } from "../../../../../../functions/server/getCountryCod
import { getSubscriberById } from "../../../../../../../db/tables/subscribers";
import { checkSession } from "../../../../../../functions/server/checkSession";
import { checkUserHasMonthlySubscription } from "../../../../../../functions/server/user";

import { generateUnsubscribeLinkForSubscriber } from "../../../../../../api/utils/email";
import { getEmailPreferenceForPrimaryEmail } from "../../../../../../../db/tables/subscriber_email_preferences";
type Props = {
searchParams: {
nimbus_web_preview?: string;
Expand All @@ -36,6 +37,13 @@ export default async function SettingsPage({ searchParams }: Props) {
const session = await getServerSession();
console.debug(searchParams);

if (session?.user?.subscriber) {
const unsubLink = await generateUnsubscribeLinkForSubscriber(
session.user.subscriber,
);
console.info({ unsubLink });
}

if (!session?.user?.subscriber?.id || !checkSession(session)) {
return redirect("/auth/logout");
}
Expand Down Expand Up @@ -97,6 +105,7 @@ export default async function SettingsPage({ searchParams }: Props) {
l10n={getL10n()}
user={session.user}
subscriber={userData}
// emailPreference={emailPreference}
emailAddresses={emailAddresses}
breachCountByEmailAddress={breachCountByEmailAddress}
fxaSettingsUrl={fxaSettingsUrl}
Expand Down

0 comments on commit f9e6186

Please sign in to comment.