doc: added RenderCards method

This commit is contained in:
Leon Xu committed 2023-01-29 19:44:34 -08:00
1 parent c3225e8da5
commit e46682f508
1 file changed
+16
+16
View File
@@ -1,6 +1,15 @@
import React, { useState, useEffect } from "react";
import { Loader, Card, FormField } from "../components";
const RenderCards = ({ data, title }) => {
if (data?.length > 0) {
return data.map((post) => <Card key={post._id} {...post} />);
}
return (
<h2 className="mt-5 font-bold text-[#6449ff] text-xl uppercase">{title}</h2>
);
};
const Home = () => {
const [loading, setLoading] = useState(false);
const [allPosts, setAllPosts] = useState(null);
@@ -35,6 +44,13 @@ const Home = () => {
<span className="text-[#222328]">{searchText}</span>
</h2>
)}
<div className="grid lg:grid-cols-4 sm:grid-cols-3 xs:grid-cols-2 grid-cols-1 gap-3">
{searchText ? (
<RenderCards data={[]} title="No search results found" />
) : (
<RenderCards data={[]} title="No posts found" />
)}
</div>
</>
)}
</div>