Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat:updates for year in review
Iuliia Shnaiaecd0728e93f
diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsxindex eb83286f..737d5d36 100644--- a/components/sidebar/app-sidebar.tsx+++ b/components/sidebar/app-sidebar.tsx@@ -18,6 +18,7 @@ import {Loader,ServerIcon,WorkflowIcon,+ Sparkles as SparklesIcon,} from "lucide-react";import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";@@ -213,6 +214,12 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {},],},+ {+ title: "2025 Recap",+ url: "/dashboard?openRecap=true",+ icon: SparklesIcon,+ current: false,+ },],};diff --git a/components/sidebar/nav-main.tsx b/components/sidebar/nav-main.tsxindex 33d96de4..e78c565e 100644--- a/components/sidebar/nav-main.tsx+++ b/components/sidebar/nav-main.tsx@@ -60,6 +60,7 @@ export function NavMain({ items }: { items: NavItem[] }) {item.current &&!item.items?.length &&"rounded-md bg-gray-200 font-semibold dark:bg-secondary",+ item.title === "2025 Recap" && "text-orange-500 dark:text-orange-400 hover:text-orange-700 dark:hover:text-orange-300",)}>{item.disabled ? (diff --git a/components/yearly-recap/globe.tsx b/components/yearly-recap/globe.tsxnew file mode 100644index 00000000..6e62c558--- /dev/null+++ b/components/yearly-recap/globe.tsx@@ -0,0 +1,145 @@+"use client";++import { useEffect, useRef } from "react";++interface GlobePoint {+ x: number;+ y: number;+ z: number;+ color: string;+}++export function Globe() {+ const canvasRef = useRef<HTMLCanvasElement>(null);+ const pointsRef = useRef<GlobePoint[]>([]);+ const rotationRef = useRef({ x: 0, y: 0 });++ useEffect(() => {+ const canvas = canvasRef.current;+ if (!canvas) return;++ const ctx = canvas.getContext("2d");+ if (!ctx) return;++ // Set canvas size+ const width = canvas.clientWidth;+ const height = canvas.clientHeight;+ canvas.width = width;+ canvas.height = height;++ // Create globe points - land and ocean colors+ const generateGlobePoints = () => {+ const points: GlobePoint[] = [];+ const radius = 100;+ const density = 2500; // number of points++ // Land colors (greens, browns)+ const landColors = [+ "#2d5016", // dark green+ "#3d7020", // forest green+ "#5a8c2d", // medium green+ "#8b7355", // brown+ "#a69968", // tan+ "#6b8e23", // olive+ ];++ // Ocean colors (blues)+ const oceanColors = [+ "#1e3a8a", // dark blue+ "#2563eb", // medium blue+ "#0369a1", // cyan-blue+ "#3b82f6", // sky blue+ ];++ for (let i = 0; i < density; i++) {+ // Random spherical coordinates+ const theta = Math.random() * Math.PI * 2;+ const phi = Math.acos(Math.random() * 2 - 1);++ const x = radius * Math.sin(phi) * Math.cos(theta);+ const y = radius * Math.sin(phi) * Math.sin(theta);+ const z = radius * Math.cos(phi);++ // Determine if this point is "land" based on noise-like pattern+ const landChance = Math.sin(theta * 3) * Math.sin(phi * 2) * 0.5 + 0.5;+ const isLand = landChance > 0.45;++ const colorArray = isLand ? landColors : oceanColors;+ const color = colorArray[Math.floor(Math.random() * colorArray.length)];++ points.push({ x, y, z, color });+ }++ return points;+ };++ pointsRef.current = generateGlobePoints();++ let animationId: number;++ const animate = () => {+ // Clear canvas with transparent background+ ctx.clearRect(0, 0, width, height);++ // Rotation - only around Y axis for smooth round rotation+ rotationRef.current.y += 0.003;++ const cosY = Math.cos(rotationRef.current.y);+ const sinY = Math.sin(rotationRef.current.y);+ // Fixed tilt for a nice viewing angle+ const tiltAngle = 0.3;+ const cosX = Math.cos(tiltAngle);+ const sinX = Math.sin(tiltAngle);++ // Project and sort points+ const projectedPoints = pointsRef.current+ .map((point) => {+ // Rotation around X axis+ const y = point.y * cosX - point.z * sinX;+ let z = point.y * sinX + point.z * cosX;++ // Rotation around Y axis+ const x = point.x * cosY + z * sinY;+ z = -point.x * sinY + z * cosY;++ // Perspective projection+ const scale = 300 / (z + 150);+ const x2d = x * scale + width / 2;+ const y2d = y * scale + height / 2;++ return { x: x2d, y: y2d, z, color: point.color };+ })+ .sort((a, b) => a.z - b.z); // Sort by depth++ // Draw points+ projectedPoints.forEach((point) => {+ const depth = (point.z + 150) / 300;+ const size = Math.max(0.5, depth * 1.5);++ ctx.fillStyle = point.color;+ ctx.globalAlpha = Math.max(0.3, depth);+ ctx.beginPath();+ ctx.arc(point.x, point.y, size, 0, Math.PI * 2);+ ctx.fill();+ });++ ctx.globalAlpha = 1;+ animationId = requestAnimationFrame(animate);+ };++ animate();++ return () => {+ cancelAnimationFrame(animationId);+ };+ }, []);++ return (+ <canvas+ ref={canvasRef}+ className="w-full h-full"+ style={{ background: "transparent" }}+ />+ );+}+diff --git a/components/yearly-recap/index.ts b/components/yearly-recap/index.tsnew file mode 100644index 00000000..a5d9f3fe--- /dev/null+++ b/components/yearly-recap/index.ts@@ -0,0 +1,3 @@+export { YearlyRecapBanner } from "./yearly-recap-banner";+export { YearlyRecapModal } from "./yearly-recap-modal";+diff --git a/components/yearly-recap/yearly-recap-banner.tsx b/components/yearly-recap/yearly-recap-banner.tsxnew file mode 100644index 00000000..0351c846--- /dev/null+++ b/components/yearly-recap/yearly-recap-banner.tsx@@ -0,0 +1,135 @@+"use client";++import { useState, useEffect } from "react";+import { useRouter } from "next/router";++import { useTeam } from "@/context/team-context";+import { Sparkles, ArrowRight } from "lucide-react";+import useSWR from "swr";++import { fetcher } from "@/lib/utils";++import { Button } from "@/components/ui/button";+import { YearlyRecapModal } from "./yearly-recap-modal";++// Decorative SVG Components+const DocumentStackSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 100 120" fill="none" xmlns="http://www.w3.org/2000/svg">+ <rect x="10" y="10" width="60" height="80" rx="2" fill="#FA7A02" opacity="0.4" />+ <rect x="15" y="20" width="60" height="80" rx="2" fill="#FA7A02" opacity="0.5" />+ <rect x="20" y="30" width="60" height="80" rx="2" fill="#FA7A02" opacity="0.6" />+ </svg>+);++const PeachPaperSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">+ <path d="M10 15 Q15 10, 20 15 L45 40 Q50 45, 45 50 L20 50 Q15 50, 10 45 Z" fill="#FFD4B3" opacity="0.6" />+ <path d="M10 15 Q12 12, 15 15 L40 40 Q42 42, 40 45 L15 45 Q12 45, 10 42 Z" fill="#FFD4B3" opacity="0.4" />+ </svg>+);++const ScatterDotsSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">+ <circle cx="25" cy="30" r="2" fill="#D3D3D3" opacity="0.5" />+ <circle cx="45" cy="25" r="1.5" fill="#D3D3D3" opacity="0.5" />+ <circle cx="65" cy="35" r="2" fill="#D3D3D3" opacity="0.5" />+ <circle cx="30" cy="55" r="1.5" fill="#D3D3D3" opacity="0.5" />+ <circle cx="55" cy="60" r="2" fill="#D3D3D3" opacity="0.5" />+ <circle cx="70" cy="70" r="1.5" fill="#D3D3D3" opacity="0.5" />+ </svg>+);++interface YearlyRecapStats {+ year: number;+ totalViews: number;+ totalDocuments: number;+ totalDatarooms: number;+}++export function YearlyRecapBanner() {+ const teamInfo = useTeam();+ const router = useRouter();+ const currentYear = new Date().getFullYear();+ const [showModal, setShowModal] = useState(false);++ const { data: stats } = useSWR<YearlyRecapStats>(+ teamInfo?.currentTeam?.id+ ? `/api/teams/${teamInfo.currentTeam.id}/yearly-recap`+ : null,+ fetcher,+ {+ revalidateOnFocus: false,+ },+ );++ // Check if URL has openRecap parameter - open modal regardless of stats+ useEffect(() => {+ if (router.isReady && router.query.openRecap === "true" && teamInfo?.currentTeam?.id) {+ setShowModal(true);+ // Remove the query parameter+ const { openRecap, ...rest } = router.query;+ router.replace({ pathname: router.pathname, query: rest }, undefined, {+ shallow: true,+ });+ }+ }, [router.isReady, router.query.openRecap, teamInfo?.currentTeam?.id, router]);++ const handleOpenModal = () => {+ setShowModal(true);+ };++ // Don't render anything if no team+ if (!teamInfo?.currentTeam?.id) {+ return null;+ }++ return (+ <>+ {/* Modal - always available */}+ <YearlyRecapModal+ isOpen={showModal}+ onClose={() => setShowModal(false)}+ teamId={teamInfo.currentTeam.id}+ />++ {/* Banner - always shown */}+ <div className="mx-2 my-2 mb-2">+ <div className="relative overflow-hidden rounded-xl bg-[#EEEFEB] p-6">+ {/* Decorative elements */}+ <DocumentStackSVG className="absolute -top-2 -right-2 w-24 h-28" />+ {/* <PeachPaperSVG className="absolute bottom-2 left-2 w-16 h-16" /> */}+ <ScatterDotsSVG className="absolute top-2 left-1/4 w-20 h-20" />++ <div className="relative z-10 flex items-center justify-between gap-4">+ <div className="flex items-center gap-4">+ <div className="relative w-12 h-12 shrink-0">+ {/* <PeachPaperSVG className="absolute inset-0 w-full h-full opacity-60" /> */}+ <div className="absolute inset-0 w-12 h-12 rounded-full bg-orange-500/20 flex items-center justify-center">+ <Sparkles className="h-6 w-6 text-orange-500" />+ </div>+ </div>+ <div>+ <h3 className="font-semibold text-gray-900 text-xl">Papermark Wrapped {currentYear}</h3>+ <p className="text-gray-600 text-sm">+ {stats ? (+ <>See your highlights: {stats.totalViews.toLocaleString()} views, {stats.totalDocuments} documents, {stats.totalDatarooms} datarooms</>+ ) : (+ "Your year in document sharing"+ )}+ </p>+ </div>+ </div>+ <Button+ onClick={handleOpenModal}+ className="bg-gray-900 hover:bg-gray-800 text-white gap-2 shrink-0"+ >+ See your Wrapped+ <ArrowRight className="h-4 w-4" />+ </Button>+ </div>+ </div>+ </div>+ </>+ );+}+diff --git a/components/yearly-recap/yearly-recap-modal.tsx b/components/yearly-recap/yearly-recap-modal.tsxnew file mode 100644index 00000000..efc72a9b--- /dev/null+++ b/components/yearly-recap/yearly-recap-modal.tsx@@ -0,0 +1,687 @@+"use client";++import { useState, useRef, useCallback } from "react";++import {+ Dialog,+ DialogContent,+} from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import {+ X,+ ChevronLeft,+ ChevronRight,+ Share2,+ Eye,+ Clock,+ FileText,+ Calendar,+ Users,+ Database,+ ArrowRight,+ MapPin,+ Building2,+ Copy,+ Download,+ Linkedin,+ Twitter,+ Globe2,+ Files,+ Folder,+ Paperclip,+ StickyNote,+ Grid3x3,+ Circle+} from "lucide-react";+import { toast } from "sonner";+import useSWR from "swr";++import { fetcher, cn } from "@/lib/utils";++interface YearlyRecapStats {+ year: number;+ totalViews: number;+ totalDocuments: number;+ totalLinks: number;+ totalDatarooms: number;+ mostViewedDocument: {+ documentId: string;+ documentName: string;+ viewCount: number;+ } | null;+ mostActiveMonth: {+ month: string;+ viewCount: number;+ } | null;+ mostActiveViewer: {+ email: string;+ name: string | null;+ viewCount: number;+ } | null;+ totalDuration: number;+ uniqueCountries: string[];+ uniqueCities?: string[];+}++interface YearlyRecapModalProps {+ isOpen: boolean;+ onClose: () => void;+ teamId: string;+}++// Decorative SVG Components+const DocumentStackSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 100 120" fill="none" xmlns="http://www.w3.org/2000/svg">+ <rect x="10" y="10" width="60" height="80" rx="2" fill="#F5F5F5" stroke="currentColor" strokeWidth="1.5" />+ <rect x="15" y="20" width="60" height="80" rx="2" fill="#F5F5F5" stroke="currentColor" strokeWidth="1.5" />+ <rect x="20" y="30" width="60" height="80" rx="2" fill="#F5F5F5" stroke="currentColor" strokeWidth="1.5" />+ </svg>+);++const FolderTabSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 100 80" fill="none" xmlns="http://www.w3.org/2000/svg">+ <path d="M10 20 L10 70 L70 70 L70 30 L45 30 L35 20 Z" fill="#FFB84D" opacity="0.4" stroke="#FFB84D" strokeWidth="1.5" />+ <path d="M10 20 L35 20 L45 30 L10 30 Z" fill="#FFB84D" opacity="0.6" />+ </svg>+);++const StickyNoteSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">+ <rect x="10" y="10" width="60" height="60" rx="2" fill="#90EE90" opacity="0.4" stroke="#90EE90" strokeWidth="1.5" />+ <path d="M10 10 L70 10 L60 20 L10 20 Z" fill="#90EE90" opacity="0.6" />+ </svg>+);++const ScatterDotsSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">+ <circle cx="25" cy="30" r="2" fill="#000000" opacity="0.5" />+ <circle cx="45" cy="25" r="1.5" fill="#000000" opacity="0.5" />+ <circle cx="65" cy="35" r="2" fill="#000000" opacity="0.5" />+ <circle cx="30" cy="55" r="1.5" fill="#000000" opacity="0.5" />+ <circle cx="55" cy="60" r="2" fill="#000000" opacity="0.5" />+ <circle cx="70" cy="70" r="1.5" fill="#000000" opacity="0.5" />+ </svg>+);++const CurvedLineSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 200 50" fill="none" xmlns="http://www.w3.org/2000/svg">+ <path d="M0 25 Q50 10, 100 25 T200 25" stroke="#D3D3D3" strokeWidth="2" fill="none" opacity="0.5" />+ </svg>+);++const RECAP_GRADIENT = "bg-[#EEEFEB]";++const slides = [+ { id: "intro", gradient: RECAP_GRADIENT },+ { id: "globalFootprint", gradient: RECAP_GRADIENT },+ { id: "minutes", gradient: RECAP_GRADIENT },+ { id: "viewsStats", gradient: RECAP_GRADIENT },+ { id: "mostActive", gradient: RECAP_GRADIENT },+ { id: "summary", gradient: RECAP_GRADIENT },+ { id: "shareOffer", gradient: RECAP_GRADIENT },+];++export function YearlyRecapModal({+ isOpen,+ onClose,+ teamId,+}: YearlyRecapModalProps) {+ const [currentSlide, setCurrentSlide] = useState(0);+ const [showShareView, setShowShareView] = useState(false);+ const [isCapturing, setIsCapturing] = useState(false);+ const shareCardRef = useRef<HTMLDivElement>(null);++ const { data: stats, isLoading } = useSWR<YearlyRecapStats>(+ teamId ? `/api/teams/${teamId}/yearly-recap` : null,+ fetcher,+ {+ revalidateOnFocus: false,+ },+ );++ const nextSlide = () => {+ if (currentSlide < slides.length - 1) {+ setCurrentSlide(currentSlide + 1);+ }+ };++ const prevSlide = () => {+ if (currentSlide > 0) {+ setCurrentSlide(currentSlide - 1);+ }+ };++ const handleShare = () => {+ setShowShareView(true);+ };++ const handleClose = () => {+ setCurrentSlide(0);+ setShowShareView(false);+ onClose();+ };++ const captureImage = useCallback(async (): Promise<Blob | null> => {+ if (!shareCardRef.current) return null;++ try {+ const html2canvas = (await import("html2canvas")).default;+ const canvas = await html2canvas(shareCardRef.current, {+ scale: 2,+ backgroundColor: null,+ useCORS: true,+ });++ return new Promise((resolve) => {+ canvas.toBlob((blob) => {+ resolve(blob);+ }, "image/png");+ });+ } catch (error) {+ console.error("Error capturing image:", error);+ toast.error("Failed to capture image");+ return null;+ }+ }, []);++ const handleCopyLink = async () => {+ try {+ await navigator.clipboard.writeText("https://www.papermark.com/");+ toast.success("Link copied to clipboard!");+ } catch (error) {+ toast.error("Failed to copy link");+ }+ };++ const handleDownload = async () => {+ setIsCapturing(true);+ try {+ const blob = await captureImage();+ if (blob) {+ const url = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = url;+ a.download = `papermark-wrapped-${stats?.year || 2025}.png`;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(url);+ toast.success("Image downloaded!");+ }+ } catch (error) {+ toast.error("Failed to download image");+ } finally {+ setIsCapturing(false);+ }+ };++ const getShareText = () => {+ const totalMinutes = Math.floor((stats?.totalDuration || 0) / 60);+ const countriesCount = stats?.uniqueCountries?.length || 0;+ const distanceTraveled = Math.round(countriesCount * 2500);++ return `· ${totalMinutes.toLocaleString()} min my docs were viewed+· ${distanceTraveled.toLocaleString()} km travelled my documents+· ${stats?.totalDocuments} documents+· ${stats?.totalViews?.toLocaleString()} views+· ${countriesCount} countries++My Papermark Wrapped ${stats?.year}!++#PapermarkWrapped https://www.papermark.com/`;+ };++ const handleShareLinkedIn = async () => {+ const text = getShareText();+ window.open(+ `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent("https://www.papermark.com/")}&summary=${encodeURIComponent(text)}`,+ "_blank"+ );+ };++ const handleShareTwitter = async () => {+ const text = getShareText();+ window.open(+ `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}`,+ "_blank"+ );+ };++ if (isLoading || !stats) {+ return (+ <Dialog open={isOpen} onOpenChange={handleClose}>+ <DialogContent className="max-w-4xl bg-[#EEEFEB]">+ <div className="flex items-center justify-center p-8">+ <div className="text-center text-balance">Loading your recap...</div>+ </div>+ </DialogContent>+ </Dialog>+ );+ }++ // Share View+ if (showShareView) {+ return (+ <Dialog open={isOpen} onOpenChange={handleClose}>+ <DialogContent className="max-w-[700px] p-0 overflow-hidden border-0 bg-[#EEEFEB]">+ {/* Close button */}+ <button+ onClick={() => setShowShareView(false)}+ className="absolute top-4 right-4 z-50 text-foreground/60 hover:text-foreground transition-colors"+ >+ <X className="h-5 w-5" />+ </button>++ {/* Shareable Card */}+ <div className="p-6">+ {(() => {+ const totalMinutes = Math.floor(stats.totalDuration / 60);+ const countriesCount = stats.uniqueCountries?.length || 0;+ const distanceTraveled = Math.round(countriesCount * 2500);++ return (+ <div+ ref={shareCardRef}+ className="rounded-2xl overflow-hidden bg-[#EEEFEB] p-8 w-full max-w-[500px]"+ >+ {/* Stats Grid */}+ <div className="bg-white rounded-xl p-6 shadow-sm mb-6">+ <div className="grid grid-cols-2 gap-4">+ <div className="text-center">+ <div className="text-4xl font-bold text-black mb-1">{totalMinutes.toLocaleString()}</div>+ <p className="text-xs text-gray-600">minutes viewed</p>+ </div>+ <div className="text-center">+ <div className="text-4xl font-bold text-black mb-1">{distanceTraveled.toLocaleString()}</div>+ <p className="text-xs text-gray-600">km travelled</p>+ </div>+ <div className="text-center">+ <div className="text-4xl font-bold text-black mb-1">{stats.totalDocuments}</div>+ <p className="text-xs text-gray-600">documents</p>+ </div>+ <div className="text-center">+ <div className="text-4xl font-bold text-black mb-1">{stats.totalViews.toLocaleString()}</div>+ <p className="text-xs text-gray-600">views</p>+ </div>+ </div>+ {/* <div className="text-center mt-4 pt-4 border-t border-gray-200">+ <div className="text-4xl font-bold text-orange-500 mb-1">{countriesCount}</div>+ <p className="text-xs text-gray-600">countries reached</p>+ </div> */}+ </div>++ {/* Branding */}+ <div className="text-center mt-6">+ <div className="inline-flex items-center gap-2">+ <span className="text-lg font-bold text-gray-900">Papermark</span>+ <span className="text-lg font-black text-gray-900">WRAPPED</span>+ </div>+ <p className="text-xs text-gray-500 mt-1">papermark.com</p>+ </div>+ </div>+ );+ })()}+ </div>++ {/* $50 grant text */}+ <p className="px-6 text-sm text-muted-foreground text-center mb-4">+ Share your stats and receive <span className="font-semibold text-orange-600">$50</span> in credits on your papermark account, please send confirmation to <span className="font-medium">[email protected]</span> and include screenshot or link to your post.++ </p>++ {/* Share buttons */}+ <div className="px-6 pb-6 flex items-center justify-between">+ <div className="flex items-center gap-2">+ <Button+ onClick={handleCopyLink}+ variant="secondary"+ className="gap-2 rounded-full"+ >+ <Copy className="h-4 w-4" />+ Copy link+ </Button>+ <Button+ onClick={handleShareLinkedIn}+ variant="secondary"+ size="icon"+ className="rounded-full"+ >+ <Linkedin className="h-4 w-4" />+ </Button>+ <Button+ onClick={handleShareTwitter}+ variant="secondary"+ size="icon"+ className="rounded-full"+ >+ <Twitter className="h-4 w-4" />+ </Button>+ <Button+ onClick={handleDownload}+ disabled={isCapturing}+ variant="secondary"+ size="icon"+ className="rounded-full"+ >+ <Download className="h-4 w-4" />+ </Button>+ </div>++ <Button+ onClick={() => setShowShareView(false)}+ className="bg-gradient-to-r from-orange-500 to-orange-500 hover:from-orange-600 hover:to-orange-600 text-white gap-2 rounded-full"+ >+ Back to Wrapped+ <ArrowRight className="h-4 w-4" />+ </Button>+ </div>+ </DialogContent>+ </Dialog>+ );+ }++ return (+ <Dialog open={isOpen} onOpenChange={handleClose}>+ <DialogContent className="max-w-[1100px] min-w-[700px] p-0 overflow-hidden border-0 bg-[#EEEFEB] [&>button]:hidden">+ <div+ className={cn("relative min-h-[700px] rounded-3xl shadow-2xl overflow-hidden", slides[currentSlide].gradient)}+ >+ {/* Decorative background elements - same as banner */}+ {/* <DocumentStackSVG className="absolute top-16 -right-2 w-24 h-28 text-foreground opacity-50" /> */}+ {/* <ScatterDotsSVG className="absolute top-1/4 left-1/4 w-20 h-20" /> */}+ {/* <Paperclip className="absolute bottom-16 left-8 w-16 h-16 text-foreground/30" strokeWidth="1" /> */}++ {/* Progress bar */}+ <div className="relative z-10 flex gap-2 p-8">+ {slides.map((_, index) => (+ <div+ key={index}+ className={cn(+ "h-1.5 flex-1 rounded-full transition-all duration-300",+ index <= currentSlide ? "bg-foreground/40" : "bg-foreground/10"+ )}+ />+ ))}+ </div>++ {/* Close button */}+ <button+ onClick={handleClose}+ className="absolute top-8 right-8 z-50 text-foreground/60 hover:text-foreground transition-colors"+ >+ <X className="h-6 w-6" />+ </button>++ {/* Slide content */}+ <div className="relative z-10 px-16 pb-16 pt-4">+ {currentSlide === 0 && <IntroSlide stats={stats} onNext={nextSlide} />}+ {currentSlide === 1 && <GlobalFootprintSlide stats={stats} />}+ {currentSlide === 2 && <MinutesSlide stats={stats} />}+ {currentSlide === 3 && <ViewsStatsSlide stats={stats} />}+ {currentSlide === 4 && <MostActiveSlide stats={stats} />}+ {currentSlide === 5 && <SummarySlide stats={stats} />}+ {currentSlide === 6 && <ShareOfferSlide stats={stats} />}+ </div>++ {/* Navigation - hidden on first slide */}+ {currentSlide > 0 && (+ <div className="absolute bottom-8 left-0 right-0 z-10 flex items-center justify-center gap-3">+ <Button+ variant="ghost"+ size="icon"+ onClick={prevSlide}+ disabled={currentSlide === 0}+ className="h-10 w-10 rounded-full bg-foreground/10 hover:bg-foreground/20 disabled:opacity-30"+ >+ <ChevronLeft className="h-5 w-5" />+ </Button>+ <Button+ onClick={handleShare}+ className="bg-foreground hover:bg-foreground/90 text-gray-100 gap-2 rounded-full px-6"+ >+ <Share2 className="h-4 w-4" />+ Share+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={nextSlide}+ disabled={currentSlide === slides.length - 1}+ className="h-10 w-10 rounded-full bg-foreground/10 hover:bg-foreground/20 disabled:opacity-30"+ >+ <ChevronRight className="h-5 w-5" />+ </Button>+ </div>+ )}+ </div>+ </DialogContent>+ </Dialog>+ );+}++function IntroSlide({ stats, onNext }: { stats: YearlyRecapStats; onNext: () => void }) {+ return (+ <div className="flex flex-col items-center justify-center min-h-[520px] text-center relative">+ <h1 className="text-6xl font-semibold text-foreground mb-4 relative z-10 text-balance">+ Your {stats.year} with <span className="text-orange-500">Papermark</span>+ </h1>+ <p className="max-w-xl text-sm text-gray-500 mb-14 relative z-10">+ This review is personalised to your platform usage and contains your stats.++ </p>++ {/* Let's go button - only appears from bottom */}+ <Button+ onClick={onNext}+ size="lg"+ className="bg-black hover:from-orange-600 hover:to-orange-600 text-white text-lg px-10 py-3 h-auto rounded-full shadow-xl animate-in slide-in-from-bottom-12 duration-700 relative z-10"+ >+ Let's go+ <ArrowRight className="ml-2 h-5 w-5" />+ </Button>+ </div>+ );+}++function GlobalFootprintSlide({ stats }: { stats: YearlyRecapStats }) {+ const countriesCount = stats.uniqueCountries.length;+ const citiesCount = stats.uniqueCities?.length || Math.round(countriesCount * 1.5);+ const distanceTraveled = Math.round(countriesCount * 2500);++ return (+ <div className="min-h-[520px] flex flex-col items-center justify-center text-center">+ {/* Title section - appears from top */}+ <div className="animate-in slide-in-from-top-8 duration-700">+ {/* Big number */}+ <h2 className="text-9xl font-bold text-foreground mb-4 text-balance">+ {distanceTraveled.toLocaleString()}+ <span className="text-2xl font-normal text-foreground">km</span>+ </h2>++ <p className="text-2xl font-normal text-foreground mb-8 text-balance">+ your documents travelled this year+ </p>+ </div>++ {/* Two boxes side by side - appears from bottom */}+ <div className="flex gap-6 animate-in slide-in-from-bottom-8 duration-700">+ {/* Countries box */}+ <div className="bg-card rounded-2xl p-8 shadow-lg w-56">+ <MapPin className="h-8 w-8 text-orange-600 mx-auto mb-4" />+ <div className="text-5xl font-bold text-foreground">{countriesCount}</div>+ <p className="text-sm text-muted-foreground mt-2 text-balance">Countries</p>+ </div>++ {/* Cities box */}+ <div className="bg-card rounded-2xl p-8 shadow-lg w-56">+ <Building2 className="h-8 w-8 text-orange-600 mx-auto mb-4" />+ <div className="text-5xl font-bold text-foreground">{citiesCount}</div>+ <p className="text-sm text-muted-foreground mt-2 text-balance">Cities</p>+ </div>+ </div>+ </div>+ );+}++function MinutesSlide({ stats }: { stats: YearlyRecapStats }) {+ const totalMinutes = Math.floor(stats.totalDuration / 60);++ return (+ <div className="min-h-[520px] flex flex-col items-center justify-center text-center">+ {/* Header from top */}+ <div className="animate-in slide-in-from-top-8 duration-700">+ <p className="text-lg text-muted-foreground mb-2">Total time on your documents</p>+ <h2+ className="text-8xl font-bold text-orange-500 mb-2"+ style={{ WebkitTextStroke: '2px currentColor', WebkitTextFillColor: 'transparent' }}+ >+ {totalMinutes.toLocaleString()}+ </h2>+ <p className="text-2xl font-medium text-foreground">minutes</p>+ </div>++ {/* Document card from left */}+ {stats.mostViewedDocument && (+ <div className="bg-white/80 backdrop-blur rounded-xl p-5 shadow-sm animate-in slide-in-from-left-8 duration-700 mt-8 border border-foreground/5 max-w-xl w-full">+ <div className="flex items-center gap-4">+ <div className="w-12 h-12 rounded-lg bg-orange-500/10 flex items-center justify-center flex-shrink-0">+ <FileText className="h-6 w-6 text-orange-500" />+ </div>+ <div className="text-left">+ <span className="text-xs font-medium text-muted-foreground uppercase tracking-wide">Most Viewed</span>+ <h3 className="font-semibold text-foreground mt-1">{stats.mostViewedDocument.documentName}</h3>+ <p className="text-sm text-muted-foreground mt-1">+ <span className="font-semibold text-orange-500">{stats.mostViewedDocument.viewCount.toLocaleString()}</span> views+ </p>+ </div>+ </div>+ </div>+ )}+ </div>+ );+}++function ViewsStatsSlide({ stats }: { stats: YearlyRecapStats }) {+ return (+ <div className="min-h-[520px] flex flex-col items-center justify-center">+ {/* Header from left */}+ <h2 className="text-3xl font-bold text-foreground mb-8 animate-in slide-in-from-left-8 duration-700 text-center text-balance">+ Your {stats.year} activity on Papermark+ </h2>++ {/* Busiest month */}+ {stats.mostActiveMonth && (+ <div className="mb-8 bg-card rounded-2xl px-8 py-5 shadow-lg animate-in slide-in-from-top-4 duration-700">+ <div className="flex items-center gap-3 text-sm">+ <Calendar className="h-5 w-5 text-orange-600" />+ <span className="text-muted-foreground">Busiest month:</span>+ <span className="font-semibold text-foreground">{stats.mostActiveMonth.month}</span>+ </div>+ </div>+ )}++ {/* Cards from right */}+ <div className="grid grid-cols-3 gap-5 w-full max-w-5xl animate-in slide-in-from-right-8 duration-700">+ <div className="bg-card rounded-2xl p-10 text-center shadow-lg">+ <Eye className="h-6 w-6 text-orange-500 mx-auto mb-4" />+ <span className="text-5xl font-bold text-foreground block">{stats.totalViews.toLocaleString()}</span>+ <p className="text-sm text-muted-foreground mt-3 font-medium text-balance">Views</p>+ </div>+ <div className="bg-card rounded-2xl p-10 text-center shadow-lg">+ <FileText className="h-6 w-6 text-orange-500 mx-auto mb-4" />+ <span className="text-5xl font-bold text-foreground block">{stats.totalDocuments.toLocaleString()}</span>+ <p className="text-sm text-muted-foreground mt-3 font-medium text-balance">Documents</p>+ </div>+ <div className="bg-card rounded-2xl p-10 text-center shadow-lg">+ <Database className="h-6 w-6 text-orange-600 mx-auto mb-4" />+ <span className="text-5xl font-bold text-foreground block">{stats.totalDatarooms.toLocaleString()}</span>+ <p className="text-sm text-muted-foreground mt-3 font-medium text-balance">Datarooms</p>+ </div>+ </div>+ </div>+ );+}++function MostActiveSlide({ stats }: { stats: YearlyRecapStats }) {+ return (+ <div className="min-h-[520px] flex flex-col items-center justify-center text-center">+ <h2 className="text-3xl font-bold text-foreground mb-2 text-balance">+ Your Most Active Viewer+ </h2>+ <p className="text-muted-foreground text-lg mb-10 text-balance">+ Someone really loves your documents!+ </p>++ {/* Card appears from bottom only */}+ {stats.mostActiveViewer ? (+ <div className="bg-card rounded-3xl p-12 shadow-lg animate-in slide-in-from-bottom-8 duration-700 max-w-xl w-full">+ <div className="w-24 h-24 rounded-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center mx-auto mb-6">+ <Users className="h-12 w-12 text-primary" />+ </div>+ <h3 className="text-2xl font-bold text-foreground text-balance">+ {stats.mostActiveViewer.name || stats.mostActiveViewer.email}+ </h3>+ <p className="text-muted-foreground mt-3 text-balance">+ Viewed your documents <span className="font-semibold text-primary">{stats.mostActiveViewer.viewCount.toLocaleString()} times</span>+ </p>+ </div>+ ) : (+ <div className="bg-card rounded-3xl p-12 shadow-lg">+ <p className="text-muted-foreground text-balance">No viewer data available</p>+ </div>+ )}+ </div>+ );+}++function SummarySlide({ stats }: { stats: YearlyRecapStats }) {+ return (+ <div className="min-h-[520px] flex flex-col items-center justify-center text-center">+ <h2 className="text-4xl font-bold text-foreground mb-4 text-balance">+ What a year! 🎉+ </h2>+ <p className="text-muted-foreground text-lg max-w-xl text-balance">+ You've made an impact with your documents. Here's to an even bigger {stats.year + 1}!+ </p>++ {/* Numbers only */}+ {/* <div className="flex items-center justify-center gap-8 mt-10">+ <span className="text-5xl font-bold text-foreground animate-in zoom-in-75 duration-700" style={{ animationDelay: "0ms" }}>+ {stats.totalViews.toLocaleString()}+ </span>+ <span className="text-5xl font-bold text-foreground animate-in zoom-in-75 duration-700" style={{ animationDelay: "150ms" }}>+ {stats.totalDocuments.toLocaleString()}+ </span>+ <span className="text-5xl font-bold text-foreground animate-in zoom-in-75 duration-700" style={{ animationDelay: "300ms" }}>+ {stats.totalDatarooms.toLocaleString()}+ </span>+ </div> */}+ </div>+ );+}++function ShareOfferSlide({ stats }: { stats: YearlyRecapStats }) {+ return (+ <div className="min-h-[520px] flex flex-col items-center justify-center text-center">+ <h2 className="text-3xl font-bold text-foreground mb-6 text-balance">+ Share your stats or experience with Papermark+ </h2>++ <div className="animate-in zoom-in-50 duration-1000">+ <span className="text-8xl font-bold text-orange-500 mb-2">++ <h2+ className="text-8xl font-semibold text-black mb-2"++ >+ $50+ </h2>+ </span>+ </div>++ <p className="text-sm text-muted-foreground mt-8 text-balance">+ You will receive $50 in credits on your papermark account, please send confirmation to <span className="font-medium">[email protected]</span> and include screenshot or link to your post.+ </p>+ </div>+ );+}diff --git a/lib/tinybird/endpoints/get_total_team_duration.pipe b/lib/tinybird/endpoints/get_total_team_duration.pipenew file mode 100644index 00000000..92adc4c0--- /dev/null+++ b/lib/tinybird/endpoints/get_total_team_duration.pipe@@ -0,0 +1,35 @@+VERSION 1++DESCRIPTION >+ Get total duration and unique countries for all documents in a team++NODE get_duration+SQL >+ %+ SELECT+ sum(duration) as total_duration+ FROM page_views+ WHERE documentId IN splitByString(',', {{String(documentIds, '')}})+ AND time >= {{Int64(since, 0)}}+ AND time < {{Int64(until, 9999999999999)}}++NODE get_countries+SQL >+ %+ SELECT+ groupArray(DISTINCT country) as unique_countries+ FROM pm_click_events+ WHERE document_id IN splitByString(',', {{String(documentIds, '')}})+ AND toUnixTimestamp64Milli(timestamp) >= {{Int64(since, 0)}}+ AND toUnixTimestamp64Milli(timestamp) < {{Int64(until, 9999999999999)}}+ AND country != 'Unknown'+ AND country != ''++NODE endpoint+SQL >+ %+ SELECT+ (SELECT total_duration FROM get_duration) as total_duration,+ (SELECT unique_countries FROM get_countries) as unique_countries++diff --git a/lib/tinybird/pipes.ts b/lib/tinybird/pipes.tsindex f1635e28..74677018 100644--- a/lib/tinybird/pipes.ts+++ b/lib/tinybird/pipes.ts@@ -198,3 +198,16 @@ export const getClickEventsByView = tb.buildPipe({href: z.string(),}),});++export const getTotalTeamDuration = tb.buildPipe({+ pipe: "get_total_team_duration__v1",+ parameters: z.object({+ documentIds: z.string().describe("Comma separated documentIds"),+ since: z.number(),+ until: z.number(),+ }),+ data: z.object({+ total_duration: z.number(),+ unique_countries: z.array(z.string()),+ }),+});diff --git a/lib/utils/geo.ts b/lib/utils/geo.tsindex 16eab05b..dff501a9 100644--- a/lib/utils/geo.ts+++ b/lib/utils/geo.ts@@ -23,12 +23,12 @@ export function getGeoData(headers: {}export const LOCALHOST_GEO_DATA = {- continent: "Europe",- city: "Munich",- region: "BY",- country: "DE",- latitude: "48.137154",- longitude: "11.576124",+ continent: "North America",+ city: "San Francisco",+ region: "CA",+ country: "US",+ latitude: "37.7749",+ longitude: "-122.4194",};export const LOCALHOST_IP = "127.0.0.1";diff --git a/lib/year-in-review/get-stats.ts b/lib/year-in-review/get-stats.tsindex 24da15c3..e7644ee5 100644--- a/lib/year-in-review/get-stats.ts+++ b/lib/year-in-review/get-stats.ts@@ -1,59 +1,69 @@-import { Tinybird } from "@chronark/zod-bird";import { Prisma } from "@prisma/client";-import { z } from "zod";import prisma from "@/lib/prisma";+import { getTotalTeamDuration } from "@/lib/tinybird/pipes";import { COUNTRIES } from "../constants";-export async function getYearInReviewStats(teamId: string) {+export async function getYearInReviewStats(teamId: string, year?: number) {+ const currentYear = year || new Date().getFullYear();+ const yearStart = new Date(`${currentYear}-01-01`);+ const yearEnd = new Date(`${currentYear + 1}-01-01`);+// Run all queries in parallel for a specific team- const [documents, teamCounts, mostViewedDoc, mostActiveMonth] =- await Promise.all([- prisma.document.findMany({- where: { teamId },- select: { id: true },- }),+ const [+ documents,+ teamCounts,+ mostViewedDoc,+ mostActiveMonth,+ dataroomCounts,+ mostActiveViewer,+ ] = await Promise.all([+ prisma.document.findMany({+ where: { teamId },+ select: { id: true },+ }),- // 1. Total documents uploaded in 2024- prisma.team.findUnique({- where: { id: teamId },- select: {- _count: {- select: {- documents: {- where: {- createdAt: {- gte: new Date("2024-01-01"),- lt: new Date("2024-12-01"),- },+ // 1. Total documents, links, and views for the year+ prisma.team.findUnique({+ where: { id: teamId },+ select: {+ _count: {+ select: {+ documents: {+ where: {+ createdAt: {+ gte: yearStart,+ lt: yearEnd,},},- links: {- where: {- createdAt: {- gte: new Date("2024-01-01"),- lt: new Date("2024-12-01"),- },+ },+ links: {+ where: {+ createdAt: {+ gte: yearStart,+ lt: yearEnd,},},- views: {- where: {- viewedAt: {- gte: new Date("2024-01-01"),- lt: new Date("2024-12-01"),- },+ },+ views: {+ where: {+ viewedAt: {+ gte: yearStart,+ lt: yearEnd,},+ isArchived: false,},},},},- }),+ },+ }),- // 2. Most viewed document- prisma.$queryRaw<- Array<{ documentId: string; documentName: string; viewCount: number }>- >(Prisma.sql`+ // 2. Most viewed document+ prisma.$queryRaw<+ Array<{ documentId: string; documentName: string; viewCount: number }>+ >(Prisma.sql`WITH RankedDocuments AS (SELECTd."id" as "documentId",@@ -64,8 +74,9 @@ export async function getYearInReviewStats(teamId: string) {LEFT JOIN "View" v ON v."documentId" = d."id"WHEREd."teamId" = ${teamId}- AND v."viewedAt" >= '2024-01-01'- AND v."viewedAt" < '2024-12-01'+ AND v."viewedAt" >= ${yearStart}+ AND v."viewedAt" < ${yearEnd}+ AND v."isArchived" = falseGROUP BY d."id", d."name")SELECT@@ -77,8 +88,8 @@ export async function getYearInReviewStats(teamId: string) {LIMIT 1`),- // 3. Most active month- prisma.$queryRaw<Array<{ month: Date; viewCount: number }>>(Prisma.sql`+ // 3. Most active month+ prisma.$queryRaw<Array<{ month: Date; viewCount: number }>>(Prisma.sql`WITH MonthlyViews AS (SELECTDATE_TRUNC('month', "viewedAt") as month,@@ -87,8 +98,9 @@ export async function getYearInReviewStats(teamId: string) {FROM "View"WHERE"teamId" = ${teamId}- AND "viewedAt" >= '2024-01-01'- AND "viewedAt" < '2024-12-01'+ AND "viewedAt" >= ${yearStart}+ AND "viewedAt" < ${yearEnd}+ AND "isArchived" = falseGROUP BY DATE_TRUNC('month', "viewedAt"))SELECT month, "viewCount"@@ -96,39 +108,93 @@ export async function getYearInReviewStats(teamId: string) {WHERE rn = 1LIMIT 1;`),- ]);++ // 4. Total datarooms for the year+ prisma.dataroom.count({+ where: {+ teamId,+ createdAt: {+ gte: yearStart,+ lt: yearEnd,+ },+ },+ }),++ // 5. Most active viewer (person who viewed most)+ prisma.$queryRaw<+ Array<{+ viewerEmail: string;+ viewerName: string | null;+ viewCount: number;+ }>+ >(Prisma.sql`+ WITH RankedViewers AS (+ SELECT+ v."viewerEmail",+ v."viewerName",+ COUNT(*) as "viewCount",+ ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as rn+ FROM "View" v+ WHERE+ v."teamId" = ${teamId}+ AND v."viewedAt" >= ${yearStart}+ AND v."viewedAt" < ${yearEnd}+ AND v."isArchived" = false+ AND v."viewerEmail" IS NOT NULL+ GROUP BY v."viewerEmail", v."viewerName"+ )+ SELECT+ "viewerEmail",+ "viewerName",+ "viewCount"+ FROM RankedViewers+ WHERE rn = 1+ LIMIT 1+ `),+ ]);// skip if no documentsif (documents.length === 0) {return {- totalDocuments: teamCounts?._count.documents,- totalLinks: teamCounts?._count.links,- totalViews: teamCounts?._count.views,+ year: currentYear,+ totalDocuments: teamCounts?._count.documents || 0,+ totalLinks: teamCounts?._count.links || 0,+ totalViews: teamCounts?._count.views || 0,+ totalDatarooms: dataroomCounts || 0,+ mostViewedDocument: null,+ mostActiveMonth: null,+ mostActiveViewer: null,+ totalDuration: 0,+ uniqueCountries: [],};}// get total duration for all documents in the team- const tinybirdData = await getTotalDuration({+ const tinybirdData = await getTotalTeamDuration({documentIds: documents.map((doc) => doc.id).join(","),+ since: yearStart.getTime(),+ until: yearEnd.getTime(),});// write full name of countries- const uniqueCountries = tinybirdData.data[0].unique_countries.map(- (country) => {+ const uniqueCountries = tinybirdData.data[0]?.unique_countries?.map(+ (country: string) => {// Map country codes to full names using COUNTRIES constantreturn COUNTRIES[country] || country;},- );+ ) || [];return {- totalDocuments: teamCounts?._count.documents,- totalLinks: teamCounts?._count.links,- totalViews: teamCounts?._count.views,+ year: currentYear,+ totalDocuments: teamCounts?._count.documents || 0,+ totalLinks: teamCounts?._count.links || 0,+ totalViews: teamCounts?._count.views || 0,+ totalDatarooms: dataroomCounts || 0,mostViewedDocument: mostViewedDoc[0]? {documentId: mostViewedDoc[0].documentId,documentName: mostViewedDoc[0].documentName,- viewCount: mostViewedDoc[0].viewCount,+ viewCount: Number(mostViewedDoc[0].viewCount),}: null,mostActiveMonth: mostActiveMonth?.[0]@@ -136,24 +202,17 @@ export async function getYearInReviewStats(teamId: string) {month: new Date(mostActiveMonth[0].month).toLocaleString("en-US", {month: "long",}),- viewCount: mostActiveMonth[0].viewCount,+ viewCount: Number(mostActiveMonth[0].viewCount),}: null,- totalDuration: tinybirdData.data[0].total_duration,+ mostActiveViewer: mostActiveViewer?.[0]+ ? {+ email: mostActiveViewer[0].viewerEmail,+ name: mostActiveViewer[0].viewerName,+ viewCount: Number(mostActiveViewer[0].viewCount),+ }+ : null,+ totalDuration: tinybirdData.data[0]?.total_duration || 0,uniqueCountries: uniqueCountries,};}--const tb = new Tinybird({ token: process.env.TINYBIRD_TOKEN! });--// tinybird pipe to get the total view duration for all documents in a team-export const getTotalDuration = tb.buildPipe({- pipe: "get_total_team_duration__v1",- parameters: z.object({- documentIds: z.string().describe("Comma separated documentIds"),- }),- data: z.object({- total_duration: z.number(),- unique_countries: z.array(z.string()),- }),-});diff --git a/package-lock.json b/package-lock.jsonindex 731a0f44..b9892727 100644--- a/package-lock.json+++ b/package-lock.json@@ -85,6 +85,7 @@"eslint-config-next": "^14.2.33","exceljs": "^4.4.0","fluent-ffmpeg": "^2.1.3",+ "html2canvas": "^1.4.1","input-otp": "^1.4.2","js-cookie": "^3.0.5","jsonwebtoken": "^9.0.2",@@ -9044,6 +9045,15 @@"resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.1.tgz","integrity": "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg=="},+ "node_modules/base64-arraybuffer": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",+ "integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6.0"+ }+ },"node_modules/base64-js": {"version": "1.5.1","resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",@@ -9895,6 +9905,15 @@"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz","integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="},+ "node_modules/css-line-break": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz",+ "integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",+ "license": "MIT",+ "dependencies": {+ "utrie": "^1.0.2"+ }+ },"node_modules/cssesc": {"version": "3.0.0","resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",@@ -12294,6 +12313,19 @@"url": "https://github.com/sponsors/wooorm"}},+ "node_modules/html2canvas": {+ "version": "1.4.1",+ "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz",+ "integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",+ "license": "MIT",+ "dependencies": {+ "css-line-break": "^2.1.0",+ "text-segmentation": "^1.0.3"+ },+ "engines": {+ "node": ">=8.0.0"+ }+ },"node_modules/htmlparser2": {"version": "8.0.2","resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz",@@ -18073,6 +18105,15 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/text-segmentation": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",+ "integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",+ "license": "MIT",+ "dependencies": {+ "utrie": "^1.0.2"+ }+ },"node_modules/text-table": {"version": "0.2.0","resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",@@ -18807,6 +18848,15 @@"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz","integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="},+ "node_modules/utrie": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz",+ "integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",+ "license": "MIT",+ "dependencies": {+ "base64-arraybuffer": "^1.0.2"+ }+ },"node_modules/uuid": {"version": "9.0.1","resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",diff --git a/package.json b/package.jsonindex a983e444..55cda1f2 100644--- a/package.json+++ b/package.json@@ -96,6 +96,7 @@"eslint-config-next": "^14.2.33","exceljs": "^4.4.0","fluent-ffmpeg": "^2.1.3",+ "html2canvas": "^1.4.1","input-otp": "^1.4.2","js-cookie": "^3.0.5","jsonwebtoken": "^9.0.2",diff --git a/pages/api/teams/[teamId]/yearly-recap.ts b/pages/api/teams/[teamId]/yearly-recap.tsnew file mode 100644index 00000000..8c306857--- /dev/null+++ b/pages/api/teams/[teamId]/yearly-recap.ts@@ -0,0 +1,33 @@+import { NextApiRequest, NextApiResponse } from "next";++import { getYearInReviewStats } from "@/lib/year-in-review/get-stats";++export default async function handler(+ req: NextApiRequest,+ res: NextApiResponse,+) {+ if (req.method !== "GET") {+ return res.status(405).json({ message: "Method not allowed" });+ }++ const { teamId } = req.query as { teamId: string };+ const year = req.query.year+ ? parseInt(req.query.year as string)+ : undefined;++ if (!teamId) {+ return res.status(400).json({ message: "Team ID is required" });+ }++ try {+ const stats = await getYearInReviewStats(teamId, year);+ return res.status(200).json(stats);+ } catch (error) {+ console.error("Error fetching yearly recap stats:", error);+ return res.status(500).json({+ message: "Internal server error",+ error: error instanceof Error ? error.message : "Unknown error",+ });+ }+}+diff --git a/pages/dashboard.tsx b/pages/dashboard.tsxindex cd3a533c..73a4cefa 100644--- a/pages/dashboard.tsx+++ b/pages/dashboard.tsx@@ -23,6 +23,7 @@ import ViewsTable from "@/components/analytics/views-table";import VisitorsTable from "@/components/analytics/visitors-table";import AppLayout from "@/components/layouts/app";import { TabMenu } from "@/components/tab-menu";+import { YearlyRecapBanner } from "@/components/yearly-recap/yearly-recap-banner";interface OverviewData {counts: {@@ -123,6 +124,7 @@ export default function DashboardPage() {return (<AppLayout><div className="flex-1 space-y-4 p-4 pt-6 md:p-8">+ <YearlyRecapBanner /><div className="flex items-center justify-between"><h2 className="text-3xl font-bold tracking-tight">Dashboard</h2><TimeRangeSelectdiff --git a/styles/globals.css b/styles/globals.cssindex 4ffa2d60..6a5f5b9e 100644--- a/styles/globals.css+++ b/styles/globals.css@@ -2,6 +2,21 @@@tailwind components;@tailwind utilities;+@layer utilities {+ @keyframes fade-in {+ from {+ opacity: 0;+ }+ to {+ opacity: 1;+ }+ }++ .animate-fade-in {+ animation: fade-in 0.5s ease-in-out;+ }+}+@layer base {:root {--background: 0 0% 100%; /* white */