// Dependencies import { welcomeSteps } from './shared.mjs' import { linkClasses, 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 { NoIcon, OkIcon, SaveIcon } from '@freesewing/react/components/Icon' import { ListInput } from '@freesewing/react/components/Input' import { Popout } from '@freesewing/react/components/Popout' const strings = { yes: { title: 'Yes, in case it may help me', desc: 'Allowing us to compare your measurments to a baseline or others measurements sets ' + 'allows us to detect potential problems in your measurements or patterns.', }, no: { title: 'No, never compare', desc: 'We get it, comparison is the thief of joy. Just be aware that this limits our ability ' + 'to warn you about potential problems in your measurements sets or patterns.', }, } /* * Component for the account/preferences/consent page * * @params {object} props - All React props * @params {bool} props.signUp - Set to true to use this component on the initial signUp * @param {function} props.Link - An optional framework-specific Link component */ 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, body] = 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 (
{title ?

Privacy Matters

: null} {text.intro}
Do you give your consent to process your account data?
{text.account} {consent1 ? ( ) : ( )} {consent1 ? ( <>
Do you give your consent to share your anonymized measurements
{!consent2 ? {text.opendata} : null} ) : null} {!consent1 && This consent is required for a FreeSewing account.} {consent1 ? ( ) : signUp ? null : ( )}

FreeSewing Privacy Notice

) } const Checkbox = ({ value, setter, label, children = null }) => (
setter(value ? false : true)} >
setter(value ? false : true)} /> {label}
{children}
) const text = { intro: ( <>

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: (
What is account data?

Your email address, username, and password, and any measurements{' '} you add to your account.

Why do we need it?

To authenticate you, contact you when needed, and generate bespoke{' '} sewing patterns.

How long do we keep it?

12 months after the last time your connected to our backend, or until you{' '} remove your account or revoke this consent.

Do we share it with others?

No, never.

Note: Freesewing publishes anonymized measurements as open data for scientific research. You have the right to object to this.

), opendata: `This data is used to study and understand the human form in all its shapes, so we can get better sewing patterns, and better fitting garments. Even though this data is anonymized, you have the right to object to this.`, }