From 74d2cd8d03b3d40e5f9548a5680818cb79f6f3b1 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Wed, 28 Dec 2022 12:37:09 -0800 Subject: [PATCH] Feat/um 140 password modal (#1718) * Change password to modal. * Close on save. --- components/forms/UserPasswordForm.js | 5 +-- components/pages/Dashboard.js | 4 +-- components/pages/ProfileSettings.js | 27 ++++++++++++++-- components/pages/UserSettings.js | 31 +++++++++++++++++-- .../{WebsiteList.js => WebsiteChartList.js} | 0 components/settings/ProfileDetails.js | 2 +- ...s.module.css => ProfileDetails.module.css} | 0 7 files changed, 58 insertions(+), 11 deletions(-) rename components/pages/{WebsiteList.js => WebsiteChartList.js} (100%) rename components/settings/{ProfileSettings.module.css => ProfileDetails.module.css} (100%) diff --git a/components/forms/UserPasswordForm.js b/components/forms/UserPasswordForm.js index 748f462b..c28d9624 100644 --- a/components/forms/UserPasswordForm.js +++ b/components/forms/UserPasswordForm.js @@ -6,7 +6,7 @@ import { getClientAuthToken } from 'lib/client'; import styles from './UserPasswordForm.module.css'; import useUser from 'hooks/useUser'; -export default function UserPasswordForm({ onSave, userId }) { +export default function UserPasswordForm({ onSave, onClose, userId }) { const { user: { id }, } = useUser(); @@ -68,9 +68,10 @@ export default function UserPasswordForm({ onSave, userId }) { - + ); diff --git a/components/pages/Dashboard.js b/components/pages/Dashboard.js index 343ac3f7..452288dd 100644 --- a/components/pages/Dashboard.js +++ b/components/pages/Dashboard.js @@ -2,7 +2,7 @@ import { useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import Page from 'components/layout/Page'; import PageHeader from 'components/layout/PageHeader'; -import WebsiteList from 'components/pages/WebsiteList'; +import WebsiteChartList from 'components/pages/WebsiteChartList'; import { Button } from 'react-basics'; import DashboardSettingsButton from 'components/settings/DashboardSettingsButton'; import useFetch from 'hooks/useFetch'; @@ -37,7 +37,7 @@ export default function Dashboard({ userId }) { {!editing && } {editing && } - {!editing && } + {!editing && } {max < data.length && ( General - Password {tab === 'general' && } - {tab === 'password' && } + {edit && ( + + {close => } + + )} ); } diff --git a/components/pages/UserSettings.js b/components/pages/UserSettings.js index b74164a9..f53678ce 100644 --- a/components/pages/UserSettings.js +++ b/components/pages/UserSettings.js @@ -9,9 +9,11 @@ import useApi from 'hooks/useApi'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; -import { Breadcrumbs, Item, Tabs, useToast } from 'react-basics'; +import { Breadcrumbs, Item, Icon, Tabs, useToast, Modal, Button } from 'react-basics'; +import Pen from 'assets/pen.svg'; export default function UserSettings({ userId }) { + const [edit, setEdit] = useState(false); const [values, setValues] = useState(null); const [tab, setTab] = useState('general'); const { get } = useApi(getClientAuthToken()); @@ -32,6 +34,18 @@ export default function UserSettings({ userId }) { if (data) { setValues(state => ({ ...state, ...data })); } + + if (edit) { + setEdit(false); + } + }; + + const handleAdd = () => { + setEdit(true); + }; + + const handleClose = () => { + setEdit(false); }; const handleDelete = async () => { @@ -55,15 +69,26 @@ export default function UserSettings({ userId }) { {values?.username} + General - Password Danger Zone {tab === 'general' && } - {tab === 'password' && } {tab === 'delete' && } + {edit && ( + + {close => ( + + )} + + )} ); } diff --git a/components/pages/WebsiteList.js b/components/pages/WebsiteChartList.js similarity index 100% rename from components/pages/WebsiteList.js rename to components/pages/WebsiteChartList.js diff --git a/components/settings/ProfileDetails.js b/components/settings/ProfileDetails.js index c77b946b..a8d37595 100644 --- a/components/settings/ProfileDetails.js +++ b/components/settings/ProfileDetails.js @@ -4,7 +4,7 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; import DateRangeSetting from './DateRangeSetting'; import LanguageSetting from './LanguageSetting'; -import styles from './ProfileSettings.module.css'; +import styles from './ProfileDetails.module.css'; import ThemeSetting from './ThemeSetting'; export default function ProfileDetails() { diff --git a/components/settings/ProfileSettings.module.css b/components/settings/ProfileDetails.module.css similarity index 100% rename from components/settings/ProfileSettings.module.css rename to components/settings/ProfileDetails.module.css