From 9ed60d836afe1920c3208daed18a62944fa1ed8c Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 4 Aug 2023 18:23:43 +0100 Subject: [PATCH] Add friends invite page --- src/components/AccountSidebar.astro | 10 ++++ src/components/Authenticator/authenticator.ts | 3 +- src/components/Friends/EmptyFriends.tsx | 48 +++++++++++++++++++ src/components/Friends/FriendsPage.tsx | 34 +++++++++++++ src/icons/user-plus.svg | 1 + src/pages/account/friends.astro | 15 ++++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 src/components/Friends/EmptyFriends.tsx create mode 100644 src/components/Friends/FriendsPage.tsx create mode 100644 src/icons/user-plus.svg create mode 100644 src/pages/account/friends.astro diff --git a/src/components/AccountSidebar.astro b/src/components/AccountSidebar.astro index ca3c72acb..440283fdf 100644 --- a/src/components/AccountSidebar.astro +++ b/src/components/AccountSidebar.astro @@ -31,6 +31,16 @@ 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/Authenticator/authenticator.ts b/src/components/Authenticator/authenticator.ts index 91860b30e..9ec312c58 100644 --- a/src/components/Authenticator/authenticator.ts +++ b/src/components/Authenticator/authenticator.ts @@ -37,13 +37,14 @@ function handleGuest() { '/account/update-password', '/account/settings', '/account/road-card', + '/account/friends', '/account', '/team', '/team/progress', '/team/roadmaps', '/team/new', '/team/members', - '/team/settings' + '/team/settings', ]; showHideAuthElements('hide'); diff --git a/src/components/Friends/EmptyFriends.tsx b/src/components/Friends/EmptyFriends.tsx new file mode 100644 index 000000000..1c9fdc0f0 --- /dev/null +++ b/src/components/Friends/EmptyFriends.tsx @@ -0,0 +1,48 @@ +import UserPlusIcon from '../../icons/user-plus.svg'; +import CopyIcon from '../../icons/copy.svg'; +import { useAuth } from '../../hooks/use-auth'; +import { useCopyText } from '../../hooks/use-copy-text'; + +export function EmptyFriends() { + const user = useAuth(); + const { isCopied, copyText } = useCopyText(); + const befriendUrl = `https://roadmap.sh/befriend?u=${user?.id}`; + + return ( +
+
+ no friends +

Invite your Friends

+

+ Share the link below with your friends to invite them +

+ +
+ { + e.currentTarget.select(); + copyText(befriendUrl); + }} + type="text" + value={befriendUrl} + class="w-full border-none bg-transparent px-1.5 outline-none" + readonly + /> + +
+
+
+ ); +} diff --git a/src/components/Friends/FriendsPage.tsx b/src/components/Friends/FriendsPage.tsx new file mode 100644 index 000000000..36237aad9 --- /dev/null +++ b/src/components/Friends/FriendsPage.tsx @@ -0,0 +1,34 @@ +import { useEffect, useState } from 'preact/hooks'; +import CopyIcon from '../../icons/copy.svg'; +import UserPlus from '../../icons/user-plus.svg'; +import { pageProgressMessage } from '../../stores/page'; +import { useAuth } from '../../hooks/use-auth'; +import {EmptyFriends} from "./EmptyFriends"; + +export function FriendsPage() { + const user = useAuth(); + + useEffect(() => { + pageProgressMessage.set(''); + }, []); + + const baseUrl = import.meta.env.DEV + ? 'http://localhost:3000' + : 'https://roadmap.sh'; + const befriendUrl = `${baseUrl}/befriend?u=${user?.id}`; + + return + return ( +
+
+ + You have 4 friends on Roadmap.sh + + +
+
+ ); +} diff --git a/src/icons/user-plus.svg b/src/icons/user-plus.svg new file mode 100644 index 000000000..e2893d04a --- /dev/null +++ b/src/icons/user-plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/pages/account/friends.astro b/src/pages/account/friends.astro new file mode 100644 index 000000000..8a7fed1e1 --- /dev/null +++ b/src/pages/account/friends.astro @@ -0,0 +1,15 @@ +--- +import AccountSidebar from '../../components/AccountSidebar.astro'; +import AccountLayout from '../../layouts/AccountLayout.astro'; +import { FriendsPage } from '../../components/Friends/FriendsPage'; +--- + + + + + +