Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNTOR-3556: Front end integration #4995

Merged
merged 22 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions locales-pending/settings-premium.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

## Email preferences

settings-alert-preferences-allow-monthly-monitor-plus-report-title = Monthly { -brand-monitor-plus } report
settings-alert-preferences-allow-monthly-monitor-plus-report-subtitle = A monthly update of new exposures, what’s been fixed, and what needs your attention.

## Cancel Plus subscription

settings-cancel-plus-title = Cancel { -brand-monitor-plus } subscription
Expand Down
5 changes: 5 additions & 0 deletions locales/en/settings.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ settings-delete-monitor-free-account-dialog-cta-label = Delete account
settings-delete-monitor-free-account-dialog-cancel-button-label = Never mind, take me back
settings-delete-monitor-account-confirmation-toast-label-2 = Your { -brand-monitor } account is now deleted.
settings-delete-monitor-account-confirmation-toast-dismiss-label = Dismiss

## Monthly Monitor Report

settings-alert-preferences-allow-monthly-monitor-report-title = Monthly { -brand-monitor } report
settings-alert-preferences-allow-monthly-monitor-report-subtitle = A monthly update of new exposures, what’s been fixed, and what needs your attention.
18 changes: 18 additions & 0 deletions locales/en/unsubscribe.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Confirm Unsubscription State

unsubscribe-from-monthly-report-header = Unsubscribe from this email?
unsubscribe-from-monthly-report-body = You’ll no longer receive the monthly { -brand-monitor } report, which tells you how many new exposures you’ve had each month and how many are fixed.
unsubscribe-cta = Unsubscribe

# Success Unsubscription State

unsubscribe-success-from-monthly-report-header = You’re now unsubscribed
unsubscribe-success-from-monthly-report-body = You can resubscribe or update your email preferences anytime from your { -brand-monitor } settings.

# Error warning

unsubscription-failed = Unsubscribe failed. <try_again_link>Try again.</try_again_link>
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"react-dom": "^18.3.1",
"react-intersection-observer": "^9.13.0",
"react-stately": "^3.32.2",
"react-toastify": "^10.0.5",
"server-only": "^0.0.1",
"uuid": "^10.0.0",
"winston": "^3.14.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ import { VisuallyHidden } from "../../../../../../components/server/VisuallyHidd
import { useSession } from "next-auth/react";
import { FeatureFlagName } from "../../../../../../../db/tables/featureFlags";
import { Session } from "next-auth";
import { hasPremium } from "../../../../../../functions/universal/user";
import { useRouter } from "next/navigation";
import { SubscriberRow } from "knex/types/tables";
import { SubscriberEmailPreferencesOutput } from "../../../../../../../db/tables/subscriber_email_preferences";
import { hasPremium } from "../../../../../../functions/universal/user";

export type Props = {
user: Session["user"];
subscriber: SubscriberRow;
data: SubscriberEmailPreferencesOutput;
enabledFeatureFlags: FeatureFlagName[];
};

Expand All @@ -48,7 +50,15 @@ export const AlertAddressForm = (props: Props) => {

const breachAlertsEmailsAllowed = props.subscriber.all_emails_to_primary;

const monitorReportAllowed = props.subscriber.monthly_monitor_report;
// Extract monthly report preference from the right column
const monitorReportAllowed = hasPremium(props.user)
? props.data.monthly_monitor_report
: props.data.monthly_monitor_report_free;

// TODO: Deprecate this when monthly report for free users has been created
const monthlyFreeUserReportEnabled =
props.enabledFeatureFlags.includes("MonthlyReportFreeUser") ||
hasPremium(props.user);

const defaultActivateAlertEmail =
typeof breachAlertsEmailsAllowed === "boolean";
Expand Down Expand Up @@ -175,22 +185,21 @@ export const AlertAddressForm = (props: Props) => {
</AlertAddressRadio>
</AlertAddressContext.Provider>
)}

{props.enabledFeatureFlags.includes("MonthlyActivityEmail") &&
hasPremium(props.user) && (
monthlyFreeUserReportEnabled && (
<ActivateEmailsCheckbox
isSelected={activateMonthlyMonitorReport}
onChange={handleMonthlyMonitorReportToggle}
>
<div>
<b>
{l10n.getString(
"settings-alert-preferences-allow-monthly-monitor-plus-report-title",
"settings-alert-preferences-allow-monthly-monitor-report-title",
)}
</b>
<p>
{l10n.getString(
"settings-alert-preferences-allow-monthly-monitor-plus-report-subtitle",
"settings-alert-preferences-allow-monthly-monitor-report-subtitle",
)}
</p>
</div>
Expand Down
Loading
Loading