fix: detail and thumbnail categories
This commit is contained in:
parent
dd2344a59f
commit
a0cb4cc9bf
|
|
@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { formatDateToIndonesian } from "@/utils/globals";
|
import { formatDateToIndonesian } from "@/utils/globals";
|
||||||
import { getArticleCategoryDetail } from "@/service/categories/categories";
|
import { getArticleCategoryDetail } from "@/service/categories/categories";
|
||||||
|
import { getUserInfo } from "@/service/user";
|
||||||
|
|
||||||
type CategoryDetail = {
|
type CategoryDetail = {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
@ -27,10 +28,21 @@ type CategoryDetail = {
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type CurrentUser = {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
fullname?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export default function CategoriesDetailForm() {
|
export default function CategoriesDetailForm() {
|
||||||
const { id } = useParams() as { id: string };
|
const { id } = useParams() as { id: string };
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [detail, setDetail] = useState<CategoryDetail | null>(null);
|
const [detail, setDetail] = useState<CategoryDetail | null>(null);
|
||||||
|
const [currentUser, setCurrentUser] = useState<CurrentUser | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getUserInfo().then((res) => setCurrentUser(res.data.data));
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function init() {
|
async function init() {
|
||||||
|
|
@ -77,7 +89,7 @@ export default function CategoriesDetailForm() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Thumbnail */}
|
{/* Thumbnail */}
|
||||||
<div className="space-y-2 py-3">
|
{/* <div className="space-y-2 py-3">
|
||||||
<Label>Thumbnail</Label>
|
<Label>Thumbnail</Label>
|
||||||
<Card className="mt-2 w-fit p-2 border">
|
<Card className="mt-2 w-fit p-2 border">
|
||||||
<img
|
<img
|
||||||
|
|
@ -86,7 +98,7 @@ export default function CategoriesDetailForm() {
|
||||||
className="h-[200px] rounded"
|
className="h-[200px] rounded"
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div> */}
|
||||||
|
|
||||||
{/* Tags */}
|
{/* Tags */}
|
||||||
{/* <div className="space-y-2 py-3 ">
|
{/* <div className="space-y-2 py-3 ">
|
||||||
|
|
@ -112,10 +124,19 @@ export default function CategoriesDetailForm() {
|
||||||
<div>
|
<div>
|
||||||
<Label>Created By</Label>
|
<Label>Created By</Label>
|
||||||
<Input
|
<Input
|
||||||
|
readOnly
|
||||||
|
value={
|
||||||
|
currentUser && currentUser.id === detail.createdById
|
||||||
|
? currentUser.fullname || currentUser.username
|
||||||
|
: `User ID ${detail.createdById}`
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* <Input
|
||||||
type="text"
|
type="text"
|
||||||
value={detail.createdByName || detail.createdById}
|
value={detail.createdByName || detail.createdById}
|
||||||
readOnly
|
readOnly
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Status */}
|
{/* Status */}
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,13 @@ const columns: ColumnDef<any>[] = [
|
||||||
<span className="normal-case">{row.getValue("userLevelGroup") || "-"}</span>
|
<span className="normal-case">{row.getValue("userLevelGroup") || "-"}</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
accessorKey: "statusId",
|
// accessorKey: "statusId",
|
||||||
header: "Status ID",
|
// header: "Status ID",
|
||||||
cell: ({ row }) => (
|
// cell: ({ row }) => (
|
||||||
<span>{row.getValue("statusId")}</span>
|
// <span>{row.getValue("statusId")}</span>
|
||||||
),
|
// ),
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
accessorKey: "createdAt",
|
accessorKey: "createdAt",
|
||||||
header: "Tanggal Unggah",
|
header: "Tanggal Unggah",
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,8 @@ import { httpGetInterceptor } from "./http-config/http-interceptor-service";
|
||||||
export function getUserInfo() {
|
export function getUserInfo() {
|
||||||
return httpGetInterceptor("users/info");
|
return httpGetInterceptor("users/info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getUserById(userId: number) {
|
||||||
|
return httpGetInterceptor(`users/${userId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue