// Dependencies import { navigate } 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 { Popout } from '@freesewing/react/components/Popout' /** * A component to manage the user's consent setting * * @component * @param {object} props - All component props * @param {bool} [props.signUp = false] - Set to true to use this component on the initial signUp * @param {function} [props.Link = false] - An optional framework-specific Link component * @returns {JSX.Element} */ export const Consent = ({ signUp = false, Link = false, title = false }) => { if (!Link) Link = WebLink // Hooks const backend = useBackend() const { account, setAccount, setToken } = useAccount() const { setLoadingStatus } = useContext(LoadingStatusContext) // State const [consent1, setConsent1] = useState(account?.consent > 0) const [consent2, setConsent2] = useState(account?.consent > 1) // Helper method to update the account const update = async () => { let newConsent = 0 if (consent1) newConsent = 1 if (consent1 && consent2) newConsent = 2 if (newConsent > 0 && signUp) { setLoadingStatus([true, 'Creating your account']) const [status, body] = await backend.confirmSignup({ id: signUp, consent: newConsent }) if (status === 200) { setLoadingStatus([true, 'Account created', true, true]) if (body?.token) setToken(body.token) if (body?.account) setAccount(body.account) navigate('/welcome') } else setLoadingStatus([true, 'An error occured, please report this', true, true]) } else if (newConsent !== account.consent) { setLoadingStatus([true, 'Updating your account']) const [status, body] = await backend.updateAccount({ consent: newConsent }) if (status === 200) { setLoadingStatus([true, 'Account updated', true, true]) setAccount(body.account) } else setLoadingStatus([true, 'An error occured, please report this', true, true]) } } // Helper method to remove the account const removeAccount = async () => { setLoadingStatus([true, 'One moment please']) const [status] = await backend.removeAccount() if (status === 200) { setLoadingStatus([true, 'All done, farewell', true, true]) setToken(null) setAccount({ username: false }) } else setLoadingStatus([true, 'Something went wrong. Please report this.', true, true]) } return (
FreeSewing Privacy Notice
FreeSewing respects your privacy and your rights. We adhere to the toughest privacy and security law in the world: the{' '} General Data Protection Regulation {' '} (GDPR) of the European Union (EU).
Under the GDPR, processing of your personal data requires granular consent — in other words,{' '} we need your permission for the various ways we handle your data.
> ), account: (Your email address, username, and password, and any measurements{' '} you add to your account.
To authenticate you, contact you when needed, and generate bespoke{' '} sewing patterns.
12 months after the last time your connected to our backend, or until you{' '} remove your account or revoke this consent.
No, never.
Note: Freesewing publishes anonymized measurements as open data for scientific research. You have the right to object to this.