Skip to content

Commit 10df1ef

Browse files
committed
Merge branch 'main' into company-filter
2 parents 1f8c1a3 + 8feb4c6 commit 10df1ef

File tree

6 files changed

+47
-36
lines changed

6 files changed

+47
-36
lines changed

apps/web/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const config = {
2626
remotePatterns: [
2727
{
2828
protocol: "https",
29-
hostname: "logo.clearbit.com",
29+
hostname: "img.logo.dev",
3030
port: "",
3131
pathname: "/**",
3232
},

apps/web/src/app/(pages)/(dashboard)/companies/company/page.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use client";
22

3-
import Image from "next/image";
43
import { useSearchParams } from "next/navigation";
54

5+
import Logo from "@cooper/ui/logo";
6+
67
import RenderAllRoles from "~/app/_components/companies/all-company-roles";
78
import { CompanyAbout } from "~/app/_components/companies/company-about";
89
import { CompanyReview } from "~/app/_components/companies/company-reviews";
@@ -23,13 +24,7 @@ export default function Company() {
2324
<div className="mb-6 mt-6 flex items-center justify-between">
2425
<div className="flex items-center">
2526
<div className="mr-3 flex h-16 w-16 items-center justify-center">
26-
<Image
27-
src={`https://logo.clearbit.com/${company.data?.name.replace(/\s/g, "")}.com`}
28-
width={80}
29-
height={80}
30-
alt={`Logo of ${company.data?.name}`}
31-
className="rounded-md"
32-
/>
27+
{company.data && <Logo company={company.data} size="small" />}
3328
</div>
3429
<div>
3530
<h1 className="text-4xl font-bold">{company.data?.name}</h1>

apps/web/src/app/_components/companies/company-card-preview.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import Image from "next/image";
2-
31
import type { CompanyType } from "@cooper/db/schema";
42
import { Card, CardContent, CardHeader, CardTitle } from "@cooper/ui/card";
3+
import Logo from "@cooper/ui/logo";
54

65
import { api } from "~/trpc/react";
76
import { prettyLocationName } from "~/utils/locationHelpers";
@@ -22,13 +21,7 @@ export function CompanyCardPreview({ companyObj }: CompanyCardPreviewProps) {
2221
<div>
2322
<CardHeader className="pb-3">
2423
<div className="flex items-center justify-start space-x-4">
25-
<Image
26-
src={`https://logo.clearbit.com/${companyObj.name.replace(/\s/g, "")}.com`}
27-
width={75}
28-
height={75}
29-
alt={`Logo of ${companyObj.name}`}
30-
className="h-20 w-20 rounded-lg"
31-
/>
24+
<Logo company={companyObj} />
3225
<div>
3326
<CardTitle className="text-xl">{companyObj.name}</CardTitle>
3427
</div>

apps/web/src/app/_components/footer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default function Footer() {
3030
Submit Feedback or Bug Reports!
3131
</h2>
3232
</Link>
33-
<a href="https://clearbit.com" target="_blank" className="italic">
34-
Logos provided by Clearbit
33+
<a href="https://logo.dev" target="_blank" className="italic">
34+
Logos provided by Logo.dev
3535
</a>
3636
</div>
3737
</footer>

apps/web/src/app/_components/reviews/role-info.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
"use client";
2-
31
import Image from "next/image";
42
import Link from "next/link";
53

64
import type { ReviewType, RoleType } from "@cooper/db/schema";
75
import { cn } from "@cooper/ui";
86
import { CardContent, CardHeader, CardTitle } from "@cooper/ui/card";
7+
import Logo from "@cooper/ui/logo";
98

109
import { api } from "~/trpc/react";
1110
import { prettyLocationName } from "~/utils/locationHelpers";
@@ -64,13 +63,7 @@ export function RoleInfo({ className, roleObj }: RoleCardProps) {
6463
<CardHeader className="pb-3">
6564
<div className="flex items-center justify-start space-x-4">
6665
{companyData ? (
67-
<Image
68-
src={`https://logo.clearbit.com/${companyData.name.replace(/\s/g, "")}.com`}
69-
width={80}
70-
height={80}
71-
alt={`Logo of ${companyData.name}`}
72-
className="h-20 w-20 rounded-lg"
73-
/>
66+
<Logo company={companyData} />
7467
) : (
7568
<div className="h-20 w-20 rounded-lg border bg-cooper-blue-200"></div>
7669
)}
@@ -130,13 +123,7 @@ export function RoleInfo({ className, roleObj }: RoleCardProps) {
130123
<div className="h-full" id="company">
131124
<InfoCard title={`About ${companyData.name}`}>
132125
<div className="flex gap-4 overflow-scroll text-[#5a5a5a]">
133-
<Image
134-
src={`https://logo.clearbit.com/${companyData.name.replace(/\s/g, "")}.com`}
135-
width={80}
136-
height={80}
137-
alt={`Logo of ${companyData.name}`}
138-
className="h-20 w-20 rounded-lg"
139-
/>
126+
<Logo company={companyData} />
140127
<p className="h-40 overflow-scroll">
141128
{companyData.description}
142129
</p>

packages/ui/src/logo.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"use client";
2+
3+
import { useState } from "react";
4+
import Image from "next/image";
5+
6+
import type { CompanyType } from "../../db/src/schema/companies";
7+
8+
interface ILogoProps {
9+
company: CompanyType;
10+
size?: "small" | "default";
11+
}
12+
13+
const Logo: React.FC<ILogoProps> = ({ company, size }) => {
14+
const rawWebsite = company.website;
15+
const website =
16+
rawWebsite && rawWebsite !== ""
17+
? rawWebsite.replace(/^(https?:\/\/)/, "")
18+
: `${company.name.replace(/\s/g, "")}.com`;
19+
const [imageError, setImageError] = useState(false);
20+
return imageError ? (
21+
<div className="flex aspect-square max-h-20 min-h-16 min-w-16 max-w-20 items-center justify-center rounded-md bg-cooper-gray-200 text-4xl font-bold text-white">
22+
{company.name.charAt(0)}
23+
</div>
24+
) : (
25+
<Image
26+
src={`https://img.logo.dev/${website}?token=pk_DNxGM2gHTjiLU3p79GX79A`}
27+
width={80}
28+
height={80}
29+
alt={`Logo of ${company.name}`}
30+
className={`${size === "small" ? "" : "h-20 w-20"} rounded-lg`}
31+
onError={() => setImageError(true)}
32+
/>
33+
);
34+
};
35+
36+
export default Logo;

0 commit comments

Comments
 (0)