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

Use optional chaining to avoid undefined monthly_monitor_report #5511

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading