diff --git a/packages/web/components/EditProfileForm.tsx b/packages/web/components/EditProfileForm.tsx index b7023df3..96c1e282 100644 --- a/packages/web/components/EditProfileForm.tsx +++ b/packages/web/components/EditProfileForm.tsx @@ -1,18 +1,19 @@ import { Box, - Flex, Grid, GridItem, - Image, Input, + InputGroup, + InputLeftElement, + InputRightAddon, MetaFilterSelectSearch, MetaTheme, selectStyles, + SelectTimeZone, Text, } from '@metafam/ds'; -import React, { FC } from 'react'; +import React, { FC, useEffect, useState } from 'react'; -import BackgroundImage from '../assets/login-background.jpg'; import { MeType } from '../graphql/types'; import { TimeZoneOption } from '../utils/skillHelpers'; @@ -62,7 +63,7 @@ const DropdownStyles: typeof selectStyles = { export type ProfileEditorProps = { user: MeType; - address: string; + onClose?: () => void; }; export type ProfileSectionFormProps = { @@ -97,6 +98,7 @@ export const ProfileField: React.FC = ({ setInnerValue(e.target.value || '')} w="100%" @@ -158,7 +160,7 @@ export type TimezoneOption = { value: string; }; export type TimezoneSelectDropdownProps = { - timezone: TimeZoneOption; + timezone: TimeZoneOption | undefined; onChange: (timezone: TimezoneOption | null) => void; }; @@ -170,72 +172,93 @@ export const TIMEZONES_LIST: { [key: string]: string } = { export const TIMEZONES_OPTIONS = Object.keys(TIMEZONES_LIST).map( (key) => ({ value: key, label: TIMEZONES_LIST[key] } as TimezoneOption), ); -export const TimezoneSelectDropdown: FC = ({ - timezone, - onChange, -}) => ( - - - timezone - - - { - if (value) onChange(value as TimezoneOption); - }} - /> - - -); -export const EditProfileForm: React.FC = ({ user }) => { +export const EditProfileForm: React.FC = ({ + user, + onClose, +}) => { + const [timeZone, setTimeZone] = useState(''); + const [availability, setAvailability] = useState(''); + const [invalid, setInvalid] = useState(false); + + if (user?.player) { + const { player } = user; + if (player.timezone && !timeZone) { + setTimeZone(player.timezone); + } + if (player.availability_hours && !availability) { + setAvailability(player.availability_hours.toString()); + } + } + + useEffect(() => { + const value = Number(availability); + setInvalid(value < 0 || value > 168); + }, [availability]); + const GRID_SIZE = 2; const HALF = GRID_SIZE / 2; return ( - + - + {/* - + - + */} - - - + {/* + + + */} + + + + availability + + + + + 🕛 + + + ) => + setAvailability(e.target.value) + } + isInvalid={invalid} + /> + + hr/week + + - - + + timezone + + setTimeZone(tz.value)} + labelStyle="abbrev" /> + {/* = ({ user }) => { - + */} ); }; diff --git a/packages/web/components/Player/Section/PlayerHero.tsx b/packages/web/components/Player/Section/PlayerHero.tsx index 1432dade..f087c9a2 100644 --- a/packages/web/components/Player/Section/PlayerHero.tsx +++ b/packages/web/components/Player/Section/PlayerHero.tsx @@ -4,12 +4,22 @@ import { Flex, HStack, IconButton, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalHeader, + ModalOverlay, SimpleGrid, Text, + useDisclosure, VStack, } from '@metafam/ds'; +import BackgroundImage from 'assets/main-background.jpg'; +import { EditProfileForm } from 'components/EditProfileForm'; import { PlayerAvatar } from 'components/Player/PlayerAvatar'; import { PlayerFragmentFragment } from 'graphql/autogen/types'; +import { useUser } from 'lib/hooks'; import React, { useMemo } from 'react'; import { FaClock, FaGlobe } from 'react-icons/fa'; import { getPlayerTimeZoneDisplay } from 'utils/dateHelpers'; @@ -29,11 +39,13 @@ type TimeZoneDisplayProps = { timeZone?: string; offset?: string }; export const PlayerHero: React.FC = ({ player, isOwnProfile }) => { const description = getPlayerDescription(player); const [show, setShow] = React.useState(description.length <= MAX_BIO_LENGTH); + const { isOpen, onOpen, onClose } = useDisclosure(); const { timeZone, offset } = useMemo( () => getPlayerTimeZoneDisplay(player.timezone), [player.timezone], ); + const { user, fetching } = useUser(); return ( @@ -50,6 +62,7 @@ export const PlayerHero: React.FC = ({ player, isOwnProfile }) => { background="rgba(17, 17, 17, 0.9)" color="pinkShadeOne" _hover={{ color: 'white', borderColor: 'white' }} + onClick={onOpen} icon={} isRound _active={{ @@ -148,6 +161,37 @@ export const PlayerHero: React.FC = ({ player, isOwnProfile }) => { )} + + + + + + Edit Profile + + + + + + + ); }; diff --git a/packages/web/components/ProfileSection.tsx b/packages/web/components/ProfileSection.tsx index c68ca2b4..c4b5268b 100644 --- a/packages/web/components/ProfileSection.tsx +++ b/packages/web/components/ProfileSection.tsx @@ -101,7 +101,9 @@ export const ProfileSection: React.FC = ({