From c7fadef207291ce0c145772d511a85ef16aaffcb Mon Sep 17 00:00:00 2001 From: Leeward Bound Date: Tue, 28 Sep 2021 20:50:19 -0700 Subject: [PATCH] feat: temporary profile editor with beginning sections --- packages/web/components/MegaMenu.tsx | 7 +- .../web/components/TemporaryProfileEditor.tsx | 142 ++++++++++++++++++ packages/web/pages/profile/edit.tsx | 24 +++ 3 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 packages/web/components/TemporaryProfileEditor.tsx create mode 100644 packages/web/pages/profile/edit.tsx diff --git a/packages/web/components/MegaMenu.tsx b/packages/web/components/MegaMenu.tsx index cb369b46..2490d1b7 100644 --- a/packages/web/components/MegaMenu.tsx +++ b/packages/web/components/MegaMenu.tsx @@ -307,6 +307,9 @@ const PlayerStats: React.FC = ({ player }) => { const { disconnect } = useWeb3(); const { pSeedBalance } = usePSeedBalance(); + const hasEditedProfile = + player.username && player.username !== player.ethereum_address; + return ( = ({ player }) => { Edit Profile diff --git a/packages/web/components/TemporaryProfileEditor.tsx b/packages/web/components/TemporaryProfileEditor.tsx new file mode 100644 index 00000000..f89a0582 --- /dev/null +++ b/packages/web/components/TemporaryProfileEditor.tsx @@ -0,0 +1,142 @@ +import { + Box, + Flex, + Heading, + Image, + Input, + MetaBox, + MetaHeading, +} from '@metafam/ds'; +import React from 'react'; + +import AvatarImage from '../assets/avatar.png'; +import BackgroundImage from '../assets/login-background.jpg'; +import { MeType } from '../graphql/types'; + +export type ProfileEditorProps = { + user: MeType; + address: string; +}; + +export type ProfileSectionFormProps = { + title: string; +}; + +export type ProfileFieldProps = { + title: string; + placeholder?: string; + value?: string; +}; + +export const ProfileField: React.FC = ({ + title, + placeholder, + value, + children, +}) => { + const [innerValue, setInnerValue] = React.useState(value); + + React.useEffect(() => { + setInnerValue(value); + }, [value]); + + return ( + <> +
+ + {title} + + {!children ? ( + <> + setInnerValue(e.target.value || '')} + w="auto" + my={4} + /> +   + + ) : ( + <>{children || innerValue} + )} + + ); +}; + +export const ProfileFormSection: React.FC = ({ + title, + children, +}) => ( + /* We'll re-design this Section when it's time to place it in the Profile page */ + <> + +
{children}
+
+
+
+ +); + +export const TemporaryProfileEditor: React.FC = ({ + user, +}) => ( + <> + Edit Profile Form (temporary) + + + + + Avatar + + + + + + + + + + + + + + + + + + + + + + + + + + + background + + + + + + + + + ... + + ... + + ... + +); diff --git a/packages/web/pages/profile/edit.tsx b/packages/web/pages/profile/edit.tsx new file mode 100644 index 00000000..6435f14a --- /dev/null +++ b/packages/web/pages/profile/edit.tsx @@ -0,0 +1,24 @@ +import { PageContainer } from 'components/Container'; +import { TemporaryProfileEditor } from 'components/TemporaryProfileEditor'; +import React from 'react'; + +import { useUser, useWeb3 } from '../../lib/hooks'; + +const EditProfile: React.FC = () => { + const { address } = useWeb3(); + const { user } = useUser({ redirectTo: '/' }); + + if (user === null || user === undefined || address === null) + return ( + +

Loading...

+
+ ); + + return ( + + + + ); +}; +export default EditProfile;