Skip to content

Commit

Permalink
fix: dont display teams with empty digest (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
baptadn authored Feb 28, 2024
1 parent 8589d23 commit 0924642
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/components/ActiveTeams.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import TeamAvatar from './teams/TeamAvatar';
import Link from 'next/link';
import TeamAvatar from './teams/TeamAvatar';

interface Props {
teams: {
Expand All @@ -10,7 +9,10 @@ interface Props {
}[];
}
export default function ActiveTeams({ teams }: Props) {
if (teams.length === 0) return <></>;
if (teams.length === 0) {
return <></>;
}

return (
<div className="bg-white p-4 border border-gray-200 rounded-lg">
<h4 className="text-xl font-bold">Active Teams</h4>
Expand Down
9 changes: 7 additions & 2 deletions src/services/database/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ export const getPublicTeam = (slug: string) =>
export const getRecentTeams = async () => {
const digests = await db.digest.findMany({
take: 5,
select: { team: { select: { name: true, slug: true, color: true } } },
where: { publishedAt: { not: null } },
select: {
team: { select: { name: true, slug: true, color: true } },
},
where: {
publishedAt: { not: null },
digestBlocks: { some: {} },
},
orderBy: { publishedAt: 'desc' },
distinct: ['teamId'],
});
Expand Down

0 comments on commit 0924642

Please sign in to comment.