Skip to content

Commit

Permalink
Add fetching and displaying profile information for startups
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasiwnl committed Jan 30, 2024
1 parent d530c7c commit 25d2d73
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
6 changes: 5 additions & 1 deletion components/DirectoryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const DirectoryLayout = (props: LayoutProps) => {

useEffect(() => {
const fetchStartups = async () => {
const { data } = await supabase.from("startups").select();
const { data } = await supabase
.from("startups")
// This is necessary due to Supabase's API formatting requirements.
// eslint-disable-next-line quotes
.select(`*, profiles!startups_members (username, name)`);
setStartups(data);
};
fetchStartups();
Expand Down
14 changes: 4 additions & 10 deletions components/startups/StartupProfileTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ export default function StartupProfileTile({
}: {
startupProfile: StartupProfile;
}) {
const { headshot, name, role } = startupProfile;
const { username, name } = startupProfile;

return (
<div className="flex flex-col items-center mr-5">
<img
className="rounded-lg"
height={90}
width={90}
src={headshot}
alt={name}
/>
<h1 className="mt-1">{name}</h1>
<p className="text-gray-400 text-xs">{role}</p>
<h1 className="mt-1">{name ?? username}</h1>
{/* TODO(jonas): roles+images */}
<p className="text-gray-400 text-xs">Software Engineer</p>
</div>
);
}
6 changes: 3 additions & 3 deletions components/startups/StartupTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Startup } from "../../utils/types";
import StartupProfileTile from "./StartupProfileTile";

export default function StartupTile({ startup }: { startup: Startup }) {
const { name, description, logo, website, industries, members } = startup;
const { name, description, logo, website, industries, profiles } = startup;
const [dialogOpen, setDialogOpen] = useState(false);

return (
Expand Down Expand Up @@ -135,8 +135,8 @@ export default function StartupTile({ startup }: { startup: Startup }) {
</div>
</div>
<div className="flex">
{members?.map((member) => (
<StartupProfileTile startupProfile={member} />
{profiles?.map((profile) => (
<StartupProfileTile startupProfile={profile} />
))}
</div>
</div>
Expand Down
7 changes: 3 additions & 4 deletions utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export type StartupProfile = {
headshot: string;
name: string;
role: string;
name: string | null;
username: string;
};

export type Startup = {
Expand All @@ -16,5 +15,5 @@ export type Startup = {
stage: string;
tech: string[];
website: string;
members: StartupProfile[];
profiles: StartupProfile[];
};

0 comments on commit 25d2d73

Please sign in to comment.