From be82b3dd082a750a540ee126ae7c9402aa0b41b2 Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Mon, 7 Aug 2023 17:08:33 -0400 Subject: [PATCH] feat: add user profile --- src/auth/views/Login.tsx | 2 +- src/auth/views/MagicLink.tsx | 2 +- src/components/AppBar/LandingPageAppBar.tsx | 1 - src/components/Drawer/MiniSideBar.tsx | 60 +++++++++-- src/components/Navigation/DraftMenu.tsx | 28 +++-- src/components/Navigation/Navbar.tsx | 7 +- src/components/Steps/ActionButtons.tsx | 8 +- src/theme.tsx | 8 ++ src/user/hooks/useGenerateApiKey.tsx | 45 ++++++++ src/user/settings/NewKeyPairModal.tsx | 13 +-- src/user/settings/Settings.tsx | 60 ++++++----- src/user/settings/UserApiKey.tsx | 112 ++++++++++++++++++++ src/user/settings/UserForm.tsx | 4 +- src/user/views/user/Profile.tsx | 16 +-- 14 files changed, 289 insertions(+), 77 deletions(-) create mode 100644 src/user/hooks/useGenerateApiKey.tsx create mode 100644 src/user/settings/UserApiKey.tsx diff --git a/src/auth/views/Login.tsx b/src/auth/views/Login.tsx index 450892da..63b8da9b 100644 --- a/src/auth/views/Login.tsx +++ b/src/auth/views/Login.tsx @@ -45,7 +45,7 @@ export function Login() { color="primary" size="large" variant="contained" - sx={{ mt: 2, textTransform: "none", mb: 1 }} + sx={{ mt: 2, mb: 1 }} disabled={loading} loading={loading} onClick={() => { diff --git a/src/auth/views/MagicLink.tsx b/src/auth/views/MagicLink.tsx index c5a1337a..500edd2c 100644 --- a/src/auth/views/MagicLink.tsx +++ b/src/auth/views/MagicLink.tsx @@ -66,7 +66,7 @@ export function MagicLink() { color="primary" size="large" variant="contained" - sx={{ mt: 2, textTransform: "none", mb: 1 }} + sx={{ mt: 2, mb: 1 }} disabled={loading} loading={loading} onClick={() => { diff --git a/src/components/AppBar/LandingPageAppBar.tsx b/src/components/AppBar/LandingPageAppBar.tsx index 820258c8..544f9a96 100644 --- a/src/components/AppBar/LandingPageAppBar.tsx +++ b/src/components/AppBar/LandingPageAppBar.tsx @@ -97,7 +97,6 @@ function AuthedButton(props: { isAuthenticated?: boolean }) { setAnchorEl(null)}> )} - diff --git a/src/components/Steps/ActionButtons.tsx b/src/components/Steps/ActionButtons.tsx index 009fce71..527a9ca2 100644 --- a/src/components/Steps/ActionButtons.tsx +++ b/src/components/Steps/ActionButtons.tsx @@ -12,18 +12,14 @@ export function ActionButtons() { return ( - {values.draftId !== undefined && ( + + setOpen(false)} maxWidth="lg"> + + {data ? "New API Key" : "Generate a new API key?"} + + + {!data && ( + + Generating a new API key will result in the deactivation of your + previous key, rendering it unusable for future requests. Make sure + to update your code with the new key to avoid disruptions in your + application's functionality. + + )} + {data && ( + + + This key is unique to you, make sure to safely store it and + avoid sharing it with others to prevent unauthorized access. + + + {data} + + window.navigator.clipboard + .writeText(data) + .then(() => alert("Key copied")) + } + sx={{ ml: 1 }} + > + + + + + )} + + + + {!data && ( + generate(advertiser.id)} + > + Generate + + )} + + + + ); +} diff --git a/src/user/settings/UserForm.tsx b/src/user/settings/UserForm.tsx index 9a0db58f..b7f945b5 100644 --- a/src/user/settings/UserForm.tsx +++ b/src/user/settings/UserForm.tsx @@ -14,7 +14,7 @@ export function UserForm() { const [initialVals, setInitialVals] = useState(user); if (!user.userId) { - const details = "Unable to get user information"; + const details = "Unable to get profile information"; return ; } @@ -25,7 +25,7 @@ export function UserForm() { }); return ( - + -
- - - + + +
+ +
+ + + ); }