Skip to content

Commit

Permalink
Revert "Startup modal (#96)"
Browse files Browse the repository at this point in the history
This reverts commit 4b944d6.
  • Loading branch information
iyasinn authored Sep 3, 2024
1 parent 4b944d6 commit 38d2640
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 138 deletions.
22 changes: 9 additions & 13 deletions components/startups/StartupProfileTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Dialog, Transition } from "@headlessui/react";
import useSupabase from "../../hooks/useSupabase";
import supabase from "../../utils/supabaseClient";
import { StartupProfile, StartupProfileMetadata } from "../../utils/types";
import InternalLink from "../Link";

const CONNECTION_REQUEST_URL =
process.env.NODE_ENV === "development"
Expand Down Expand Up @@ -66,18 +65,15 @@ export default function StartupProfileTile({
}

return (
<div className="flex flex-col items-center p-2">
<InternalLink href={`/profile/${username}`}>
<img
className="rounded-xl"
src={headshotSrc ?? anonymousPersonImage}
height={60}
width={60}
alt={`${displayName} headshot`}
/>
</InternalLink>

<h1 className="mt-1 text-sm">{displayName}</h1>
<div className="flex flex-col items-center mr-5 w-36 mb-5">
<img
className="rounded-xl"
src={headshotSrc ?? anonymousPersonImage}
height={80}
width={80}
alt={`${displayName} headshot`}
/>
<h1 className="mt-1">{displayName}</h1>
<p className="text-gray-500 text-xs">{role}</p>
{connectionSent ? (
<p className="text-xs px-2 py-1 mt-2 font-inter text-center">
Expand Down
137 changes: 13 additions & 124 deletions components/startups/StartupTile.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import React, { Fragment, useState, useEffect } from "react";
import React, { Fragment, useState } from "react";
import {
InformationCircleIcon,
ExternalLinkIcon,
HeartIcon as HeartOutlineIcon,
} from "@heroicons/react/outline";
import { HeartIcon as HeartFilledIcon } from "@heroicons/react/solid";
import { Dialog, Transition } from "@headlessui/react";
import useSupabase from "../../hooks/useSupabase";
import { Project, Startup } from "../../utils/types";
import { Startup } from "../../utils/types";
import StartupProfileTile from "./StartupProfileTile";

interface Favorite {
user_id: string;
startup_id: number;
}

export default function StartupTile({ startup }: { startup: Startup }) {
const {
name,
Expand All @@ -28,69 +20,6 @@ export default function StartupTile({ startup }: { startup: Startup }) {
startups_members: profileMetadata,
} = startup;
const [dialogOpen, setDialogOpen] = useState(false);
const [isFavorite, setIsFavorite] = useState(false);
const [projects, setProjects] = useState<Project[]>([]);

const { supabase, user } = useSupabase();

useEffect(() => {
const checkIfFavorite = async () => {
if (!user) {
return;
}

const { data } = await supabase
.from<Favorite>("favorites")
.select("*")
.eq("user_id", user.id)
.eq("startup_id", startup.id)
.single();

if (data) {
setIsFavorite(true);
}
};

const fetchProjects = async () => {
const { data } = await supabase
.from<Project>("projects")
.select("*")
.eq("startup_id", startup.id);

if (data) {
setProjects(data);
}
};

checkIfFavorite();
fetchProjects();
}, [user, supabase, startup.id]);

const toggleFavorite = async () => {
if (!user) {
return;
}

if (isFavorite) {
const { error } = await supabase
.from("favorites")
.delete()
.eq("user_id", user.id)
.eq("startup_id", startup.id);

if (!error) {
setIsFavorite(false);
}
} else {
const { error } = await supabase
.from("favorites")
.insert([{ user_id: user.id, startup_id: startup.id }]);

if (!error) {
setIsFavorite(true);
}
}
};

return (
<>
Expand Down Expand Up @@ -181,31 +110,17 @@ export default function StartupTile({ startup }: { startup: Startup }) {
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-xl transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<div className="relative flex flex-col gap-y-4">
<div className="flex flex-col gap-y-4">
<div className="flex gap-x-8">
<img
src={logo}
className="w-48 rounded-lg"
alt={`${name} logo`}
/>
<div className="flex flex-col gap-y-4">
<div className="flex gap-3">
<h1 className="text-4xl font-bold text-gray-900">
{name}
</h1>
<button
type="button"
onClick={toggleFavorite}
className="hover:scale-110 transition-transform duration-200 focus:outline-none"
>
{isFavorite ? (
<HeartFilledIcon className="w-7 h-7 text-red-500" />
) : (
<HeartOutlineIcon className="w-7 h-7 text-gray-500 stroke-[1.5px]" />
)}
</button>
</div>

<h1 className="text-4xl font-bold text-gray-900">
{name}
</h1>
<a
href={website}
target="_blank"
Expand All @@ -227,39 +142,13 @@ export default function StartupTile({ startup }: { startup: Startup }) {
))}
</div>
</div>
<div className="flex flex-col">
<span className="text-primary font-medium text-lg mb-2">
People
</span>
<div className="grid grid-cols-4 justify-between">
{profiles?.map((profile, i) => (
<StartupProfileTile
startupProfile={profile}
startupProfileMetadata={profileMetadata[i]}
/>
))}
</div>
</div>

<div className="flex flex-col">
<span className="text-primary font-medium text-lg mb-2">
Projects
</span>
<div className="grid grid-cols-2 justify-between gap-4">
{projects?.map((project) => (
<div
key={project.id}
className=" bg-gray-100 rounded-lg flex flex-col gap-y-1 p-3"
>
<p className="text-sm text-gray-900">
{project.name}
</p>
<p className="text-xs text-gray-600">
{project.description}
</p>
</div>
))}
</div>
<div className="flex flex-wrap justify-center">
{profiles?.map((profile, i) => (
<StartupProfileTile
startupProfile={profile}
startupProfileMetadata={profileMetadata[i]}
/>
))}
</div>
</div>
</Dialog.Panel>
Expand Down
1 change: 0 additions & 1 deletion utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ export type Project = {
name: string;
categories: string;
link: string;
startup_id: number;
};

0 comments on commit 38d2640

Please sign in to comment.