update
This commit is contained in:
parent
389cd0a4f3
commit
c5f9d85366
|
|
@ -234,7 +234,7 @@ export default function DetailContent() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span className="text-blue-400 font-medium">
|
<span className="text-blue-400 font-medium">
|
||||||
{articleDetail?.createdByName}
|
{articleDetail?.customCreatorName || articleDetail?.createdByName}
|
||||||
</span>
|
</span>
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<span>
|
<span>
|
||||||
|
|
@ -384,7 +384,8 @@ export default function DetailContent() {
|
||||||
{/* Info Author */}
|
{/* Info Author */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="text-lg font-semibold text-gray-800">
|
<h3 className="text-lg font-semibold text-gray-800">
|
||||||
{articleDetail?.createdByName}
|
{articleDetail?.customCreatorName ||
|
||||||
|
articleDetail?.createdByName}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className="mt-2 flex items-center gap-4 flex-wrap">
|
<div className="mt-2 flex items-center gap-4 flex-wrap">
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,9 @@ const createArticleSchema = z.object({
|
||||||
title: z.string().min(2, {
|
title: z.string().min(2, {
|
||||||
message: "Judul harus diisi",
|
message: "Judul harus diisi",
|
||||||
}),
|
}),
|
||||||
|
customCreatorName: z.string().min(2, {
|
||||||
|
message: "Judul harus diisi",
|
||||||
|
}),
|
||||||
slug: z.string().min(2, {
|
slug: z.string().min(2, {
|
||||||
message: "Slug harus diisi",
|
message: "Slug harus diisi",
|
||||||
}),
|
}),
|
||||||
|
|
@ -94,6 +97,7 @@ const createArticleSchema = z.object({
|
||||||
tags: z.array(z.string()).nonempty({
|
tags: z.array(z.string()).nonempty({
|
||||||
message: "Minimal 1 tag",
|
message: "Minimal 1 tag",
|
||||||
}),
|
}),
|
||||||
|
source: z.enum(["internal", "external"]).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function CreateArticleForm() {
|
export default function CreateArticleForm() {
|
||||||
|
|
@ -225,6 +229,8 @@ export default function CreateArticleForm() {
|
||||||
const request = {
|
const request = {
|
||||||
id: diseData?.id,
|
id: diseData?.id,
|
||||||
title: values.title,
|
title: values.title,
|
||||||
|
customCreatorName: values.customCreatorName,
|
||||||
|
source: values.source,
|
||||||
articleBody: removeImgTags(values.description),
|
articleBody: removeImgTags(values.description),
|
||||||
metaDescription: diseData?.metaDescription,
|
metaDescription: diseData?.metaDescription,
|
||||||
metaTitle: diseData?.metaTitle,
|
metaTitle: diseData?.metaTitle,
|
||||||
|
|
@ -280,6 +286,8 @@ export default function CreateArticleForm() {
|
||||||
title: values.title,
|
title: values.title,
|
||||||
typeId: 1,
|
typeId: 1,
|
||||||
slug: values.slug,
|
slug: values.slug,
|
||||||
|
customCreatorName: values.customCreatorName,
|
||||||
|
source: values.source,
|
||||||
categoryIds: values.category.map((a) => a.id).join(","),
|
categoryIds: values.category.map((a) => a.id).join(","),
|
||||||
tags: values.tags.join(","),
|
tags: values.tags.join(","),
|
||||||
description: htmlToString(removeImgTags(values.description)),
|
description: htmlToString(removeImgTags(values.description)),
|
||||||
|
|
@ -524,13 +532,21 @@ export default function CreateArticleForm() {
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="single">Single Article</SelectItem>
|
<SelectItem value="single">Single Article</SelectItem>
|
||||||
<SelectItem value="rewrite">Content Rewrite</SelectItem>
|
{/* <SelectItem value="rewrite">Content Rewrite</SelectItem> */}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
{selectedWritingType === "single" ? (
|
{selectedWritingType === "single" ? (
|
||||||
<GenerateSingleArticleForm
|
<GenerateSingleArticleForm
|
||||||
content={(data) => {
|
content={(data) => {
|
||||||
setDiseData(data);
|
setDiseData(data);
|
||||||
|
// setValue("title", data?.title ?? "", {
|
||||||
|
// shouldValidate: true,
|
||||||
|
// shouldDirty: true,
|
||||||
|
// });
|
||||||
|
// setValue("slug", generateSlug(data?.title ?? ""), {
|
||||||
|
// shouldValidate: true,
|
||||||
|
// shouldDirty: true,
|
||||||
|
// });
|
||||||
setValue(
|
setValue(
|
||||||
"description",
|
"description",
|
||||||
data?.articleBody ? data?.articleBody : ""
|
data?.articleBody ? data?.articleBody : ""
|
||||||
|
|
@ -651,7 +667,38 @@ export default function CreateArticleForm() {
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<p className="text-sm">Kreator</p>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="customCreatorName"
|
||||||
|
render={({ field }) => (
|
||||||
|
<Input
|
||||||
|
id="customCreatorName"
|
||||||
|
type="text"
|
||||||
|
placeholder="Masukkan judul artikel"
|
||||||
|
className="w-full border rounded-lg dark:border-gray-400"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="mt-2">
|
||||||
|
<p className="text-sm">Tipe Kreator</p>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="source"
|
||||||
|
render={({ field }) => (
|
||||||
|
<Select onValueChange={field.onChange} value={field.value}>
|
||||||
|
<SelectTrigger className="w-full border rounded-lg text-sm dark:border-gray-400">
|
||||||
|
<SelectValue placeholder="Pilih tipe kreator" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="internal">Internal</SelectItem>
|
||||||
|
<SelectItem value="external">External</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<p className="text-sm mt-3">Kategori</p>
|
<p className="text-sm mt-3">Kategori</p>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,13 @@ import {
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
|
||||||
const ViewEditor = dynamic(
|
const ViewEditor = dynamic(
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -81,6 +88,9 @@ const createArticleSchema = z.object({
|
||||||
title: z.string().min(2, {
|
title: z.string().min(2, {
|
||||||
message: "Judul harus diisi",
|
message: "Judul harus diisi",
|
||||||
}),
|
}),
|
||||||
|
customCreatorName: z.string().min(2, {
|
||||||
|
message: "Judul harus diisi",
|
||||||
|
}),
|
||||||
slug: z.string().min(2, {
|
slug: z.string().min(2, {
|
||||||
message: "Slug harus diisi",
|
message: "Slug harus diisi",
|
||||||
}),
|
}),
|
||||||
|
|
@ -92,7 +102,8 @@ const createArticleSchema = z.object({
|
||||||
}),
|
}),
|
||||||
tags: z.array(z.string()).nonempty({
|
tags: z.array(z.string()).nonempty({
|
||||||
message: "Minimal 1 tag",
|
message: "Minimal 1 tag",
|
||||||
}), // Array berisi string
|
}),
|
||||||
|
source: z.enum(["internal", "external"]).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
interface DiseData {
|
interface DiseData {
|
||||||
|
|
@ -179,7 +190,9 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
||||||
const data = res.data?.data;
|
const data = res.data?.data;
|
||||||
setDetailData(data);
|
setDetailData(data);
|
||||||
setValue("title", data?.title);
|
setValue("title", data?.title);
|
||||||
|
setValue("customCreatorName", data?.customCreatorName);
|
||||||
setValue("slug", data?.slug);
|
setValue("slug", data?.slug);
|
||||||
|
setValue("source", data?.source);
|
||||||
setValue("description", data?.htmlDescription);
|
setValue("description", data?.htmlDescription);
|
||||||
setValue("tags", data?.tags ? data.tags.split(",") : []);
|
setValue("tags", data?.tags ? data.tags.split(",") : []);
|
||||||
setThumbnail(data?.thumbnailUrl);
|
setThumbnail(data?.thumbnailUrl);
|
||||||
|
|
@ -681,6 +694,7 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
className=" border-none rounded-full"
|
className=" border-none rounded-full"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
color="danger"
|
color="danger"
|
||||||
|
|
@ -782,6 +796,43 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<p className="text-sm">Kreator</p>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="customCreatorName"
|
||||||
|
render={({ field }) => (
|
||||||
|
<Input
|
||||||
|
id="customCreatorName"
|
||||||
|
type="text"
|
||||||
|
placeholder="Masukkan Kreator artikel"
|
||||||
|
readOnly={isDetail}
|
||||||
|
className="w-full border rounded-lg dark:border-gray-400"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="mt-2">
|
||||||
|
<p className="text-sm">Tipe Kreator</p>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="source"
|
||||||
|
render={({ field }) => (
|
||||||
|
<Select
|
||||||
|
onValueChange={field.onChange}
|
||||||
|
value={field.value}
|
||||||
|
disabled={isDetail}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full border rounded-lg text-sm dark:border-gray-400">
|
||||||
|
<SelectValue placeholder="Pilih tipe kreator" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="internal">Internal</SelectItem>
|
||||||
|
<SelectItem value="external">External</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<p className="text-sm mt-3">Kategori</p>
|
<p className="text-sm mt-3">Kategori</p>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
|
|
|
||||||
|
|
@ -76,16 +76,15 @@ interface DiseData {
|
||||||
export default function GenerateSingleArticleForm(props: {
|
export default function GenerateSingleArticleForm(props: {
|
||||||
content: (data: DiseData) => void;
|
content: (data: DiseData) => void;
|
||||||
}) {
|
}) {
|
||||||
const [selectedWritingSyle, setSelectedWritingStyle] =
|
const [selectedWritingSyle, setSelectedWritingStyle] = useState("");
|
||||||
useState("Informational");
|
const [selectedArticleSize, setSelectedArticleSize] = useState("");
|
||||||
const [selectedArticleSize, setSelectedArticleSize] = useState("News");
|
const [selectedLanguage, setSelectedLanguage] = useState("");
|
||||||
const [selectedLanguage, setSelectedLanguage] = useState("id");
|
|
||||||
const [mainKeyword, setMainKeyword] = useState("");
|
const [mainKeyword, setMainKeyword] = useState("");
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [additionalKeyword, setAdditionalKeyword] = useState("");
|
const [additionalKeyword, setAdditionalKeyword] = useState("");
|
||||||
const [articleIds, setArticleIds] = useState<number[]>([]);
|
const [articleIds, setArticleIds] = useState<number[]>([]);
|
||||||
const [selectedId, setSelectedId] = useState<number>();
|
const [selectedId, setSelectedId] = useState<number>();
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const generateAll = async (keyword: string | undefined) => {
|
const generateAll = async (keyword: string | undefined) => {
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
|
|
@ -271,11 +270,11 @@ export default function GenerateSingleArticleForm(props: {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="w-full border border-gray-300 dark:border-gray-400 rounded-lg text-black">
|
<SelectTrigger className="w-full border border-gray-300 dark:border-gray-400 rounded-lg text-black">
|
||||||
<SelectValue placeholder="Writing Style" />
|
<SelectValue placeholder="Article Size" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{articleSize.map((style) => (
|
{articleSize.map((style) => (
|
||||||
<SelectItem key={style.name} value={style.name}>
|
<SelectItem key={style.name} value={style.value}>
|
||||||
{style.name}
|
{style.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
|
|
@ -307,7 +306,7 @@ export default function GenerateSingleArticleForm(props: {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="w-full border border-gray-300 dark:border-gray-400 rounded-lg text-black">
|
<SelectTrigger className="w-full border border-gray-300 dark:border-gray-400 rounded-lg text-black">
|
||||||
<SelectValue placeholder="Bahasa" />
|
<SelectValue placeholder="Language" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="id">Indonesia</SelectItem>
|
<SelectItem value="id">Indonesia</SelectItem>
|
||||||
|
|
@ -319,6 +318,7 @@ export default function GenerateSingleArticleForm(props: {
|
||||||
<div className="flex flex-row gap-2 items-center">
|
<div className="flex flex-row gap-2 items-center">
|
||||||
<p className="text-sm">Main Keyword</p>
|
<p className="text-sm">Main Keyword</p>
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
variant="default"
|
variant="default"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => generateAll(mainKeyword)}
|
onClick={() => generateAll(mainKeyword)}
|
||||||
|
|
@ -350,6 +350,7 @@ export default function GenerateSingleArticleForm(props: {
|
||||||
<div className="flex flex-row gap-2 items-center mt-3">
|
<div className="flex flex-row gap-2 items-center mt-3">
|
||||||
<p className="text-sm">Title</p>
|
<p className="text-sm">Title</p>
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
variant="default"
|
variant="default"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => generateTitle(mainKeyword)}
|
onClick={() => generateTitle(mainKeyword)}
|
||||||
|
|
@ -373,6 +374,7 @@ export default function GenerateSingleArticleForm(props: {
|
||||||
<div className="flex flex-row gap-2 items-center mt-2">
|
<div className="flex flex-row gap-2 items-center mt-2">
|
||||||
<p className="text-sm">Additional Keyword</p>
|
<p className="text-sm">Additional Keyword</p>
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
className="text-sm"
|
className="text-sm"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => generateKeywords(mainKeyword)}
|
onClick={() => generateKeywords(mainKeyword)}
|
||||||
|
|
@ -417,6 +419,7 @@ export default function GenerateSingleArticleForm(props: {
|
||||||
<div className="flex flex-row gap-1 mt-2">
|
<div className="flex flex-row gap-1 mt-2">
|
||||||
{articleIds.map((id, index) => (
|
{articleIds.map((id, index) => (
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
key={id}
|
key={id}
|
||||||
onClick={() => setSelectedId(id)}
|
onClick={() => setSelectedId(id)}
|
||||||
disabled={isLoading && selectedId === id}
|
disabled={isLoading && selectedId === id}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ type Article = {
|
||||||
categoryName: string;
|
categoryName: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
createdByName: string;
|
createdByName: string;
|
||||||
|
customCreatorName: string;
|
||||||
thumbnailUrl: string;
|
thumbnailUrl: string;
|
||||||
categories: {
|
categories: {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -86,7 +87,7 @@ export default function BreakingNews() {
|
||||||
{item.title}
|
{item.title}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-gray-500 mt-1">
|
<p className="text-xs text-gray-500 mt-1">
|
||||||
By {item.createdByName} •{" "}
|
By {item?.customCreatorName || item?.createdByName} •{" "}
|
||||||
{new Date(item.createdAt).toLocaleDateString("id-ID", {
|
{new Date(item.createdAt).toLocaleDateString("id-ID", {
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ type Article = {
|
||||||
categoryName: string;
|
categoryName: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
createdByName: string;
|
createdByName: string;
|
||||||
|
customCreatorName: string;
|
||||||
thumbnailUrl: string;
|
thumbnailUrl: string;
|
||||||
categories: {
|
categories: {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ type Article = {
|
||||||
description: string;
|
description: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
createdByName: string;
|
createdByName: string;
|
||||||
|
customCreatorName: string;
|
||||||
thumbnailUrl: string;
|
thumbnailUrl: string;
|
||||||
categories: { title: string }[];
|
categories: { title: string }[];
|
||||||
};
|
};
|
||||||
|
|
@ -64,7 +65,7 @@ export default function HeaderNews() {
|
||||||
<h2 className="text-2xl font-bold mt-2">{articles[0]?.title}</h2>
|
<h2 className="text-2xl font-bold mt-2">{articles[0]?.title}</h2>
|
||||||
<p className="text-sm mt-1">
|
<p className="text-sm mt-1">
|
||||||
<span className="font-semibold">
|
<span className="font-semibold">
|
||||||
{articles[0]?.createdByName}
|
{articles[0]?.customCreatorName || articles[0]?.createdByName}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
•{" "}
|
•{" "}
|
||||||
{articles[0]?.createdAt &&
|
{articles[0]?.createdAt &&
|
||||||
|
|
@ -106,7 +107,7 @@ export default function HeaderNews() {
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-[10px]">
|
<p className="text-[10px]">
|
||||||
<span className="font-semibold">
|
<span className="font-semibold">
|
||||||
{item.createdByName}
|
{item?.customCreatorName || item.createdByName}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
•{" "}
|
•{" "}
|
||||||
{item.createdAt &&
|
{item.createdAt &&
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ type Article = {
|
||||||
title: string;
|
title: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
createdByName: string;
|
createdByName: string;
|
||||||
|
customCreatorName: string;
|
||||||
thumbnailUrl: string;
|
thumbnailUrl: string;
|
||||||
categories: { title: string }[];
|
categories: { title: string }[];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ export default function DashboardContainer() {
|
||||||
|
|
||||||
async function initState() {
|
async function initState() {
|
||||||
const req = {
|
const req = {
|
||||||
limit: "4",
|
limit: "5",
|
||||||
page: page,
|
page: page,
|
||||||
search: "",
|
search: "",
|
||||||
};
|
};
|
||||||
|
|
@ -207,11 +207,15 @@ export default function DashboardContainer() {
|
||||||
<p className="text-slate-600">{username}</p>
|
<p className="text-slate-600">{username}</p>
|
||||||
<div className="flex space-x-6 pt-2">
|
<div className="flex space-x-6 pt-2">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="text-2xl font-bold text-blue-600">{summary?.totalToday}</p>
|
<p className="text-2xl font-bold text-blue-600">
|
||||||
|
{summary?.totalToday}
|
||||||
|
</p>
|
||||||
<p className="text-sm text-slate-500">Today</p>
|
<p className="text-sm text-slate-500">Today</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="text-2xl font-bold text-purple-600">{summary?.totalThisWeek}</p>
|
<p className="text-2xl font-bold text-purple-600">
|
||||||
|
{summary?.totalThisWeek}
|
||||||
|
</p>
|
||||||
<p className="text-sm text-slate-500">This Week</p>
|
<p className="text-sm text-slate-500">This Week</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -234,7 +238,9 @@ export default function DashboardContainer() {
|
||||||
<DashboardSpeecIcon />
|
<DashboardSpeecIcon />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-3xl font-bold text-slate-800">{summary?.totalAll}</p>
|
<p className="text-3xl font-bold text-slate-800">
|
||||||
|
{summary?.totalAll}
|
||||||
|
</p>
|
||||||
<p className="text-sm text-slate-500">Total Posts</p>
|
<p className="text-sm text-slate-500">Total Posts</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -252,7 +258,9 @@ export default function DashboardContainer() {
|
||||||
<DashboardConnectIcon />
|
<DashboardConnectIcon />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-3xl font-bold text-slate-800">{summary?.totalViews}</p>
|
<p className="text-3xl font-bold text-slate-800">
|
||||||
|
{summary?.totalViews}
|
||||||
|
</p>
|
||||||
<p className="text-sm text-slate-500">Total Views</p>
|
<p className="text-sm text-slate-500">Total Views</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -270,7 +278,9 @@ export default function DashboardContainer() {
|
||||||
<DashboardShareIcon />
|
<DashboardShareIcon />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-3xl font-bold text-slate-800">{summary?.totalShares}</p>
|
<p className="text-3xl font-bold text-slate-800">
|
||||||
|
{summary?.totalShares}
|
||||||
|
</p>
|
||||||
<p className="text-sm text-slate-500">Total Shares</p>
|
<p className="text-sm text-slate-500">Total Shares</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -288,7 +298,9 @@ export default function DashboardContainer() {
|
||||||
<DashboardCommentIcon size={40} />
|
<DashboardCommentIcon size={40} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-3xl font-bold text-slate-800">{summary?.totalComments}</p>
|
<p className="text-3xl font-bold text-slate-800">
|
||||||
|
{summary?.totalComments}
|
||||||
|
</p>
|
||||||
<p className="text-sm text-slate-500">Total Comments</p>
|
<p className="text-sm text-slate-500">Total Comments</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -305,13 +317,20 @@ export default function DashboardContainer() {
|
||||||
transition={{ delay: 0.6 }}
|
transition={{ delay: 0.6 }}
|
||||||
>
|
>
|
||||||
<div className="flex justify-between items-center mb-6">
|
<div className="flex justify-between items-center mb-6">
|
||||||
<h3 className="text-lg font-semibold text-slate-800">Analytics Overview</h3>
|
<h3 className="text-lg font-semibold text-slate-800">
|
||||||
|
Analytics Overview
|
||||||
|
</h3>
|
||||||
<div className="flex space-x-4">
|
<div className="flex space-x-4">
|
||||||
{options.map((option) => (
|
{options.map((option) => (
|
||||||
<label key={option.value} className="flex items-center space-x-2">
|
<label
|
||||||
|
key={option.value}
|
||||||
|
className="flex items-center space-x-2"
|
||||||
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={analyticsView.includes(option.value)}
|
checked={analyticsView.includes(option.value)}
|
||||||
onCheckedChange={(checked) => handleChange(option.value, checked as boolean)}
|
onCheckedChange={(checked) =>
|
||||||
|
handleChange(option.value, checked as boolean)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<span className="text-sm text-slate-600">{option.label}</span>
|
<span className="text-sm text-slate-600">{option.label}</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -335,12 +354,14 @@ export default function DashboardContainer() {
|
||||||
transition={{ delay: 0.7 }}
|
transition={{ delay: 0.7 }}
|
||||||
>
|
>
|
||||||
<div className="flex justify-between items-center mb-6">
|
<div className="flex justify-between items-center mb-6">
|
||||||
<h3 className="text-lg font-semibold text-slate-800">Recent Articles</h3>
|
<h3 className="text-lg font-semibold text-slate-800">
|
||||||
<Link href="/admin/article/create">
|
Recent Articles
|
||||||
|
</h3>
|
||||||
|
{/* <Link href="/admin/article/create">
|
||||||
<Button className="bg-gradient-to-r from-blue-500 to-purple-500 hover:from-blue-600 hover:to-purple-600 text-white shadow-lg">
|
<Button className="bg-gradient-to-r from-blue-500 to-purple-500 hover:from-blue-600 hover:to-purple-600 text-white shadow-lg">
|
||||||
Create Article
|
Create Article
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4 max-h-96 overflow-y-auto scrollbar-thin">
|
<div className="space-y-4 max-h-96 overflow-y-auto scrollbar-thin">
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
} from "@/components/icons";
|
} from "@/components/icons";
|
||||||
import { close, error, loading, success, successToast } from "@/config/swal";
|
import { close, error, loading, success, successToast } from "@/config/swal";
|
||||||
import { Article } from "@/types/globals";
|
import { Article } from "@/types/globals";
|
||||||
import { convertDateFormat } from "@/utils/global";
|
import { convertDateFormat, formatDate } from "@/utils/global";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Key, useCallback, useEffect, useState } from "react";
|
import { Key, useCallback, useEffect, useState } from "react";
|
||||||
import Swal from "sweetalert2";
|
import Swal from "sweetalert2";
|
||||||
|
|
@ -54,7 +54,7 @@ const columns = [
|
||||||
{ name: "Banner", uid: "isBanner" },
|
{ name: "Banner", uid: "isBanner" },
|
||||||
{ name: "Kategori", uid: "category" },
|
{ name: "Kategori", uid: "category" },
|
||||||
{ name: "Tanggal Unggah", uid: "createdAt" },
|
{ name: "Tanggal Unggah", uid: "createdAt" },
|
||||||
{ name: "Kreator", uid: "createdByName" },
|
{ name: "Kreator", uid: "customCreatorName" },
|
||||||
{ name: "Status", uid: "isPublish" },
|
{ name: "Status", uid: "isPublish" },
|
||||||
{ name: "Aksi", uid: "actions" },
|
{ name: "Aksi", uid: "actions" },
|
||||||
];
|
];
|
||||||
|
|
@ -64,7 +64,7 @@ const columnsOtherRole = [
|
||||||
{ name: "Source", uid: "source" },
|
{ name: "Source", uid: "source" },
|
||||||
{ name: "Kategori", uid: "category" },
|
{ name: "Kategori", uid: "category" },
|
||||||
{ name: "Tanggal Unggah", uid: "createdAt" },
|
{ name: "Tanggal Unggah", uid: "createdAt" },
|
||||||
{ name: "Kreator", uid: "createdByName" },
|
{ name: "Kreator", uid: "customCreatorName" },
|
||||||
{ name: "Status", uid: "isPublish" },
|
{ name: "Status", uid: "isPublish" },
|
||||||
{ name: "Aksi", uid: "actions" },
|
{ name: "Aksi", uid: "actions" },
|
||||||
];
|
];
|
||||||
|
|
@ -86,6 +86,7 @@ export default function ArticleTable() {
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [categories, setCategories] = useState<any>([]);
|
const [categories, setCategories] = useState<any>([]);
|
||||||
const [selectedCategories, setSelectedCategories] = useState<any>("");
|
const [selectedCategories, setSelectedCategories] = useState<any>("");
|
||||||
|
const [selectedCategoryId, setSelectedCategoryId] = useState<any>("");
|
||||||
const [selectedSource, setSelectedSource] = useState<any>("");
|
const [selectedSource, setSelectedSource] = useState<any>("");
|
||||||
const [selectedStatus, setSelectedStatus] = useState<string>("");
|
const [selectedStatus, setSelectedStatus] = useState<string>("");
|
||||||
const [dateRange, setDateRange] = useState<any>({
|
const [dateRange, setDateRange] = useState<any>({
|
||||||
|
|
@ -111,7 +112,7 @@ export default function ArticleTable() {
|
||||||
page,
|
page,
|
||||||
showData,
|
showData,
|
||||||
search,
|
search,
|
||||||
selectedCategories,
|
selectedCategoryId,
|
||||||
selectedSource,
|
selectedSource,
|
||||||
dateRange,
|
dateRange,
|
||||||
selectedStatus,
|
selectedStatus,
|
||||||
|
|
@ -123,16 +124,12 @@ export default function ArticleTable() {
|
||||||
limit: showData,
|
limit: showData,
|
||||||
page: page,
|
page: page,
|
||||||
search: search,
|
search: search,
|
||||||
category: selectedCategories || "",
|
category: selectedCategoryId || "",
|
||||||
source: selectedSource || "",
|
source: selectedSource || "",
|
||||||
isPublish:
|
isPublish:
|
||||||
selectedStatus !== "" ? selectedStatus === "publish" : undefined,
|
selectedStatus !== "" ? selectedStatus === "publish" : undefined,
|
||||||
startDate: dateRange.startDate
|
startDate: formatDate(dateRange.startDate),
|
||||||
? new Date(dateRange.startDate).toISOString()
|
endDate: formatDate(dateRange.endDate),
|
||||||
: "",
|
|
||||||
endDate: dateRange.endDate
|
|
||||||
? new Date(dateRange.endDate).toISOString()
|
|
||||||
: "",
|
|
||||||
sort: "desc",
|
sort: "desc",
|
||||||
sortBy: "created_at",
|
sortBy: "created_at",
|
||||||
};
|
};
|
||||||
|
|
@ -221,6 +218,15 @@ export default function ArticleTable() {
|
||||||
const cellValue = article[columnKey as keyof any];
|
const cellValue = article[columnKey as keyof any];
|
||||||
|
|
||||||
switch (columnKey) {
|
switch (columnKey) {
|
||||||
|
case "customCreatorName":
|
||||||
|
return (
|
||||||
|
<p>
|
||||||
|
{article.customCreatorName &&
|
||||||
|
article.customCreatorName.trim() !== ""
|
||||||
|
? article.customCreatorName
|
||||||
|
: article.createdByName}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
case "isPublish":
|
case "isPublish":
|
||||||
return (
|
return (
|
||||||
// <Chip
|
// <Chip
|
||||||
|
|
@ -367,8 +373,8 @@ export default function ArticleTable() {
|
||||||
<div className="flex flex-col gap-1 w-full lg:w-[230px]">
|
<div className="flex flex-col gap-1 w-full lg:w-[230px]">
|
||||||
<p className="font-semibold text-sm">Kategori</p>
|
<p className="font-semibold text-sm">Kategori</p>
|
||||||
<Select
|
<Select
|
||||||
value={selectedCategories}
|
value={selectedCategoryId}
|
||||||
onValueChange={(value) => setSelectedCategories(value)}
|
onValueChange={(value) => setSelectedCategoryId(value)} // simpan ID
|
||||||
>
|
>
|
||||||
<SelectTrigger className="w-full text-sm border">
|
<SelectTrigger className="w-full text-sm border">
|
||||||
<SelectValue placeholder="Kategori" />
|
<SelectValue placeholder="Kategori" />
|
||||||
|
|
@ -377,7 +383,10 @@ export default function ArticleTable() {
|
||||||
{categories
|
{categories
|
||||||
?.filter((category: any) => category.title != null)
|
?.filter((category: any) => category.title != null)
|
||||||
.map((category: any) => (
|
.map((category: any) => (
|
||||||
<SelectItem key={category.id} value={category.title}>
|
<SelectItem
|
||||||
|
key={category.id}
|
||||||
|
value={category.id.toString()} // kirim ID, bukan title
|
||||||
|
>
|
||||||
{category.title}
|
{category.title}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
|
|
@ -394,8 +403,8 @@ export default function ArticleTable() {
|
||||||
<SelectValue placeholder="Pilih Source" />
|
<SelectValue placeholder="Pilih Source" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="INTERNAL">INTERNAL</SelectItem>
|
<SelectItem value="internal">INTERNAL</SelectItem>
|
||||||
<SelectItem value="EXTERNAL">EXTERNAL</SelectItem>
|
<SelectItem value="external">EXTERNAL</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,14 @@ export async function getListArticle(props: PaginationRequest) {
|
||||||
categorySlug,
|
categorySlug,
|
||||||
isBanner,
|
isBanner,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return await httpGet(
|
return await httpGet(
|
||||||
`/articles?limit=${limit}&page=${page}&isPublish=${
|
`/articles?limit=${limit}&page=${page}&isPublish=${
|
||||||
isPublish === undefined ? "" : isPublish
|
isPublish === undefined ? "" : isPublish
|
||||||
}&title=${search}&startDate=${startDate || ""}&endDate=${
|
}&title=${search}&startDate=${startDate || ""}&endDate=${
|
||||||
endDate || ""
|
endDate || ""
|
||||||
}&categoryId=${category || ""}&sortBy=${sortBy || "created_at"}&sort=${
|
}&categoryId=${category || ""}&sortBy=${sortBy || "created_at"}&sort=${
|
||||||
sort || "asc"
|
sort || "desc"
|
||||||
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}`,
|
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}`,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -164,3 +164,11 @@ export function convertDateFormatNoTime(date: Date): string {
|
||||||
const day = `${date.getDate()}`.padStart(2, "0");
|
const day = `${date.getDate()}`.padStart(2, "0");
|
||||||
return `${year}-${month}-${day}`;
|
return `${year}-${month}-${day}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatDate(date: Date | null) {
|
||||||
|
if (!date) return "";
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(date.getDate()).padStart(2, "0");
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue