// Dependencies import { welcomeSteps } from './shared.mjs' import { linkClasses } from '@freesewing/utils' // Context import { LoadingStatusContext } from '@freesewing/react/context/LoadingStatus' // Hooks import React, { useState, useContext } from 'react' import { useAccount } from '@freesewing/react/hooks/useAccount' import { useBackend } from '@freesewing/react/hooks/useBackend' // Components import { Link as WebLink } from '@freesewing/react/components/Link' import { NoIcon, OkIcon, RightIcon } from '@freesewing/react/components/Icon' import { ListInput } from '@freesewing/react/components/Input' import { Popout } from '@freesewing/react/components/Popout' import { IconButton } from '@freesewing/react/components/Button' import { WelcomeIcons } from './shared.mjs' /** * A component to manage the user's newsletter subscription in their account data * * @component * @params {object} props - All Component props * @param {bool} props.welcome - Set to true to use this component on the welcome page * @param {React.Component} props.Link - An optional framework-specific Link component * @returns {JSX.Element} */ export const Newsletter = ({ welcome = false, Link = false }) => { if (!Link) Link = WebLink // Hooks const { account, setAccount } = useAccount() const backend = useBackend() const { setLoadingStatus } = useContext(LoadingStatusContext) // State const [selection, setSelection] = useState(account?.newsletter ? 'yes' : 'no') // Helper method to update account const update = async (val) => { if (val !== selection) { setLoadingStatus([true, 'Saving preferences']) const [status, body] = await backend.updateAccount({ newsletter: val === 'yes' ? true : false, }) if (status === 200) { setLoadingStatus([true, 'Preferences saved', true, true]) setAccount(body.account) setSelection(val) } else setLoadingStatus([true, 'An error occured. Please report this.', true, true]) } } // Next step for onboarding const nextHref = welcomeSteps[account?.control].length > 2 ? '/welcome/' + welcomeSteps[account?.control][2] : '/docs/about/guide' return (
This unsubscribe link will also be included at the bottom of every newsletter we send you, so you do not need to bookmark it, but you can if you want to.
Unsubscribe link
This link is to unsubscribe you specifically, do not share it with other subscribers.