fix: detail and thumbnail categories

This commit is contained in:
Sabda Yagra 2026-02-10 13:10:40 +07:00
parent dd2344a59f
commit a0cb4cc9bf
3 changed files with 38 additions and 12 deletions

View File

@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { formatDateToIndonesian } from "@/utils/globals";
import { getArticleCategoryDetail } from "@/service/categories/categories";
import { getUserInfo } from "@/service/user";
type CategoryDetail = {
id: number;
@ -27,11 +28,22 @@ type CategoryDetail = {
updatedAt: string;
};
type CurrentUser = {
id: number;
username: string;
fullname?: string;
};
export default function CategoriesDetailForm() {
const { id } = useParams() as { id: string };
const router = useRouter();
const [detail, setDetail] = useState<CategoryDetail | null>(null);
const [currentUser, setCurrentUser] = useState<CurrentUser | null>(null);
useEffect(() => {
getUserInfo().then((res) => setCurrentUser(res.data.data));
}, []);
useEffect(() => {
async function init() {
if (id) {
@ -50,7 +62,7 @@ export default function CategoriesDetailForm() {
<form>
{detail ? (
<div className="flex flex-col lg:flex-row gap-10 border rounded-lg ">
{/* MAIN FORM */}
{/* MAIN FORM */}
<Card className="w-full lg:w-8/12 px-6 py-6 m-2">
<p className="text-lg font-semibold mb-3">Form Category Detail</p>
@ -77,7 +89,7 @@ export default function CategoriesDetailForm() {
</div>
{/* Thumbnail */}
<div className="space-y-2 py-3">
{/* <div className="space-y-2 py-3">
<Label>Thumbnail</Label>
<Card className="mt-2 w-fit p-2 border">
<img
@ -86,7 +98,7 @@ export default function CategoriesDetailForm() {
className="h-[200px] rounded"
/>
</Card>
</div>
</div> */}
{/* Tags */}
{/* <div className="space-y-2 py-3 ">
@ -112,10 +124,19 @@ export default function CategoriesDetailForm() {
<div>
<Label>Created By</Label>
<Input
readOnly
value={
currentUser && currentUser.id === detail.createdById
? currentUser.fullname || currentUser.username
: `User ID ${detail.createdById}`
}
/>
{/* <Input
type="text"
value={detail.createdByName || detail.createdById}
readOnly
/>
/> */}
</div>
{/* Status */}

View File

@ -58,13 +58,13 @@ const columns: ColumnDef<any>[] = [
<span className="normal-case">{row.getValue("userLevelGroup") || "-"}</span>
),
},
{
accessorKey: "statusId",
header: "Status ID",
cell: ({ row }) => (
<span>{row.getValue("statusId")}</span>
),
},
// {
// accessorKey: "statusId",
// header: "Status ID",
// cell: ({ row }) => (
// <span>{row.getValue("statusId")}</span>
// ),
// },
{
accessorKey: "createdAt",
header: "Tanggal Unggah",

View File

@ -3,3 +3,8 @@ import { httpGetInterceptor } from "./http-config/http-interceptor-service";
export function getUserInfo() {
return httpGetInterceptor("users/info");
}
export function getUserById(userId: number) {
return httpGetInterceptor(`users/${userId}`);
}