Skip to content

Commit

Permalink
Use optional chaining to avoid undefined monthly_monitor_report (#5511)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmer authored Jan 22, 2025
1 parent 287d445 commit 846bc04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { useTelemetry } from "../../../../../../hooks/useTelemetry";
export type Props = {
user: Session["user"];
subscriber: SubscriberRow;
data: SubscriberEmailPreferencesOutput;
data?: SubscriberEmailPreferencesOutput;
enabledFeatureFlags: FeatureFlagName[];
};

Expand All @@ -53,8 +53,8 @@ export const AlertAddressForm = (props: Props) => {

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

// TODO: Deprecate this when monthly report for free users has been created
const canToggleFreeOrPlusMonthlyReport =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type SettingsPanelNotificationsProps = {
export type NotificationSettingsProps = {
user: Session["user"];
subscriber: SubscriberRow;
data: SubscriberEmailPreferencesOutput;
data?: SubscriberEmailPreferencesOutput;
};

const EmailCommOption = {
Expand All @@ -53,8 +53,8 @@ export const NotificationsSettings = (props: NotificationSettingsProps) => {

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

const defaultActivateAlertEmail =
typeof breachAlertsEmailsAllowed === "boolean";
Expand Down

0 comments on commit 846bc04

Please sign in to comment.