Skip to content

Commit

Permalink
Addded Comming Soon
Browse files Browse the repository at this point in the history
  • Loading branch information
BhavanaK223 committed Feb 19, 2025
1 parent 8ad25e7 commit 5961a13
Showing 1 changed file with 69 additions and 68 deletions.
137 changes: 69 additions & 68 deletions src/client/routes/blogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,79 +78,80 @@ export const Route = createFileRoute("/blogs")({
setError(null);
};

if (blogs.isLoading) return <div>Loading blogs...</div>;
if (blogs.isError) return <div>Error loading blogs: {blogs.error.message}</div>;
// if (blogs.isLoading) return <div>Loading blogs...</div>;
// if (blogs.isError) return <div>Error loading blogs: {blogs.error.message}</div>;

return (
<div className="container mx-auto p-4">
<h1 className="mb-6 text-3xl font-bold">Blogs</h1>
<p>Coming Soon!</p>
// <div className="container mx-auto p-4">
// <h1 className="mb-6 text-3xl font-bold">Blogs</h1>

{isAuthenticated && !isCreating && !isEditing && (
<Button onClick={() => setIsCreating(true)} className="mb-4">
Create New Blog Post
</Button>
)}
// {isAuthenticated && !isCreating && !isEditing && (
// <Button onClick={() => setIsCreating(true)} className="mb-4">
// Create New Blog Post
// </Button>
// )}

{(isCreating || isEditing) && (
<div className="mb-8 rounded-lg bg-white p-6 shadow-md">
<h2 className="mb-4 text-2xl font-bold">{isCreating ? "Create New Blog Post" : "Edit Blog Post"}</h2>
<div className="space-y-4">
<div>
<label className="mb-1 block text-sm font-medium text-gray-700">Title</label>
<Input value={newBlogTitle} onChange={(e) => setNewBlogTitle(e.target.value)} placeholder="Enter blog title" className="w-full" />
</div>
<div>
<label className="mb-1 block text-sm font-medium text-gray-700">Content</label>
<Textarea
value={newBlogContent}
onChange={(e) => setNewBlogContent(e.target.value)}
placeholder="Enter blog content"
className="min-h-[200px] w-full"
/>
</div>
<div>
<label className="mb-1 block text-sm font-medium text-gray-700">Tags</label>
<Input
value={newBlogTags}
onChange={(e) => setNewBlogTags(e.target.value)}
placeholder="Enter tags (comma-separated)"
className="w-full"
/>
</div>
</div>
<div className="mt-4 space-x-2">
<Button onClick={isCreating ? handleCreateBlog : handleUpdateBlog}>{isCreating ? "Create Post" : "Update Post"}</Button>
<Button
variant="secondary"
onClick={() => {
setIsCreating(false);
setIsEditing(false);
setCurrentBlog(null);
resetForm();
}}
>
Cancel
</Button>
</div>
{error && <div className="mt-2 text-red-500">{error}</div>}
</div>
)}
// {(isCreating || isEditing) && (
// <div className="mb-8 rounded-lg bg-white p-6 shadow-md">
// <h2 className="mb-4 text-2xl font-bold">{isCreating ? "Create New Blog Post" : "Edit Blog Post"}</h2>
// <div className="space-y-4">
// <div>
// <label className="mb-1 block text-sm font-medium text-gray-700">Title</label>
// <Input value={newBlogTitle} onChange={(e) => setNewBlogTitle(e.target.value)} placeholder="Enter blog title" className="w-full" />
// </div>
// <div>
// <label className="mb-1 block text-sm font-medium text-gray-700">Content</label>
// <Textarea
// value={newBlogContent}
// onChange={(e) => setNewBlogContent(e.target.value)}
// placeholder="Enter blog content"
// className="min-h-[200px] w-full"
// />
// </div>
// <div>
// <label className="mb-1 block text-sm font-medium text-gray-700">Tags</label>
// <Input
// value={newBlogTags}
// onChange={(e) => setNewBlogTags(e.target.value)}
// placeholder="Enter tags (comma-separated)"
// className="w-full"
// />
// </div>
// </div>
// <div className="mt-4 space-x-2">
// <Button onClick={isCreating ? handleCreateBlog : handleUpdateBlog}>{isCreating ? "Create Post" : "Update Post"}</Button>
// <Button
// variant="secondary"
// onClick={() => {
// setIsCreating(false);
// setIsEditing(false);
// setCurrentBlog(null);
// resetForm();
// }}
// >
// Cancel
// </Button>
// </div>
// {error && <div className="mt-2 text-red-500">{error}</div>}
// </div>
// )}

<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{blogs.data && blogs.data.length > 0 ? (
blogs.data.map((blog: Blog) => (
<div key={blog.id} className="rounded-lg bg-white p-6 shadow-md">
<h2 className="mb-2 text-xl font-bold">{blog.title}</h2>
<p className="mb-4 text-gray-600">{blog.content.substring(0, 100)}...</p>
{/* {blog.tags && <p className="mb-2 text-sm text-gray-500">Tags: {blog.tags.join(", ")}</p>} */}
{isAuthenticated && <Button onClick={() => handleEditBlog(blog)}>Edit</Button>}
</div>
))
) : (
<p>No blogs found.</p>
)}
</div>
</div>
// <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
// {blogs.data && blogs.data.length > 0 ? (
// blogs.data.map((blog: Blog) => (
// <div key={blog.id} className="rounded-lg bg-white p-6 shadow-md">
// <h2 className="mb-2 text-xl font-bold">{blog.title}</h2>
// <p className="mb-4 text-gray-600">{blog.content.substring(0, 100)}...</p>
// {/* {blog.tags && <p className="mb-2 text-sm text-gray-500">Tags: {blog.tags.join(", ")}</p>} */}
// {isAuthenticated && <Button onClick={() => handleEditBlog(blog)}>Edit</Button>}
// </div>
// ))
// ) : (
// <p>No blogs found.</p>
// )}
// </div>
// </div>
);
},
});

0 comments on commit 5961a13

Please sign in to comment.