-
Notifications
You must be signed in to change notification settings - Fork 198
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
Save email preferences changes #4548
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,8 @@ import { | |
export type EmailUpdateCommTypeOfOptions = "null" | "affected" | "primary"; | ||
|
||
export interface EmailUpdateCommOptionRequest { | ||
instantBreachAlerts: EmailUpdateCommTypeOfOptions; | ||
monthlyMonitorReport: boolean; | ||
instantBreachAlerts?: EmailUpdateCommTypeOfOptions; | ||
monthlyMonitorReport?: boolean; | ||
} | ||
|
||
export async function POST(req: NextRequest) { | ||
|
@@ -48,8 +48,13 @@ export async function POST(req: NextRequest) { | |
default: | ||
allEmailsToPrimary = null; | ||
} | ||
await setAllEmailsToPrimary(subscriber, allEmailsToPrimary); | ||
await setMonthlyMonitorReport(subscriber, monthlyMonitorReport); | ||
|
||
if (typeof instantBreachAlerts !== "undefined") { | ||
await setAllEmailsToPrimary(subscriber, allEmailsToPrimary); | ||
} | ||
if (typeof monthlyMonitorReport === "boolean") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Vinnl Can the condition here be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It ended up just being an issue of passing the wrong var! my bad |
||
await setMonthlyMonitorReport(subscriber, monthlyMonitorReport); | ||
} | ||
|
||
return NextResponse.json({ | ||
success: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't leave a comment on the relevant lines because they're unchanged, but it's best to update the type representing the request body to indicate that one of the properties should now be left empty:
And then TS will show you what code to wrap in an
if (typeof <x> !== "undefined")
, and you won't need the custom type guard (isEmailUpdateCommType
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 22b41c4