-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Charlie ⚡
committed
Sep 5, 2022
1 parent
c97b8e0
commit af3f9d4
Showing
12 changed files
with
152 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useCallback } from "react"; | ||
import useSWR from "swr"; | ||
import { addFeed, getFeeds } from "../lib/fetcher"; | ||
import { RecommendationCard } from "./ui/recommendation-card"; | ||
|
||
interface RecommendationListProps { | ||
recommended: [string, Array<{ displayName: string; link: string }>][]; | ||
} | ||
|
||
export const RecommendationList = ({ recommended }: RecommendationListProps) => { | ||
const { data, error, mutate } = useSWR("recommended feeds", getFeeds); | ||
|
||
const handleClick = useCallback( | ||
async (link: string) => { | ||
const data = await addFeed(link); | ||
|
||
await mutate((prevData) => { | ||
prevData?.feeds.push(data.addFeed); | ||
|
||
return prevData; | ||
}); | ||
}, | ||
[mutate] | ||
); | ||
|
||
return ( | ||
<div className="space-y-8 pb-8"> | ||
{error && <div>{error.toString()}</div>} | ||
{recommended.map(([key, recommendedFeeds], idx) => { | ||
return ( | ||
<section key={idx}> | ||
<h2 className="text-lg opacity-50">{key}</h2> | ||
|
||
<ul | ||
role="list" | ||
className="mt-4 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3"> | ||
{recommendedFeeds.map((r) => ( | ||
<li key={r.displayName} className="col-span-1"> | ||
<RecommendationCard | ||
displayName={r.displayName} | ||
link={r.link} | ||
feeds={data} | ||
error={error} | ||
onSubscribe={handleClick} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</section> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
fragment FeedDetails on Feed { | ||
id | ||
title | ||
link | ||
feedURL | ||
} | ||
|
||
query GetFeeds { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
af3f9d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
reubin – ./
pre-alpha.reubin.app
reubin.app
reubin-site.vercel.app
reubin-hephaestus.vercel.app
reubin-git-main-hephaestus.vercel.app
alpha.reubin.app