diff --git a/components/Dashboard/Links.tsx b/components/Dashboard/Links.tsx
index aaecb52..fae5aab 100644
--- a/components/Dashboard/Links.tsx
+++ b/components/Dashboard/Links.tsx
@@ -93,8 +93,8 @@ export default function Links() {
const allLinks = Array.from(linksMap.values());
const meLinks = allLinks.filter((link) => {
- // if archived, don't show
- if (link.state == LinkState.archived) {
+ // if archived or deleted, don't show
+ if (link.state != LinkState.active) {
return false;
}
@@ -112,7 +112,7 @@ export default function Links() {
});
const teamLinks = allLinks.filter((link) => {
// not archived and does not have a recipients list
- if (link.state != LinkState.archived && !link.recipients) {
+ if (link.state == LinkState.active && !link.recipients) {
return true;
}
return false;
@@ -158,21 +158,6 @@ export default function Links() {
- {/* tab pane */}
- {/*
-
- Team
-
-
-
- Personal
-
-
-
- Favorites
-
- */}
-
Week
@@ -208,27 +193,27 @@ export default function Links() {
>
{LinkTypeFilter.me}{" "}
- {/*
- {meRooms.length > 0 ? meRooms.length : ""}
- */}
+
+ {meLinks.length > 0 ? meLinks.length : ""}
+
{LinkTypeFilter.team}{" "}
- {/* {teamRooms.length} */}
+ {teamLinks.length}
{LinkTypeFilter.favorites}{" "}
{/*
- {liveRooms.length > 0 ? liveRooms.length : ""}
- */}
+ {liveRooms.length > 0 ? fa.length : ""}
+ */}
{LinkTypeFilter.archived}{" "}
- {/*
- {archivedRooms.length > 0 ? archivedRooms.length : ""}
- */}
+
+ {archivedLinks.length > 0 ? archivedLinks.length : ""}
+
diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx
index 14b06ed..0a366bf 100644
--- a/components/LinkCard.tsx
+++ b/components/LinkCard.tsx
@@ -5,7 +5,7 @@ import {
FaFilePdf,
FaTrash,
} from "react-icons/fa";
-import Link, { LinkType } from "../models/link";
+import Link, { LinkState, LinkType } from "../models/link";
import Image from "next/image";
import { BsThreeDots } from "react-icons/bs";
import LinkIcon from "./LinkIcon";
@@ -16,11 +16,14 @@ import { Avatar, Dropdown, Menu, Tooltip } from "antd";
import { useState } from "react";
import SkeletonLoader from "./Loading/skeletonLoader";
import moment from "moment";
+import { LinkService } from "../services/linkService";
interface ILinkCardProps {
link: Link;
}
+const linkService = new LinkService();
+
export default function LinkCard(props: ILinkCardProps) {
const { currUser } = useAuth();
const { teamUsersMap, user } = useTeamDashboardContext();
@@ -46,28 +49,38 @@ export default function LinkCard(props: ILinkCardProps) {
return results;
}, [] as User[]);
- function handleDeleteLink() {
+ async function handleDeleteLink() {
+ setLoading(true);
if (
confirm(
"Are you sure you want to delete link? It will disappear for all recipients."
)
) {
console.log("deleting link");
+
+ await linkService.updateLinkState(props.link.id, LinkState.deleted);
+
try {
} catch (error) {}
}
+
+ setLoading(false);
}
- function handleArchivingLink() {
+ async function handleArchivingLink() {
+ setLoading(true);
+
if (
confirm(
"Are you sure you want to archive link? It will be in the archive tab."
)
) {
- console.log("archiving link");
+ await linkService.updateLinkState(props.link.id, LinkState.archived);
try {
} catch (error) {}
}
+
+ setLoading(false);
}
if (loading) {
@@ -76,11 +89,16 @@ export default function LinkCard(props: ILinkCardProps) {
const LinkOptionsMenu = (