Skip to content

Commit

Permalink
Merge pull request #358 from mfts/feat/downloads
Browse files Browse the repository at this point in the history
feat: add download icon for downloaded documents
  • Loading branch information
mfts authored Mar 22, 2024
2 parents c596508 + ee9ee9c commit 1c96446
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
5 changes: 2 additions & 3 deletions components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
{navigation.map((item) => {
if (item.name === "Documents") {
return (
<>
<div key={item.name}>
<button
key={item.name}
onClick={() => router.push(item.href)}
disabled={item.disabled}
className={cn(
Expand All @@ -193,7 +192,7 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
{item.name}
</button>
{item.active ? <SiderbarFolders /> : null}
</>
</div>
);
}
return (
Expand Down
10 changes: 9 additions & 1 deletion components/visitors/visitors-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { durationFormat, timeAgo } from "@/lib/utils";
import ChevronDown from "@/components/shared/icons/chevron-down";
import VisitorChart from "./visitor-chart";
import { VisitorAvatar } from "./visitor-avatar";
import { BadgeCheckIcon, BadgeInfoIcon } from "lucide-react";
import { BadgeCheckIcon, BadgeInfoIcon, DownloadCloudIcon } from "lucide-react";
import { BadgeTooltip } from "@/components/ui/tooltip";

export default function VisitorsTable({ numPages }: { numPages: number }) {
Expand Down Expand Up @@ -82,6 +82,14 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {
<BadgeInfoIcon className="h-4 w-4 text-blue-500 hover:text-blue-600" />
</BadgeTooltip>
)}
{view.downloadedAt && (
<BadgeTooltip
content={`Downloaded ${timeAgo(view.downloadedAt)}`}
key="download"
>
<DownloadCloudIcon className="h-4 w-4 text-cyan-500 hover:text-cyan-600" />
</BadgeTooltip>
)}
</>
) : (
"Anonymous"
Expand Down
14 changes: 12 additions & 2 deletions context/team-context.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { createContext, useContext, useMemo, useState } from "react";
import {
createContext,
useCallback,
useContext,
useMemo,
useState,
} from "react";
import { useTeams } from "@/lib/swr/use-teams";
import { Team } from "@/lib/types";

Expand All @@ -24,7 +30,11 @@ const TeamContext = createContext<TeamContextType | null>(initialState);

export const TeamProvider = ({ children }: TeamContextProps): JSX.Element => {
const { teams, loading } = useTeams();
const [currentTeam, setCurrentTeam] = useState<Team | null>(null);
const [currentTeam, setCurrentTeamState] = useState<Team | null>(null);

const setCurrentTeam = useCallback((team: Team) => {
setCurrentTeamState(team);
}, []);

const currentTeamId = currentTeam
? currentTeam.id
Expand Down
23 changes: 23 additions & 0 deletions pages/api/health.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@/lib/prisma";

export default async function handler(
_req: NextApiRequest,
res: NextApiResponse,
) {
try {
await prisma.$queryRaw`SELECT 1`;

return res.json({
status: "ok",
message: "All systems operational",
});
} catch (err) {
console.error(err);

return res.status(500).json({
status: "error",
message: (err as Error).message,
});
}
}

0 comments on commit 1c96446

Please sign in to comment.