From 3390333e741c08ada1aa8d47ce19f88eba67a07f Mon Sep 17 00:00:00 2001 From: Ben Derham <1805685+benderham@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:29:53 +0800 Subject: [PATCH 1/8] updates auth newsletter subscription form --- packages/auth/src/pages/InitPage.tsx | 98 ++++++++++++++++++---------- 1 file changed, 63 insertions(+), 35 deletions(-) diff --git a/packages/auth/src/pages/InitPage.tsx b/packages/auth/src/pages/InitPage.tsx index cc92c2ee987..ad0436efd30 100644 --- a/packages/auth/src/pages/InitPage.tsx +++ b/packages/auth/src/pages/InitPage.tsx @@ -4,9 +4,9 @@ import { useMemo, useState } from 'react' import fetch from 'cross-fetch' -import { jsx, H1, Stack, Inline, VisuallyHidden } from '@keystone-ui/core' +import { jsx, H1, Stack, Inline } from '@keystone-ui/core' import { Button } from '@keystone-ui/button' -import { Checkbox, TextInput } from '@keystone-ui/fields' +import { Checkbox, FieldLabel, TextInput } from '@keystone-ui/fields' import { type FieldMeta } from '@keystone-6/core/types' import isDeepEqual from 'fast-deep-equal' @@ -24,10 +24,15 @@ import { IconTwitter, IconGithub } from '../components/Icons' import { SigninContainer } from '../components/SigninContainer' import { useRedirect } from '../lib/useFromRedirect' -const signupURL = 'https://signup.keystonejs.cloud/api/newsletter-signup' +const signupURL = 'https://endpoints.thinkmill.com.au/newsletter' function Welcome ({ value, onContinue }: { value: any, onContinue: () => void }) { - const [subscribe, setSubscribe] = useState(false) + const [subscribe, setSubscribe] = useState<{ keystone: boolean, thinkmill: boolean}>( + { + keystone: false, + thinkmill: false, + } + ) const [email, setEmail] = useState(guessEmailFromValue(value)) const [error, setError] = useState(null) const [loading, setLoading] = useState(false) @@ -45,15 +50,18 @@ function Welcome ({ value, onContinue }: { value: any, onContinue: () => void }) return } + const tags = [ '@keystone-6/auth' ] + if (subscribe.keystone) tags.push('keystone_list') + if (subscribe.thinkmill) tags.push('thinkmill_list') + const res = await fetch(signupURL, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ - name: value.username, email, - source: '@keystone-6/auth InitPage', + tags, }), }) @@ -76,7 +84,7 @@ function Welcome ({ value, onContinue }: { value: any, onContinue: () => void }) } return ( - + void }) >

Welcome

- void })

- Thanks for installing KeystoneJS. While you're getting started, check out the docs at{' '} + Thanks for installing Keystone. For help getting started check out the docs at{' '} keystonejs.com

-
- If you'd like to stay up to date with the exciting things we have planned, join our mailing - list (just useful announcements, no spam!) -
-
- { - setError(null) - setSubscribe(!subscribe) - }} - > - sign up to our mailing list - -
+ +

+ To stay connected to the latest Keystone and Thinkmill news, signup to our newsletters: +

+
- - Email Address - - setEmail(e.target.value)} - /> + + Email + setEmail(e.target.value)} + /> + + { + setError(null) + setSubscribe((prevState) => ({ ...prevState, keystone: !subscribe.keystone })) + }} + > + Keystone news + + { + setError(null) + setSubscribe((prevState) => ({ ...prevState, thinkmill: !subscribe.thinkmill })) + }} + > + Thinkmill news ( + + example + + ) + + +

{error}