Skip to content

Commit a073cfc

Browse files
committed
Add DownloadCVs to company page
1 parent 8818eeb commit a073cfc

File tree

3 files changed

+49
-28
lines changed

3 files changed

+49
-28
lines changed

src/app/(authenticated)/companies/[id]/page.tsx

+17-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ExternalLinkIcon, Scan } from "lucide-react";
1515
import Link from "next/link";
1616
import BlankPageWithMessage from "@/components/BlankPageMessage";
1717
import ConnectionTile from "@/components/user/ConnectionTile";
18+
import DownloadCVs from "@/components/company/DownloadCVs";
1819

1920
interface CompanyParams {
2021
id: string;
@@ -32,13 +33,13 @@ export default async function Company({ params }: { params: CompanyParams }) {
3233
}
3334

3435
const companySessions = company.sessions?.sort((a, b) =>
35-
a.date.localeCompare(b.date)
36+
a.date.localeCompare(b.date),
3637
);
3738
const companyMembers = company.members?.sort((a, b) =>
38-
a.name.localeCompare(b.name)
39+
a.name.localeCompare(b.name),
3940
);
4041
const companyStands = company.stands?.sort((a, b) =>
41-
a.date.localeCompare(b.date)
42+
a.date.localeCompare(b.date),
4243
);
4344
const hereToday = isHereToday(company);
4445

@@ -47,9 +48,17 @@ export default async function Company({ params }: { params: CompanyParams }) {
4748

4849
const companyConnections = await CompanyService.getConnections(
4950
session.cannonToken,
50-
companyID
51+
companyID,
5152
);
5253

54+
const downloadCVsLinks =
55+
user &&
56+
((isCompany(user.role) &&
57+
!!user.company?.length &&
58+
user.company[0].company === companyID) ||
59+
isMember(user.role)) &&
60+
(await CompanyService.getDownloadLinks(session.cannonToken, companyID));
61+
5362
return (
5463
<div className="container mx-auto">
5564
<div className="flex flex-col items-center gap-y-3 p-4 text-center">
@@ -74,6 +83,10 @@ export default async function Company({ params }: { params: CompanyParams }) {
7483
</span>
7584
)}
7685
</div>
86+
87+
{/* Download CVs */}
88+
{downloadCVsLinks && <DownloadCVs links={downloadCVsLinks} />}
89+
7790
{/* Members section */}
7891
{user && isMember(user.role) && (
7992
<div className="flex justify-center items-center p-4 gap-2">

src/app/(authenticated)/home/page.tsx

+2-24
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import UserSignOut from "@/components/UserSignOut";
2121
import { SPIN_WHEEL_MAXIMUM } from "@/constants";
2222
import { EventService } from "@/services/EventService";
2323
import { FileUser, Users } from "lucide-react";
24+
import DownloadCVs from "@/components/company/DownloadCVs";
2425

2526
const N_SESSION_TILES = 3;
2627
const N_COMPANY_TILES = 15;
@@ -103,30 +104,7 @@ export default async function Home() {
103104
)}
104105

105106
{/* Download CVs section */}
106-
{downloadCVsLinks && (
107-
<List title="Download CVs">
108-
{downloadCVsLinks.all && (
109-
<Link
110-
className="button-primary text-sm"
111-
href={downloadCVsLinks.all}
112-
download
113-
>
114-
<FileUser size={16} />
115-
Download all
116-
</Link>
117-
)}
118-
{downloadCVsLinks.companyConnections && (
119-
<Link
120-
className="button-tertiary text-sm"
121-
href={downloadCVsLinks.companyConnections}
122-
download
123-
>
124-
<Users size={16} />
125-
Download company connections
126-
</Link>
127-
)}
128-
</List>
129-
)}
107+
{downloadCVsLinks && <DownloadCVs links={downloadCVsLinks} />}
130108

131109
{/* Upcoming Sessions */}
132110
<List
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { FileUser, Users } from "lucide-react";
2+
import Link from "next/link";
3+
import List from "../List";
4+
5+
interface DownloadCVsProps {
6+
links: DownloadLinks;
7+
}
8+
9+
export default function DownloadCVs({ links }: DownloadCVsProps) {
10+
return (
11+
<List title="Download CVs">
12+
{links.all && (
13+
<Link className="button-primary text-sm" href={links.all} download>
14+
<FileUser size={16} />
15+
Download all
16+
</Link>
17+
)}
18+
{links.companyConnections && (
19+
<Link
20+
className="button-tertiary text-sm"
21+
href={links.companyConnections}
22+
download
23+
>
24+
<Users size={16} />
25+
Download company connections
26+
</Link>
27+
)}
28+
</List>
29+
);
30+
}

0 commit comments

Comments
 (0)