From 77a50b4f17005cf4cc6a825beb20c2d14cd94677 Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Sat, 5 Dec 2020 18:04:11 +1100 Subject: [PATCH] issue-129 tweaks after deploy test --- web/src/Routes.js | 1 - web/src/components/InputText/InputText.js | 2 +- web/src/components/LoginModal/LoginModal.js | 6 ++++++ web/src/helpers/subscribe.js | 15 +++++++++++++++ web/src/layouts/MainLayout/MainLayout.js | 4 ---- .../UpdatePasswordPage/UpdatePasswordPage.js | 16 ++++++---------- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 web/src/helpers/subscribe.js diff --git a/web/src/Routes.js b/web/src/Routes.js index 5ed59d0..dbb6777 100644 --- a/web/src/Routes.js +++ b/web/src/Routes.js @@ -33,7 +33,6 @@ const Routes = () => { return ( - {/* */} diff --git a/web/src/components/InputText/InputText.js b/web/src/components/InputText/InputText.js index 6ab83bc..3198506 100644 --- a/web/src/components/InputText/InputText.js +++ b/web/src/components/InputText/InputText.js @@ -10,7 +10,7 @@ const InputText = ({ value, isEditable, onChange, className }) => { className )} > -
+
{ const { logIn, signUp } = useAuth() + const { addMessage } = useFlash() const [tab, setTab] = useState(shouldStartWithSignup ? 0 : 1) const onTabChange = (_, newValue) => { @@ -22,6 +25,9 @@ const LoginModal = ({ open, onClose, shouldStartWithSignup = false }) => { const onSubmitSignUp = async ({ email, password, name, userName }) => { try { setError('') + if (checkBox) { + subscribe({ email, addMessage }) + } await signUp({ email, password, diff --git a/web/src/helpers/subscribe.js b/web/src/helpers/subscribe.js new file mode 100644 index 0000000..7a21875 --- /dev/null +++ b/web/src/helpers/subscribe.js @@ -0,0 +1,15 @@ +export const subscribe = ({ email, addMessage }) => { + // subscribe to mailchimp newsletter + const path = window.location.hostname + window.location.pathname + try { + fetch( + `https://kurthutten.us10.list-manage.com/subscribe/post-json?u=cbd8888e924bdd99d06c14fa5&id=6a765a8b3d&EMAIL=${email}&FNAME=Kurt&PATHNAME=${path}&c=__jp0` + ) + } catch (e) { + setTimeout(() => { + addMessage('Problem subscribing to newsletter', { + classes: 'bg-red-300 text-red-900', + }) + }, 1000) + } +} diff --git a/web/src/layouts/MainLayout/MainLayout.js b/web/src/layouts/MainLayout/MainLayout.js index 675e7de..a195131 100644 --- a/web/src/layouts/MainLayout/MainLayout.js +++ b/web/src/layouts/MainLayout/MainLayout.js @@ -103,10 +103,6 @@ const MainLayout = ({ children }) => { }) }) } else if (key === 'recovery_token') { - // http://localhost:8910/#recovery_token=LwsC-KpgmiDwGo-ZcGH0tA - // https://mandrillapp.com/track/click/31128206/cadhub.xyz?p=eyJzIjoiWFlFbDk5YTVYU0FOSmEtZ3ZtUXlDSW13QURrIiwidiI6MSwicCI6IntcInVcIjozMTEyODIwNixcInZcIjoxLFwidXJsXCI6XCJodHRwczpcXFwvXFxcL2NhZGh1Yi54eXpcXFwvI3JlY292ZXJ5X3Rva2VuPUx3c0MtS3BnbWlEd0dvLVpjR0gwdEFcIixcImlkXCI6XCJjODU1ZWM1MjZiZmQ0Y2JmYmUyNmM4OTk2ZGU4ODczOFwiLFwidXJsX2lkc1wiOltcIjJkMjljMDI0NTY5MzcxODcxMmI0ODA0M2U3MDYyOTA1ZDc1NzVkNjlcIl19In0 - // #recovery_token=LwsC-KpgmiDwGo-ZcGH0tA - // navigate(routes.updatePassword({ recoveryToken: token })) client .recover(token, true) .then(() => { diff --git a/web/src/pages/UpdatePasswordPage/UpdatePasswordPage.js b/web/src/pages/UpdatePasswordPage/UpdatePasswordPage.js index d198ee0..48008d1 100644 --- a/web/src/pages/UpdatePasswordPage/UpdatePasswordPage.js +++ b/web/src/pages/UpdatePasswordPage/UpdatePasswordPage.js @@ -11,7 +11,7 @@ const UpdatePasswordPage = () => { const { addMessage } = useFlash() const { client } = useAuth() const onSubmit = ({ password, confirm }) => { - if (password !== confirm) { + if (password !== confirm || !password) { addMessage("Passwords don't match, try again", { classes: 'bg-red-300 text-red-900', }) @@ -21,24 +21,20 @@ const UpdatePasswordPage = () => { .currentUser() .update({ password }) .then(() => { - addMessage('Email updated', { classes: 'rw-flash-success' }) + addMessage('Password updated', { classes: 'rw-flash-success' }) setTimeout(() => { navigate(routes.home()) }, 500) }) .catch(() => { - addMessage('Problem updating email', { + addMessage('Problem updating password', { classes: 'bg-red-300 text-red-900', }) }) } return ( - +

Reset Password

@@ -52,7 +48,7 @@ const UpdatePasswordPage = () => { {