fix: table workflow and landing page
This commit is contained in:
parent
155baef80b
commit
d59857b559
|
|
@ -86,7 +86,7 @@ function TenantSettingsContentTable() {
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const [comprehensiveWorkflowRes, userLevelsRes] = await Promise.all([
|
||||
getApprovalWorkflowComprehensiveDetails(4),
|
||||
getApprovalWorkflowComprehensiveDetails(),
|
||||
getUserLevels(),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,16 @@ export default function Header() {
|
|||
const fetchData = async () => {
|
||||
try {
|
||||
// Use new Articles API
|
||||
const response = await listArticles(1, 5, undefined, undefined, undefined, "createdAt");
|
||||
const response = await listArticles(
|
||||
1,
|
||||
5,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
"createdAt"
|
||||
);
|
||||
console.log("Articles API response:", response);
|
||||
|
||||
|
||||
if (response?.error) {
|
||||
console.error("Articles API failed, falling back to old API");
|
||||
// Fallback to old API
|
||||
|
|
@ -44,19 +51,31 @@ export default function Header() {
|
|||
// Handle new API response structure
|
||||
const articlesData = response?.data?.data || [];
|
||||
console.log("Articles data:", articlesData);
|
||||
|
||||
|
||||
// Transform articles data to match old structure for backward compatibility
|
||||
const transformedData = articlesData.map((article: any) => ({
|
||||
id: article.id,
|
||||
title: article.title,
|
||||
categoryName: article.categoryName || (article.categories && article.categories[0]?.title) || "",
|
||||
categoryName:
|
||||
article.categoryName ||
|
||||
(article.categories && article.categories[0]?.title) ||
|
||||
"",
|
||||
createdAt: article.createdAt,
|
||||
smallThumbnailLink: article.thumbnailUrl,
|
||||
fileTypeId: article.typeId,
|
||||
label: article.typeId === 1 ? "Image" : article.typeId === 2 ? "Video" : article.typeId === 3 ? "Text" : article.typeId === 4 ? "Audio" : "",
|
||||
...article
|
||||
label:
|
||||
article.typeId === 1
|
||||
? "Image"
|
||||
: article.typeId === 2
|
||||
? "Video"
|
||||
: article.typeId === 3
|
||||
? "Text"
|
||||
: article.typeId === 4
|
||||
? "Audio"
|
||||
: "",
|
||||
...article,
|
||||
}));
|
||||
|
||||
|
||||
setData(transformedData);
|
||||
} catch (error) {
|
||||
console.error("Gagal memuat data:", error);
|
||||
|
|
@ -150,7 +169,10 @@ function Card({ item, isBig = false }: { item: any; isBig?: boolean }) {
|
|||
<span className="bg-emerald-600 text-white px-2 py-0.5 rounded">
|
||||
{item.categoryName}
|
||||
</span>
|
||||
<span className="text-orange-600">{item.label}</span>
|
||||
<span className="text-orange-600">
|
||||
{" "}
|
||||
{item.categories?.map((cat: any) => cat.title).join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{new Date(item.createdAt)
|
||||
|
|
|
|||
|
|
@ -300,16 +300,16 @@ export async function deleteApprovalWorkflow(id: number) {
|
|||
return httpDeleteInterceptor(url);
|
||||
}
|
||||
|
||||
// export async function getApprovalWorkflowComprehensiveDetails() {
|
||||
// const url = `approval-workflows/comprehensive-details`;
|
||||
// return httpGetInterceptor(url);
|
||||
// }
|
||||
export async function getApprovalWorkflowComprehensiveDetails(
|
||||
clientId?: string | number
|
||||
) {
|
||||
const url = clientId
|
||||
? `approval-workflows/comprehensive-details/${clientId}`
|
||||
: `approval-workflows/comprehensive-details`;
|
||||
|
||||
export async function getApprovalWorkflowComprehensiveDetails() {
|
||||
const url = `approval-workflows/comprehensive-details`;
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
// export async function getApprovalWorkflowComprehensiveDetails(
|
||||
// clientId?: string | number
|
||||
// ) {
|
||||
// const url = clientId
|
||||
// ? `approval-workflows/comprehensive-details/${clientId}`
|
||||
// : `approval-workflows/comprehensive-details`;
|
||||
|
||||
// return httpGetInterceptor(url);
|
||||
// }
|
||||
|
|
|
|||
Loading…
Reference in New Issue