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 { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
|
import { ApiPaths, apiUrl } from '../states/ApiState';
|
||||||
import { StatisticItem } from './items/DashboardItem';
|
import { StatisticItem } from './items/DashboardItem';
|
||||||
import { ErrorItem } from './items/ErrorItem';
|
import { ErrorItem } from './items/ErrorItem';
|
||||||
|
|
||||||
@ -15,13 +16,13 @@ export function DashboardItemProxy({
|
|||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
text: string;
|
text: string;
|
||||||
url: string;
|
url: ApiPaths;
|
||||||
params: any;
|
params: any;
|
||||||
autoupdate: boolean;
|
autoupdate: boolean;
|
||||||
}) {
|
}) {
|
||||||
function fetchData() {
|
function fetchData() {
|
||||||
return api
|
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);
|
.then((res) => res.data);
|
||||||
}
|
}
|
||||||
const { isLoading, error, data, isFetching } = useQuery({
|
const { isLoading, error, data, isFetching } = useQuery({
|
||||||
|
@ -1,125 +1,132 @@
|
|||||||
import { t } from '@lingui/macro';
|
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',
|
id: 'starred-parts',
|
||||||
text: t`Subscribed Parts`,
|
text: t`Subscribed Parts`,
|
||||||
icon: 'fa-bell',
|
icon: 'fa-bell',
|
||||||
url: apiUrl(ApiPaths.part_list),
|
url: ApiPaths.part_list,
|
||||||
params: { starred: true }
|
params: { starred: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'starred-categories',
|
id: 'starred-categories',
|
||||||
text: t`Subscribed Categories`,
|
text: t`Subscribed Categories`,
|
||||||
icon: 'fa-bell',
|
icon: 'fa-bell',
|
||||||
url: apiUrl(ApiPaths.category_list),
|
url: ApiPaths.category_list,
|
||||||
params: { starred: true }
|
params: { starred: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'latest-parts',
|
id: 'latest-parts',
|
||||||
text: t`Latest Parts`,
|
text: t`Latest Parts`,
|
||||||
icon: 'fa-newspaper',
|
icon: 'fa-newspaper',
|
||||||
url: apiUrl(ApiPaths.part_list),
|
url: ApiPaths.part_list,
|
||||||
params: { ordering: '-creation_date', limit: 10 }
|
params: { ordering: '-creation_date', limit: 10 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'bom-validation',
|
id: 'bom-validation',
|
||||||
text: t`BOM Waiting Validation`,
|
text: t`BOM Waiting Validation`,
|
||||||
icon: 'fa-times-circle',
|
icon: 'fa-times-circle',
|
||||||
url: apiUrl(ApiPaths.part_list),
|
url: ApiPaths.part_list,
|
||||||
params: { bom_valid: false }
|
params: { bom_valid: false }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'recently-updated-stock',
|
id: 'recently-updated-stock',
|
||||||
text: t`Recently Updated`,
|
text: t`Recently Updated`,
|
||||||
icon: 'fa-clock',
|
icon: 'fa-clock',
|
||||||
url: apiUrl(ApiPaths.stock_item_list),
|
url: ApiPaths.stock_item_list,
|
||||||
params: { part_detail: true, ordering: '-updated', limit: 10 }
|
params: { part_detail: true, ordering: '-updated', limit: 10 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'low-stock',
|
id: 'low-stock',
|
||||||
text: t`Low Stock`,
|
text: t`Low Stock`,
|
||||||
icon: 'fa-flag',
|
icon: 'fa-flag',
|
||||||
url: apiUrl(ApiPaths.part_list),
|
url: ApiPaths.part_list,
|
||||||
params: { low_stock: true }
|
params: { low_stock: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'depleted-stock',
|
id: 'depleted-stock',
|
||||||
text: t`Depleted Stock`,
|
text: t`Depleted Stock`,
|
||||||
icon: 'fa-times',
|
icon: 'fa-times',
|
||||||
url: apiUrl(ApiPaths.part_list),
|
url: ApiPaths.part_list,
|
||||||
params: { depleted_stock: true }
|
params: { depleted_stock: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'stock-to-build',
|
id: 'stock-to-build',
|
||||||
text: t`Required for Build Orders`,
|
text: t`Required for Build Orders`,
|
||||||
icon: 'fa-bullhorn',
|
icon: 'fa-bullhorn',
|
||||||
url: apiUrl(ApiPaths.part_list),
|
url: ApiPaths.part_list,
|
||||||
params: { stock_to_build: true }
|
params: { stock_to_build: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'expired-stock',
|
id: 'expired-stock',
|
||||||
text: t`Expired Stock`,
|
text: t`Expired Stock`,
|
||||||
icon: 'fa-calendar-times',
|
icon: 'fa-calendar-times',
|
||||||
url: apiUrl(ApiPaths.stock_item_list),
|
url: ApiPaths.stock_item_list,
|
||||||
params: { expired: true }
|
params: { expired: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'stale-stock',
|
id: 'stale-stock',
|
||||||
text: t`Stale Stock`,
|
text: t`Stale Stock`,
|
||||||
icon: 'fa-stopwatch',
|
icon: 'fa-stopwatch',
|
||||||
url: apiUrl(ApiPaths.stock_item_list),
|
url: ApiPaths.stock_item_list,
|
||||||
params: { stale: true, expired: true }
|
params: { stale: true, expired: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'build-pending',
|
id: 'build-pending',
|
||||||
text: t`Build Orders In Progress`,
|
text: t`Build Orders In Progress`,
|
||||||
icon: 'fa-cogs',
|
icon: 'fa-cogs',
|
||||||
url: apiUrl(ApiPaths.build_order_list),
|
url: ApiPaths.build_order_list,
|
||||||
params: { active: true }
|
params: { active: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'build-overdue',
|
id: 'build-overdue',
|
||||||
text: t`Overdue Build Orders`,
|
text: t`Overdue Build Orders`,
|
||||||
icon: 'fa-calendar-times',
|
icon: 'fa-calendar-times',
|
||||||
url: apiUrl(ApiPaths.build_order_list),
|
url: ApiPaths.build_order_list,
|
||||||
params: { overdue: true }
|
params: { overdue: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'po-outstanding',
|
id: 'po-outstanding',
|
||||||
text: t`Outstanding Purchase Orders`,
|
text: t`Outstanding Purchase Orders`,
|
||||||
icon: 'fa-sign-in-alt',
|
icon: 'fa-sign-in-alt',
|
||||||
url: apiUrl(ApiPaths.purchase_order_list),
|
url: ApiPaths.purchase_order_list,
|
||||||
params: { supplier_detail: true, outstanding: true }
|
params: { supplier_detail: true, outstanding: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'po-overdue',
|
id: 'po-overdue',
|
||||||
text: t`Overdue Purchase Orders`,
|
text: t`Overdue Purchase Orders`,
|
||||||
icon: 'fa-calendar-times',
|
icon: 'fa-calendar-times',
|
||||||
url: apiUrl(ApiPaths.purchase_order_list),
|
url: ApiPaths.purchase_order_list,
|
||||||
params: { supplier_detail: true, overdue: true }
|
params: { supplier_detail: true, overdue: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'so-outstanding',
|
id: 'so-outstanding',
|
||||||
text: t`Outstanding Sales Orders`,
|
text: t`Outstanding Sales Orders`,
|
||||||
icon: 'fa-sign-out-alt',
|
icon: 'fa-sign-out-alt',
|
||||||
url: apiUrl(ApiPaths.sales_order_list),
|
url: ApiPaths.sales_order_list,
|
||||||
params: { customer_detail: true, outstanding: true }
|
params: { customer_detail: true, outstanding: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'so-overdue',
|
id: 'so-overdue',
|
||||||
text: t`Overdue Sales Orders`,
|
text: t`Overdue Sales Orders`,
|
||||||
icon: 'fa-calendar-times',
|
icon: 'fa-calendar-times',
|
||||||
url: apiUrl(ApiPaths.sales_order_list),
|
url: ApiPaths.sales_order_list,
|
||||||
params: { customer_detail: true, overdue: true }
|
params: { customer_detail: true, overdue: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'news',
|
id: 'news',
|
||||||
text: t`Current News`,
|
text: t`Current News`,
|
||||||
icon: 'fa-newspaper',
|
icon: 'fa-newspaper',
|
||||||
url: 'news',
|
url: ApiPaths.news,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -39,6 +39,7 @@ export enum ApiPaths {
|
|||||||
notifications_list = 'api-notifications-list',
|
notifications_list = 'api-notifications-list',
|
||||||
|
|
||||||
barcode = 'api-barcode',
|
barcode = 'api-barcode',
|
||||||
|
news = 'news',
|
||||||
|
|
||||||
// Build order URLs
|
// Build order URLs
|
||||||
build_order_list = 'api-build-list',
|
build_order_list = 'api-build-list',
|
||||||
@ -113,6 +114,8 @@ export function apiEndpoint(path: ApiPaths): string {
|
|||||||
return 'notifications/';
|
return 'notifications/';
|
||||||
case ApiPaths.barcode:
|
case ApiPaths.barcode:
|
||||||
return 'barcode/';
|
return 'barcode/';
|
||||||
|
case ApiPaths.news:
|
||||||
|
return 'news/';
|
||||||
case ApiPaths.build_order_list:
|
case ApiPaths.build_order_list:
|
||||||
return 'build/';
|
return 'build/';
|
||||||
case ApiPaths.build_order_attachment_list:
|
case ApiPaths.build_order_attachment_list:
|
||||||
|
Loading…
Reference in New Issue
Block a user