-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(newletter): deprecate newsletter (#12499)
* feat(newletter): deprecate newsletter - don't allow new sign-ups - only unsubscribe from settings - remove from blog - update copy on /en-US/newsletter * Apply suggestions from code review Co-authored-by: Claas Augner <[email protected]> --------- Co-authored-by: Claas Augner <[email protected]>
- Loading branch information
Showing
4 changed files
with
28 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import React, { createElement, useState } from "react"; | ||
import React, { createElement } from "react"; | ||
|
||
import { useIsServer, useLocale } from "../hooks"; | ||
import { Button } from "../ui/atoms/button"; | ||
import { MainContentContainer } from "../ui/atoms/page-content"; | ||
import { useUserData } from "../user-context"; | ||
|
||
|
@@ -10,7 +9,7 @@ import "./index.scss"; | |
export function Newsletter() { | ||
return ( | ||
<MainContentContainer className="section-newsletter"> | ||
<SignUpForm /> | ||
<SignUpForm sendUsersToSettings={true} /> | ||
</MainContentContainer> | ||
); | ||
} | ||
|
@@ -19,98 +18,25 @@ function SignUpForm({ sendUsersToSettings = false, section = false }) { | |
const isServer = useIsServer(); | ||
const user = useUserData(); | ||
const locale = useLocale(); | ||
const [pending, setPending] = useState(false); | ||
const [error, setError] = useState(false); | ||
const [submitted, setSubmitted] = useState(false); | ||
const [email, setEmail] = useState(""); | ||
const submit = async (event: React.FormEvent) => { | ||
event.preventDefault(); | ||
setPending(true); | ||
try { | ||
const response = await fetch("/api/v1/newsletter", { | ||
body: JSON.stringify({ email }), | ||
method: "POST", | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
}); | ||
if (!response.ok) { | ||
throw Error(); | ||
} | ||
} catch { | ||
setError(true); | ||
setPending(false); | ||
return; | ||
} | ||
setSubmitted(true); | ||
}; | ||
|
||
return submitted ? ( | ||
<> | ||
{createElement(section ? "h2" : "h1", null, "Thanks!")} | ||
<p> | ||
If you haven't previously confirmed a subscription to a Mozilla-related | ||
newsletter, you may have to do so. Please check your inbox or your spam | ||
filter for an email from us. | ||
</p> | ||
</> | ||
) : ( | ||
return ( | ||
<> | ||
{createElement(section ? "h2" : "h1", null, "Stay Informed with MDN")} | ||
<p>We're decommissioning our MDN Plus newsletter.</p> | ||
<p> | ||
Get the MDN newsletter and never miss an update on the latest web | ||
development trends, tips, and best practices. | ||
<strong> | ||
We will automatically unsubscribe you and purge all related data soon. | ||
</strong> | ||
</p> | ||
{sendUsersToSettings && user?.isAuthenticated && !isServer ? ( | ||
<p> | ||
Sign up via the{" "} | ||
Unsubscribe now via the{" "} | ||
<a href={`/${locale}/plus/settings#newsletter`} rel="_blank"> | ||
Settings Page. | ||
</a> | ||
</p> | ||
) : ( | ||
<form className="mdn-form mdn-form-big" onSubmit={submit}> | ||
<div className="mdn-form-item"> | ||
<label htmlFor="newsletter_email">Your email address:</label> | ||
|
||
<input | ||
type="email" | ||
name="email" | ||
required={true} | ||
placeholder="[email protected]" | ||
id="newsletter_email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
disabled={pending} | ||
/> | ||
</div> | ||
|
||
<div className="mdn-form-item"> | ||
<label htmlFor="newsletter_privacy"> | ||
<input | ||
type="checkbox" | ||
id="newsletter_privacy" | ||
name="privacy" | ||
required={true} | ||
disabled={pending} | ||
/>{" "} | ||
I’m okay with Mozilla handling my info as explained in this{" "} | ||
<a | ||
href="https://www.mozilla.org/en-US/privacy/websites/" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Privacy Notice | ||
</a> | ||
</label> | ||
</div> | ||
|
||
<div className="mdn-form-item"> | ||
<Button buttonType="submit" isDisabled={pending || isServer}> | ||
{error ? "Something went wrong, try again" : "Sign Up Now"} | ||
</Button> | ||
</div> | ||
</form> | ||
<></> | ||
)} | ||
</> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters