mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix news dashboard (#5741)
* Fixes wrong news url * Typed dashboard items * Removed double trailing slashes
This commit is contained in:
parent
eb79bd1743
commit
fda909ac59
@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { api } from '../App';
|
||||
import { ApiPaths, apiUrl } from '../states/ApiState';
|
||||
import { StatisticItem } from './items/DashboardItem';
|
||||
import { ErrorItem } from './items/ErrorItem';
|
||||
|
||||
@ -15,13 +16,13 @@ export function DashboardItemProxy({
|
||||
}: {
|
||||
id: string;
|
||||
text: string;
|
||||
url: string;
|
||||
url: ApiPaths;
|
||||
params: any;
|
||||
autoupdate: boolean;
|
||||
}) {
|
||||
function fetchData() {
|
||||
return api
|
||||
.get(`${url}/?search=&offset=0&limit=25`, { params: params })
|
||||
.get(`${apiUrl(url)}?search=&offset=0&limit=25`, { params: params })
|
||||
.then((res) => res.data);
|
||||
}
|
||||
const { isLoading, error, data, isFetching } = useQuery({
|
||||
|
@ -1,125 +1,132 @@
|
||||
import { t } from '@lingui/macro';
|
||||
|
||||
import { ApiPaths, apiUrl } from '../states/ApiState';
|
||||
import { ApiPaths } from '../states/ApiState';
|
||||
|
||||
export const dashboardItems = [
|
||||
interface DashboardItems {
|
||||
id: string;
|
||||
text: string;
|
||||
icon: string;
|
||||
url: ApiPaths;
|
||||
params: any;
|
||||
}
|
||||
export const dashboardItems: DashboardItems[] = [
|
||||
{
|
||||
id: 'starred-parts',
|
||||
text: t`Subscribed Parts`,
|
||||
icon: 'fa-bell',
|
||||
url: apiUrl(ApiPaths.part_list),
|
||||
url: ApiPaths.part_list,
|
||||
params: { starred: true }
|
||||
},
|
||||
{
|
||||
id: 'starred-categories',
|
||||
text: t`Subscribed Categories`,
|
||||
icon: 'fa-bell',
|
||||
url: apiUrl(ApiPaths.category_list),
|
||||
url: ApiPaths.category_list,
|
||||
params: { starred: true }
|
||||
},
|
||||
{
|
||||
id: 'latest-parts',
|
||||
text: t`Latest Parts`,
|
||||
icon: 'fa-newspaper',
|
||||
url: apiUrl(ApiPaths.part_list),
|
||||
url: ApiPaths.part_list,
|
||||
params: { ordering: '-creation_date', limit: 10 }
|
||||
},
|
||||
{
|
||||
id: 'bom-validation',
|
||||
text: t`BOM Waiting Validation`,
|
||||
icon: 'fa-times-circle',
|
||||
url: apiUrl(ApiPaths.part_list),
|
||||
url: ApiPaths.part_list,
|
||||
params: { bom_valid: false }
|
||||
},
|
||||
{
|
||||
id: 'recently-updated-stock',
|
||||
text: t`Recently Updated`,
|
||||
icon: 'fa-clock',
|
||||
url: apiUrl(ApiPaths.stock_item_list),
|
||||
url: ApiPaths.stock_item_list,
|
||||
params: { part_detail: true, ordering: '-updated', limit: 10 }
|
||||
},
|
||||
{
|
||||
id: 'low-stock',
|
||||
text: t`Low Stock`,
|
||||
icon: 'fa-flag',
|
||||
url: apiUrl(ApiPaths.part_list),
|
||||
url: ApiPaths.part_list,
|
||||
params: { low_stock: true }
|
||||
},
|
||||
{
|
||||
id: 'depleted-stock',
|
||||
text: t`Depleted Stock`,
|
||||
icon: 'fa-times',
|
||||
url: apiUrl(ApiPaths.part_list),
|
||||
url: ApiPaths.part_list,
|
||||
params: { depleted_stock: true }
|
||||
},
|
||||
{
|
||||
id: 'stock-to-build',
|
||||
text: t`Required for Build Orders`,
|
||||
icon: 'fa-bullhorn',
|
||||
url: apiUrl(ApiPaths.part_list),
|
||||
url: ApiPaths.part_list,
|
||||
params: { stock_to_build: true }
|
||||
},
|
||||
{
|
||||
id: 'expired-stock',
|
||||
text: t`Expired Stock`,
|
||||
icon: 'fa-calendar-times',
|
||||
url: apiUrl(ApiPaths.stock_item_list),
|
||||
url: ApiPaths.stock_item_list,
|
||||
params: { expired: true }
|
||||
},
|
||||
{
|
||||
id: 'stale-stock',
|
||||
text: t`Stale Stock`,
|
||||
icon: 'fa-stopwatch',
|
||||
url: apiUrl(ApiPaths.stock_item_list),
|
||||
url: ApiPaths.stock_item_list,
|
||||
params: { stale: true, expired: true }
|
||||
},
|
||||
{
|
||||
id: 'build-pending',
|
||||
text: t`Build Orders In Progress`,
|
||||
icon: 'fa-cogs',
|
||||
url: apiUrl(ApiPaths.build_order_list),
|
||||
url: ApiPaths.build_order_list,
|
||||
params: { active: true }
|
||||
},
|
||||
{
|
||||
id: 'build-overdue',
|
||||
text: t`Overdue Build Orders`,
|
||||
icon: 'fa-calendar-times',
|
||||
url: apiUrl(ApiPaths.build_order_list),
|
||||
url: ApiPaths.build_order_list,
|
||||
params: { overdue: true }
|
||||
},
|
||||
{
|
||||
id: 'po-outstanding',
|
||||
text: t`Outstanding Purchase Orders`,
|
||||
icon: 'fa-sign-in-alt',
|
||||
url: apiUrl(ApiPaths.purchase_order_list),
|
||||
url: ApiPaths.purchase_order_list,
|
||||
params: { supplier_detail: true, outstanding: true }
|
||||
},
|
||||
{
|
||||
id: 'po-overdue',
|
||||
text: t`Overdue Purchase Orders`,
|
||||
icon: 'fa-calendar-times',
|
||||
url: apiUrl(ApiPaths.purchase_order_list),
|
||||
url: ApiPaths.purchase_order_list,
|
||||
params: { supplier_detail: true, overdue: true }
|
||||
},
|
||||
{
|
||||
id: 'so-outstanding',
|
||||
text: t`Outstanding Sales Orders`,
|
||||
icon: 'fa-sign-out-alt',
|
||||
url: apiUrl(ApiPaths.sales_order_list),
|
||||
url: ApiPaths.sales_order_list,
|
||||
params: { customer_detail: true, outstanding: true }
|
||||
},
|
||||
{
|
||||
id: 'so-overdue',
|
||||
text: t`Overdue Sales Orders`,
|
||||
icon: 'fa-calendar-times',
|
||||
url: apiUrl(ApiPaths.sales_order_list),
|
||||
url: ApiPaths.sales_order_list,
|
||||
params: { customer_detail: true, overdue: true }
|
||||
},
|
||||
{
|
||||
id: 'news',
|
||||
text: t`Current News`,
|
||||
icon: 'fa-newspaper',
|
||||
url: 'news',
|
||||
url: ApiPaths.news,
|
||||
params: {}
|
||||
}
|
||||
];
|
||||
|
@ -39,6 +39,7 @@ export enum ApiPaths {
|
||||
notifications_list = 'api-notifications-list',
|
||||
|
||||
barcode = 'api-barcode',
|
||||
news = 'news',
|
||||
|
||||
// Build order URLs
|
||||
build_order_list = 'api-build-list',
|
||||
@ -113,6 +114,8 @@ export function apiEndpoint(path: ApiPaths): string {
|
||||
return 'notifications/';
|
||||
case ApiPaths.barcode:
|
||||
return 'barcode/';
|
||||
case ApiPaths.news:
|
||||
return 'news/';
|
||||
case ApiPaths.build_order_list:
|
||||
return 'build/';
|
||||
case ApiPaths.build_order_attachment_list:
|
||||
|
Loading…
Reference in New Issue
Block a user