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