diff --git a/src/components/AccountSidebar.astro b/src/components/AccountSidebar.astro index 440283fdf..1efb1dcb9 100644 --- a/src/components/AccountSidebar.astro +++ b/src/components/AccountSidebar.astro @@ -21,6 +21,16 @@ const sidebarLinks = [ classes: 'h-3 w-4', }, }, + { + href: '/account/friends', + title: 'Friends', + id: 'friends', + isNew: true, + icon: { + glyph: 'users', + classes: 'h-4 w-4', + }, + }, { href: '/account/road-card', title: 'Card', @@ -31,16 +41,6 @@ const sidebarLinks = [ classes: 'h-4 w-4', }, }, - // { - // href: '/account/friends', - // title: 'Friends', - // id: 'friends', - // isNew: true, - // icon: { - // glyph: 'users', - // classes: 'h-4 w-4', - // }, - // }, { href: '/account/update-profile', title: 'Profile', diff --git a/src/components/Friends/FriendProgressItem.tsx b/src/components/Friends/FriendProgressItem.tsx index a2598eb17..6b0445dd5 100644 --- a/src/components/Friends/FriendProgressItem.tsx +++ b/src/components/Friends/FriendProgressItem.tsx @@ -17,6 +17,8 @@ type FriendProgressItemProps = { export function FriendProgressItem(props: FriendProgressItemProps) { const { friend, onShowResourceProgress, onReload } = props; const toast = useToast(); + const [isConfirming, setIsConfirming] = + useState(); async function deleteFriend(userId: string, successMessage: string) { pageProgressMessage.set('Please wait...'); @@ -79,54 +81,95 @@ export function FriendProgressItem(props: FriendProgressItemProps) { {friend.status === 'accepted' && ( -
- {(showAll ? roadmaps : roadmaps.slice(0, 4)).map((progress) => { - return ( + <> +
+ {(showAll ? roadmaps : roadmaps.slice(0, 4)).map((progress) => { + return ( + + ); + })} + + {roadmaps.length > 4 && !showAll && ( - ); - })} + )} - {roadmaps.length > 4 && !showAll && ( - - )} + {showAll && ( + + )} - {showAll && ( - - )} + {roadmaps.length === 0 && ( +
No progress
+ )} +
+ <> + {isConfirming !== 'accepted' && ( + + )} - {roadmaps.length === 0 && ( -
No progress
- )} -
+ {isConfirming === 'accepted' && ( + + Are you sure?{' '} + {' '} + + + )} + + )} {friend.status === 'rejected' && ( diff --git a/src/components/Friends/FriendsPage.tsx b/src/components/Friends/FriendsPage.tsx index 28570cbb7..64ee8bb4e 100644 --- a/src/components/Friends/FriendsPage.tsx +++ b/src/components/Friends/FriendsPage.tsx @@ -9,6 +9,7 @@ import { EmptyFriends } from './EmptyFriends'; import { FriendProgressItem } from './FriendProgressItem'; import UserIcon from '../../icons/user.svg'; import { UserProgressModal } from '../UserProgress/UserProgressModal'; +import { InviteFriendPopup } from './InviteFriendPopup'; type FriendResourceProgress = { updatedAt: string; @@ -46,6 +47,8 @@ const groupingTypes: GroupingType[] = [ export function FriendsPage() { const toast = useToast(); + const [showInviteFriendPopup, setShowInviteFriendPopup] = useState(false); + const [showFriendProgress, setShowFriendProgress] = useState<{ resourceId: string; friend: ListFriendsResponse[0]; @@ -108,6 +111,13 @@ export function FriendsPage() { return (
+ {showInviteFriendPopup && ( + setShowInviteFriendPopup(false)} + /> + )} + {showFriendProgress && ( )} -
+
{groupingTypes.map((grouping) => { let requestCount = 0; @@ -131,7 +141,7 @@ export function FriendsPage() { selectedGrouping === grouping.value ? ' border-gray-400 bg-gray-200 ' : '' - }`} + } w-full sm:w-auto`} onClick={() => setSelectedGrouping(grouping.value)} > {grouping.label} @@ -144,14 +154,19 @@ export function FriendsPage() { ); })}
-
{filteredFriends.length > 0 && ( -
+
{filteredFriends.map((friend) => ( Invite your friends to join you on Roadmap

- diff --git a/src/components/Friends/InviteFriendPopup.tsx b/src/components/Friends/InviteFriendPopup.tsx new file mode 100644 index 000000000..908b57047 --- /dev/null +++ b/src/components/Friends/InviteFriendPopup.tsx @@ -0,0 +1,64 @@ +import { useEffect, useRef } from 'preact/hooks'; +import { useOutsideClick } from '../../hooks/use-outside-click'; +import CopyIcon from '../../icons/copy.svg'; +import { useCopyText } from '../../hooks/use-copy-text'; + +type InviteFriendPopupProps = { + befriendUrl: string; + onClose: () => void; +}; + +export function InviteFriendPopup(props: InviteFriendPopupProps) { + const { onClose, befriendUrl } = props; + + const { isCopied, copyText } = useCopyText(); + + const popupBodyRef = useRef(null); + + const handleClosePopup = () => { + onClose(); + }; + + useOutsideClick(popupBodyRef, handleClosePopup); + + return ( + + ); +} diff --git a/src/components/Navigation/AccountDropdown.astro b/src/components/Navigation/AccountDropdown.astro index 5bf41d382..c23bb4db5 100644 --- a/src/components/Navigation/AccountDropdown.astro +++ b/src/components/Navigation/AccountDropdown.astro @@ -30,6 +30,14 @@ import Icon from '../AstroIcon.astro'; Profile +
  • + + Friends + +