-
Notifications
You must be signed in to change notification settings - Fork 231
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
Conversation
Preview URL 🚀 : https://blurts-server-pr-4995-mgjlpikfea-uk.a.run.app |
..._react)/(redesign)/(public)/unsubscribe-from-monthly-report/UnsubscribeMonthlyReportView.tsx
Outdated
Show resolved
Hide resolved
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.
Is there a specific reason to keep these strings isolated in a separate file?
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.
These strings exist on a dedicated/separate page, similar to limitations-apply-premium.ftl
.
const handleUnsubscription = async () => { | ||
try { | ||
const response = await fetch(`/api/unsubscribe?token=${token}`, { | ||
method: "GET", | ||
}); | ||
|
||
if (response.ok) { | ||
setUnsubscribeSuccess(true); | ||
} | ||
} catch (e) { | ||
console.error("Error during unsubscription:", e); | ||
} | ||
}; | ||
|
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.
@mansaj You mentioned that we don't need a unsuccessful state if the unsubscription doesn't work, so do we still need this if (response.ok)
logic?
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.
If I'm understanding this correctly, this is calling the API? If so, yes, we do have to handle both success and failure. There are three possible responses: 200, 400, or 500
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 48443a6
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.
Added a react-toastify
component here, which should handle the error state.
const handleUnsubscription = async () => { | ||
try { | ||
const response = await fetch(`/api/unsubscribe?token=${token}`, { | ||
method: "GET", | ||
}); | ||
|
||
if (response.ok) { | ||
setUnsubscribeSuccess(true); | ||
} | ||
} catch (e) { | ||
console.error("Error during unsubscription:", e); | ||
} | ||
}; | ||
|
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.
If I'm understanding this correctly, this is calling the API? If so, yes, we do have to handle both success and failure. There are three possible responses: 200, 400, or 500
|
||
const handleUnsubscription = async () => { | ||
try { | ||
const response = await fetch(`/api/unsubscribe?token=${token}`, { |
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.
Is this url correct? The API is at api/v1/user/unsubscribe-email
?
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.
Ah, you're right! Fixed in 05d3925
if (session?.user?.subscriber) { | ||
const unsubLink = await generateUnsubscribeLinkForSubscriber( | ||
session.user.subscriber, | ||
); | ||
console.info({ unsubLink }); |
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.
This is only for testing right? I think we should only generate the link when the email is crafted
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.
Should remove after testing, because everytime generateUnsubscribeLinkForSubscriber
is called, it replaces the old token
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 e7d4bd5
<ToastContainer | ||
position="top-center" | ||
theme="colored" | ||
autoClose={false} | ||
toastClassName={styles.toastBody} | ||
/> |
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.
c883003
to
ad0f10e
Compare
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 have one blocker, unfortunately: we'll want to put the settings checkbox behind a flag (for free users), so that we can hide it until we've actually added the email.
...app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/settings/AlertAddressForm.tsx
Outdated
Show resolved
Hide resolved
src/app/(proper_react)/(redesign)/(public)/PublicShell.module.scss
Outdated
Show resolved
Hide resolved
..._react)/(redesign)/(public)/unsubscribe-from-monthly-report/UnsubscribeMonthlyReportView.tsx
Outdated
Show resolved
Hide resolved
..._react)/(redesign)/(public)/unsubscribe-from-monthly-report/UnsubscribeMonthlyReportView.tsx
Outdated
Show resolved
Hide resolved
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.
Could we move this to /unsubscribe-email/monthly-report-free/page.tsx
? Just to have some URL consistency with future email unsubscribes, and potentially being able to handle them all with a single route? I also imagine we'll want to allow someone to unsubscribe from all emails in one go at some point, which could then be handled by plain /unsubscribe-email/
.
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 84c36c4
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.
@Vinnl For some reason this broke the override CSS styles for the toast component...
..._react)/(redesign)/(public)/unsubscribe-from-monthly-report/UnsubscribeMonthlyReportView.tsx
Outdated
Show resolved
Hide resolved
* fix: gurantee boolean value * fix: update should upsert too * fix: delete primary_email field * fix: remove dup primary_email from new table * fix: generate the link for the unsub page instead * feat: some example code for FE * extract data from the right table * Unsubscription from monthly report confirmation page * pass in the right function * fix unit tests * fix unit tests --------- Co-authored-by: Joey Zhou <[email protected]>
3652b36
to
86f5cb4
Compare
<Button | ||
variant="link" | ||
onPress={() => void handleUnsubscription()} | ||
<button |
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 decided to resort to a default <button>
element here as opposed to using the pre-made Button
component + link
variant because this is a unique button that's in white, which would require overriding the blue-set colour to the link
<Button>
variant.
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.
This looks good to me and seems to work as intended — good job!
Cleanup completed - database 'blurts-server-pr-4995' destroyed, cloud run service 'blurts-server-pr-4995' destroyed |
An example for @codemist to help integrate
Visit localhost:6060/unsubscribe-email/monthly-report-free