Skip to content

Commit

Permalink
feat: add agreement in visitor table
Browse files Browse the repository at this point in the history
  • Loading branch information
mfts committed Jun 11, 2024
1 parent a51f287 commit 6cedb49
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/view/access-form/agreement-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function AgreementSection({
onCheckedChange={handleCheckChange}
className="mt-0.5 border border-gray-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-300 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-white data-[state=checked]:bg-black data-[state=checked]:text-white"
/>
<label className="text-sm font-medium leading-5 text-white peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
<label className="text-sm font-normal leading-5 text-white peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
I have reviewed and agree to the terms of this{" "}
<a
href={`${agreementContent}`}
Expand Down
15 changes: 14 additions & 1 deletion components/visitors/dataroom-visitors-table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { BadgeCheckIcon, BadgeInfoIcon, MailOpenIcon } from "lucide-react";
import {
BadgeCheckIcon,
BadgeInfoIcon,
FileBadgeIcon,
MailOpenIcon,
} from "lucide-react";

import ChevronDown from "@/components/shared/icons/chevron-down";
import {
Expand Down Expand Up @@ -87,6 +92,14 @@ export default function DataroomVisitorsTable({
<BadgeInfoIcon className="h-4 w-4 text-blue-500 hover:text-blue-600" />
</BadgeTooltip>
)}
{view.agreementResponse && (
<BadgeTooltip
content={`Agreed to ${view.agreementResponse.agreement.name}`}
key="nda-agreement"
>
<FileBadgeIcon className="h-4 w-4 text-emerald-500 hover:text-emerald-600" />
</BadgeTooltip>
)}
</>
) : (
"Anonymous"
Expand Down
9 changes: 9 additions & 0 deletions components/visitors/visitors-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BadgeCheckIcon,
BadgeInfoIcon,
DownloadCloudIcon,
FileBadgeIcon,
ServerIcon,
ThumbsDownIcon,
ThumbsUpIcon,
Expand Down Expand Up @@ -112,6 +113,14 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {
<BadgeInfoIcon className="h-4 w-4 text-blue-500 hover:text-blue-600" />
</BadgeTooltip>
)}
{view.agreementResponse && (
<BadgeTooltip
content={`Agreed to ${view.agreementResponse.agreement.name}`}
key="nda-agreement"
>
<FileBadgeIcon className="h-4 w-4 text-emerald-500 hover:text-emerald-600" />
</BadgeTooltip>
)}
{view.downloadedAt && (
<BadgeTooltip
content={`Downloaded ${timeAgo(view.downloadedAt)}`}
Expand Down
15 changes: 11 additions & 4 deletions lib/swr/use-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ interface ViewWithDuration extends View {
answer: string;
};
} | null;
agreementResponse: {
id: string;
agreementId: string;
agreement: {
name: string;
};
} | null;
}

type TStatsData = {
Expand All @@ -99,9 +106,7 @@ export function useDocumentVisits(page: number, limit: number) {

const cacheKey =
teamId && id
? `/api/teams/${teamInfo?.currentTeam?.id}/documents/${encodeURIComponent(
id,
)}/views?page=${page}&limit=${limit}`
? `/api/teams/${teamId}/documents/${id}/views?page=${page}&limit=${limit}`
: null;

const { data: views, error } = useSWR<TStatsData>(cacheKey, fetcher, {
Expand All @@ -124,9 +129,11 @@ interface DocumentProcessingStatus {

export function useDocumentProcessingStatus(documentVersionId: string) {
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;

const { data: status, error } = useSWR<DocumentProcessingStatus>(
`/api/teams/${teamInfo?.currentTeam?.id}/documents/document-processing-status?documentVersionId=${documentVersionId}`,
teamId &&
`/api/teams/${teamId}/documents/document-processing-status?documentVersionId=${documentVersionId}`,
fetcher,
{
refreshInterval: 3000, // refresh every 3 seconds
Expand Down
11 changes: 11 additions & 0 deletions pages/api/teams/[teamId]/datarooms/[id]/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ export default async function handle(
name: true,
},
},
agreementResponse: {
select: {
id: true,
agreementId: true,
agreement: {
select: {
name: true,
},
},
},
},
},
},
},
Expand Down
11 changes: 11 additions & 0 deletions pages/api/teams/[teamId]/documents/[id]/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ export default async function handle(
data: true,
},
},
agreementResponse: {
select: {
id: true,
agreementId: true,
agreement: {
select: {
name: true,
},
},
},
},
},
});

Expand Down

0 comments on commit 6cedb49

Please sign in to comment.