doc: added RenderCards method
This commit is contained in:
1 parent
c3225e8da5
commit
e46682f508
1 file changed
+16
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user