diff --git a/src/components/data-not-avaiable.tsx b/src/components/data-not-avaiable.tsx new file mode 100644 index 0000000..e80d611 --- /dev/null +++ b/src/components/data-not-avaiable.tsx @@ -0,0 +1,9 @@ +const DateNotAvailable = ({ text = " No data available to show" }) => { + return ( +
+ {text} +
+ ); +}; + +export default DateNotAvailable; diff --git a/src/components/editor/artical-info.tsx b/src/components/editor/artical-info.tsx new file mode 100644 index 0000000..f8d2c7d --- /dev/null +++ b/src/components/editor/artical-info.tsx @@ -0,0 +1,272 @@ +"use client"; + +import { Badge } from "@/components/ui/badge"; +import { Calendar, User, X } from "lucide-react"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { Button } from "@/components/ui/button"; +import type { ContentManagement } from "@/types"; +import { useAdminData } from "@/store/hooks/users/useAdminData"; + +interface ArticleInfoProps { + contentData: ContentManagement; + onContentDataChange: (updates: Partial) => void; +} + +export const ArticleInfo = ({ + contentData, + onContentDataChange, +}: ArticleInfoProps) => { + // Add keyword + const addKeyword = (keyword: string) => { + if (keyword.trim() && !contentData.keywords.includes(keyword.trim())) { + onContentDataChange({ + keywords: [...contentData.keywords, keyword.trim()], + }); + } + }; + + // Remove keyword + const removeKeyword = (keyword: string) => { + onContentDataChange({ + keywords: contentData.keywords.filter((k) => k !== keyword), + }); + }; + + // Handle Enter key for keywords + const handleKeywordKeyPress = (e: React.KeyboardEvent) => { + if (e.key === "Enter") { + e.preventDefault(); + const target = e.target as HTMLInputElement; + addKeyword(target.value); + target.value = ""; + } + }; + + const { adminInfo, error, loading } = useAdminData(); + + if (loading) return
Loading...
; + if (error) return
Error loading data
; + + return ( +
+
+ {/* Status Info */} +
+

Article Status

+ +
+ + {contentData.status || "Draft"} + + {contentData.category && ( + {contentData.category} + )} +
+ +
+
+ + {new Date().toLocaleDateString()} +
+
+ + + {adminInfo?.firstname} {adminInfo?.lastname} + +
+
+
+ + {/* Basic Info */} +
+

Basic Information

+ +
+
+ + onContentDataChange({ title: e.target.value })} + placeholder="Article title" + className="mt-1" + /> +
+ +
+ + + onContentDataChange({ subtitle: e.target.value }) + } + placeholder="Subtitle (optional)" + className="mt-1" + /> +
+ +
+ + { + const file = e.target.files?.[0]; + if (file) { + const url = URL.createObjectURL(file); + onContentDataChange({ coverimage: url }); + } + }} + className="mt-1" + /> + {contentData.coverimage && ( +
+ Cover + +
+ )} +
+
+
+ + {/* SEO */} +
+

SEO Settings

+ +
+
+ + + onContentDataChange({ metaTitle: e.target.value }) + } + placeholder="SEO title" + maxLength={60} + className="mt-1" + /> +
+ {(contentData.metaTitle || "").length}/60 +
+
+ +
+ +