Skip to content

Commit 5503878

Browse files
committed
fix logos and update stats
1 parent 101fa40 commit 5503878

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

apps/web/pages/index.tsx

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ const tiers = [
7272
},
7373
];
7474

75-
const Home = (props: { accounts: Props[] }) => {
75+
const Home = (props: {
76+
accounts: Props[];
77+
messages: string;
78+
members: string;
79+
}) => {
7680
const accounts = props.accounts;
81+
const messages = props.messages;
82+
const members = props.members;
7783
return (
7884
<div className="mb-10 pb-10">
7985
<Head>
@@ -178,15 +184,15 @@ const Home = (props: { accounts: Props[] }) => {
178184
Messages Synced
179185
</dt>
180186
<dd className="order-1 text-4xl md:text-5xl font-extrabold text-white">
181-
7,500,000+
187+
{messages}+
182188
</dd>
183189
</div>
184190
<div className="flex flex-col mt-10 sm:mt-0">
185191
<dt className="order-2 mt-2 text-lg leading-6 font-medium text-blue-200">
186192
Members
187193
</dt>
188194
<dd className="order-1 text-4xl md:text-5xl font-extrabold text-white">
189-
250,000+
195+
{members}+
190196
</dd>
191197
</div>
192198
</dl>
@@ -203,19 +209,9 @@ const Home = (props: { accounts: Props[] }) => {
203209

204210
<div className="flex flex-col md:grid md:grid-cols-2 lg:grid-cols-3 gap-3 mt-10">
205211
{accounts.map((a, index) => {
206-
let url = a.premium
207-
? 'https://' + a.redirectDomain
208-
: a.discordDomain
209-
? 'https://linen.dev/d/' + a.discordDomain
210-
: 'https://linen.dev/s/' + a.slackDomain;
211-
212-
// TODO:remove this once supabase sets up domain to discord.supabase.com
213-
if (url.includes('supabase')) {
214-
url = 'https://839993398554656828.linen.dev/';
215-
}
216212
return (
217213
<CommunityCard
218-
url={url}
214+
url={'https://' + a.redirectDomain}
219215
communityName={a.name}
220216
description="Community"
221217
logoUrl={a.logoUrl}
@@ -376,20 +372,20 @@ const CommunityCard = ({
376372
}) => {
377373
return (
378374
<a
379-
className="flex items-center justify-center rounded py-8"
375+
className="flex items-center justify-center rounded"
380376
style={{
381377
backgroundColor: brandColor,
382378
}}
383379
href={url}
384380
target="_blank"
385381
rel="noreferrer"
386382
>
387-
<div className="relative py-8 w-full">
383+
<div className="relative h-28 w-52 m-2">
388384
<Image
389385
src={logoUrl}
390386
alt="Logo"
391387
fill
392-
style={{ maxWidth: 200, margin: 'auto' }}
388+
style={{ objectFit: 'contain' }}
393389
></Image>
394390
</div>
395391
</a>
@@ -406,16 +402,25 @@ type Props = {
406402
discordDomain: string;
407403
};
408404

405+
function makeNumberPretty(num: number) {
406+
// Check if the number is greater than or equal to 1 million
407+
if (num >= 1000000) {
408+
// Divide the number by 1 million and round it to the nearest integer
409+
const millions = Math.round(num / 1000000);
410+
// Return the formatted string with millions and commas
411+
return millions.toLocaleString() + ',000,000';
412+
} else {
413+
// Return the formatted string with commas
414+
return num.toLocaleString();
415+
}
416+
}
417+
409418
export async function getStaticProps() {
410419
const accounts = await prisma.accounts.findMany({
411420
where: {
412-
NOT: [
413-
{
414-
logoUrl: null,
415-
redirectDomain: null,
416-
},
417-
],
418-
syncStatus: 'DONE',
421+
logoUrl: { not: null },
422+
redirectDomainPropagate: true,
423+
redirectDomain: { notIn: ['linen.linentest.com'] },
419424
},
420425
select: {
421426
logoUrl: true,
@@ -424,17 +429,20 @@ export async function getStaticProps() {
424429
brandColor: true,
425430
redirectDomain: true,
426431
},
432+
orderBy: [
433+
{
434+
createdAt: 'asc',
435+
},
436+
],
427437
});
428438

429-
const goodLookingLogos = accounts.filter((a) => a.logoUrl?.includes('.svg'));
430-
// since we use 3 columns we want it to only show numbers divisible by 3
431-
const remainders = goodLookingLogos.slice(
432-
0,
433-
goodLookingLogos.length - (goodLookingLogos.length % 3)
434-
);
439+
const messages = makeNumberPretty(await prisma.messages.count());
440+
const members = makeNumberPretty(await prisma.users.count());
441+
442+
const remainders = accounts.slice(0, accounts.length - (accounts.length % 3));
435443

436444
return {
437-
props: { accounts: remainders },
445+
props: { accounts: remainders, messages, members },
438446
};
439447
}
440448

0 commit comments

Comments
 (0)