From b47f712dec8a37d9a66b3695c37387e9ed96759b Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Thu, 9 Nov 2023 21:28:45 +0000 Subject: [PATCH] Friends and notification pages --- src/components/Friends/FriendsPage.tsx | 19 ++--- src/components/Friends/InviteFriendPopup.tsx | 4 +- .../Notification/NotificationPage.tsx | 74 +++++++++++-------- src/components/ReactIcons/AcceptIcon.tsx | 24 ++++++ .../TeamProgress/GroupRoadmapItem.tsx | 10 +-- 5 files changed, 82 insertions(+), 49 deletions(-) create mode 100644 src/components/ReactIcons/AcceptIcon.tsx diff --git a/src/components/Friends/FriendsPage.tsx b/src/components/Friends/FriendsPage.tsx index 3c3c353e3..0c8a50b95 100644 --- a/src/components/Friends/FriendsPage.tsx +++ b/src/components/Friends/FriendsPage.tsx @@ -7,10 +7,10 @@ import type { FriendshipStatus } from '../Befriend'; import { useToast } from '../../hooks/use-toast'; import { EmptyFriends } from './EmptyFriends'; import { FriendProgressItem } from './FriendProgressItem'; -import UserIcon from '../../icons/user.svg'; import { UserProgressModal } from '../UserProgress/UserProgressModal'; import { InviteFriendPopup } from './InviteFriendPopup'; import { UserCustomProgressModal } from '../UserProgress/UserCustomProgressModal'; +import { UserIcon } from '../ReactIcons/UserIcon.tsx'; type FriendResourceProgress = { updatedAt: string; @@ -64,7 +64,7 @@ export function FriendsPage() { async function loadFriends() { const { response, error } = await httpGet( - `${import.meta.env.PUBLIC_API_URL}/v1-list-friends` + `${import.meta.env.PUBLIC_API_URL}/v1-list-friends`, ); if (error || !response) { @@ -89,15 +89,15 @@ export function FriendsPage() { const befriendUrl = `${baseUrl}/befriend?u=${user?.id}`; const selectedGroupingType = groupingTypes.find( - (grouping) => grouping.value === selectedGrouping + (grouping) => grouping.value === selectedGrouping, ); - const filteredFriends = friends.filter((friend) => - selectedGroupingType?.statuses.includes(friend.status) + const filteredFriends = friends.filter( + (friend) => selectedGroupingType?.statuses.includes(friend.status), ); const receivedRequests = friends.filter( - (friend) => friend.status === 'received' + (friend) => friend.status === 'received', ); if (isLoading) { @@ -203,11 +203,8 @@ export function FriendsPage() { {filteredFriends.length === 0 && (
- Empty Friends + +

{selectedGrouping === 'active' && 'No friends yet'} {selectedGrouping === 'sent' && 'No requests sent'} diff --git a/src/components/Friends/InviteFriendPopup.tsx b/src/components/Friends/InviteFriendPopup.tsx index 255e13a85..2121a3ff8 100644 --- a/src/components/Friends/InviteFriendPopup.tsx +++ b/src/components/Friends/InviteFriendPopup.tsx @@ -2,7 +2,7 @@ import type { MouseEvent } from 'react'; import { useRef } from 'react'; import { useOutsideClick } from '../../hooks/use-outside-click'; import { useCopyText } from '../../hooks/use-copy-text'; -import { Copy } from 'lucide-react'; +import { CopyIcon } from 'lucide-react'; type InviteFriendPopupProps = { befriendUrl: string; @@ -54,7 +54,7 @@ export function InviteFriendPopup(props: InviteFriendPopupProps) { copyText(befriendUrl); }} > - + {isCopied ? 'Copied' : 'Copy URL'}

diff --git a/src/components/Notification/NotificationPage.tsx b/src/components/Notification/NotificationPage.tsx index 754f04662..689f16279 100644 --- a/src/components/Notification/NotificationPage.tsx +++ b/src/components/Notification/NotificationPage.tsx @@ -1,10 +1,10 @@ import { useEffect, useState } from 'react'; -import { httpGet, httpPatch, httpPost } from '../../lib/http'; +import { httpGet, httpPatch } from '../../lib/http'; import { pageProgressMessage } from '../../stores/page'; import type { TeamMemberDocument } from '../TeamMembers/TeamMembersPage'; import XIcon from '../../icons/close-dark.svg'; -import AcceptIcon from '../../icons/accept.svg'; import { useToast } from '../../hooks/use-toast'; +import { AcceptIcon } from '../ReactIcons/AcceptIcon.tsx'; interface NotificationList extends TeamMemberDocument { name: string; @@ -18,7 +18,7 @@ export function NotificationPage() { const lostNotifications = async () => { const { error, response } = await httpGet( - `${import.meta.env.PUBLIC_API_URL}/v1-get-invitation-list` + `${import.meta.env.PUBLIC_API_URL}/v1-get-invitation-list`, ); if (error || !response) { toast.error(error?.message || 'Something went wrong'); @@ -28,28 +28,37 @@ export function NotificationPage() { setNotifications(response); }; - async function respondInvitation(status: 'accept' | 'reject', inviteId: string) { + async function respondInvitation( + status: 'accept' | 'reject', + inviteId: string, + ) { setIsLoading(true); setError(''); const { response, error } = await httpPatch<{ teamId: string }>( - `${import.meta.env.PUBLIC_API_URL}/v1-respond-invite/${inviteId}`, { - status - }); + `${import.meta.env.PUBLIC_API_URL}/v1-respond-invite/${inviteId}`, + { + status, + }, + ); if (error || !response) { - setError(error?.message || 'Something went wrong') - setIsLoading(false) + setError(error?.message || 'Something went wrong'); + setIsLoading(false); return; } if (status === 'accept') { window.location.href = `/team/progress?t=${response.teamId}`; } else { - window.dispatchEvent(new CustomEvent('refresh-notification', { - detail: { - count: notifications.length - 1 - } - })); - setNotifications(notifications.filter((notification) => notification._id !== inviteId)); + window.dispatchEvent( + new CustomEvent('refresh-notification', { + detail: { + count: notifications.length - 1, + }, + }), + ); + setNotifications( + notifications.filter((notification) => notification._id !== inviteId), + ); setIsLoading(false); } } @@ -66,15 +75,20 @@ export function NotificationPage() {

Notification

Manage your notifications

- { - notifications.length === 0 && ( -
-

- No notifications, you can create a team and invite your friends to join. -

-
- ) - } + {notifications.length === 0 && ( +
+

+ No notifications, you can{' '} + + create a team + {' '} + and invite your friends to join. +

+
+ )}
{notifications.map((notification) => (
@@ -86,16 +100,18 @@ export function NotificationPage() {
- -
@@ -58,7 +54,7 @@ export function GroupRoadmapItem(props: GroupRoadmapItemProps) { onClick={() => { onShowResourceProgress( member.member, - member.progress?.resourceId! + member.progress?.resourceId!, ); }} >