Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Dashboard tweaks

Richie McIlroyf215ef1c9135
diff --git a/apps/web/app/dashboard/_components/DashboardInner.tsx b/apps/web/app/dashboard/_components/DashboardInner.tsx
index 3bd22c3e5..286953099 100644
--- a/apps/web/app/dashboard/_components/DashboardInner.tsx
+++ b/apps/web/app/dashboard/_components/DashboardInner.tsx
@@ -8,7 +8,13 @@ import {
PopoverContent,
PopoverTrigger,
} from "@cap/ui";
-import { LogOut, MessageSquare, MoreVertical, Settings } from "lucide-react";
+import {
+ Home,
+ LogOut,
+ MessageSquare,
+ MoreVertical,
+ Settings,
+} from "lucide-react";
import { useState } from "react";
import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";
@@ -78,6 +84,19 @@ const User = () => {
<PopoverContent className="p-1 w-48 bg-gray-50">
<Command>
<CommandGroup>
+ <Link href="/home">
+ <CommandItem
+ className="px-2 py-2 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-100 group"
+ onSelect={() => {
+ setMenuOpen(false);
+ }}
+ >
+ <Home className="mr-2 w-4 h-4 text-gray-400 group-hover:text-gray-500" />
+ <span className="text-sm text-gray-400 group-hover:text-gray-500">
+ Homepage
+ </span>
+ </CommandItem>
+ </Link>
<Link href="/dashboard/settings">
<CommandItem
className="px-2 py-2 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-100 group"
diff --git a/apps/web/app/dashboard/caps/components/CapCard.tsx b/apps/web/app/dashboard/caps/components/CapCard.tsx
index ee7cb046d..6edda0065 100644
--- a/apps/web/app/dashboard/caps/components/CapCard.tsx
+++ b/apps/web/app/dashboard/caps/components/CapCard.tsx
@@ -8,8 +8,14 @@ import { VideoThumbnail } from "@/components/VideoThumbnail";
import { VideoMetadata } from "@cap/database/types";
import { clientEnv, NODE_ENV } from "@cap/env";
import { Button } from "@cap/ui";
-import { faLink, faTrash, faUserPlus } from "@fortawesome/free-solid-svg-icons";
+import {
+ faLink,
+ faTrash,
+ faUserPlus,
+ faChevronDown,
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { ChevronDown } from "lucide-react";
import moment from "moment";
import Link from "next/link";
import { useRouter } from "next/navigation";
@@ -91,6 +97,38 @@ export const CapCard: React.FC<CapCardProps> = ({
router.refresh(); // Add this line to refresh the page
};
+ const isOwner = userId === cap.ownerId;
+
+ const renderSharedStatus = () => {
+ const baseClassName =
+ "text-sm text-gray-400 hover:text-gray-500 cursor-pointer flex items-center mb-1";
+ if (isOwner) {
+ if (cap.sharedSpaces.length === 0) {
+ return (
+ <span
+ className={`${baseClassName}`}
+ onClick={() => setIsSharingDialogOpen(true)}
+ >
+ <span>Not shared</span>{" "}
+ <FontAwesomeIcon className="size-3 ml-1" icon={faChevronDown} />
+ </span>
+ );
+ } else {
+ return (
+ <span
+ className={`${baseClassName}`}
+ onClick={() => setIsSharingDialogOpen(true)}
+ >
+ <span>Shared</span>{" "}
+ <FontAwesomeIcon className="size-3 ml-1" icon={faChevronDown} />
+ </span>
+ );
+ }
+ } else {
+ return <span className={`${baseClassName} `}>Shared with you</span>;
+ }
+ };
+
const handleDateClick = () => {
if (userId === cap.ownerId) {
if (!isDateEditing) {
@@ -286,6 +324,7 @@ export const CapCard: React.FC<CapCardProps> = ({
{title}
</p>
)}
+ {renderSharedStatus()}
<p className="mb-1">
{isDateEditing ? (
<div className="flex items-center">
diff --git a/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx b/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx
index 53e0fbb7c..08ff8e056 100644
--- a/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx
+++ b/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx
@@ -16,21 +16,21 @@ export const CapCardAnalytics: React.FC<CapCardAnalyticsProps> = ({
totalReactions,
}) => {
return (
- <div className="flex flex-wrap gap-5 items-center text-sm text-gray-60">
+ <div className="flex flex-wrap gap-3 items-center text-sm text-gray-60">
<Tooltip content={`${displayCount} unique views`}>
- <div className="flex flex-col gap-1 items-center">
+ <div className="flex gap-1 items-center">
<FontAwesomeIcon className="text-gray-400 size-4" icon={faEye} />
<span className="text-sm text-gray-500">{displayCount ?? "-"}</span>
</div>
</Tooltip>
<Tooltip content={`${totalComments} comments`}>
- <div className="flex flex-col gap-1 items-center">
+ <div className="flex gap-1 items-center">
<FontAwesomeIcon className="text-gray-400 size-4" icon={faComment} />
<span className="text-sm text-gray-500">{totalComments}</span>
</div>
</Tooltip>
<Tooltip content={`${totalReactions} reactions`}>
- <div className="flex flex-col gap-1 items-center">
+ <div className="flex gap-1 items-center">
<FontAwesomeIcon className="text-gray-400 size-4" icon={faSmile} />
<span className="text-sm text-gray-500">{totalReactions}</span>
</div>
diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsx
index 8e758de9d..c217366b2 100644
--- a/apps/web/app/page.tsx
+++ b/apps/web/app/page.tsx
@@ -1,12 +1,12 @@
import { HomePage } from "@/components/pages/HomePage";
-import { authOptions } from "@cap/database/auth/auth-options";
-import { getServerSession } from "next-auth/next";
+import { cookies } from "next/headers";
import { redirect } from "next/navigation";
export default async function Home() {
- const session = await getServerSession(authOptions);
+ const cookieStore = cookies();
+ const sessionCookie = cookieStore.get("next-auth.session-token");
- if (session?.user) {
+ if (sessionCookie) {
redirect("/dashboard/caps");
}