mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
[PUI] API Endpoint refactor (#6358)
* Cleanup SupplierPartTable * Show PurchaseOrder table on SupplierPart page * Perform edit actions as PATCH requests * Implement ManufacturerPartParameter table * Fix link * supplier part link fix * Add new ApiEndpoints enumeration * Refactor calls to ApiState * Revert previous change * remove unused imports
This commit is contained in:
parent
b42f3de357
commit
282ecebc39
@ -3,7 +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 } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../states/ApiState';
|
import { apiUrl } from '../states/ApiState';
|
||||||
import { StatisticItem } from './items/DashboardItem';
|
import { StatisticItem } from './items/DashboardItem';
|
||||||
import { ErrorItem } from './items/ErrorItem';
|
import { ErrorItem } from './items/ErrorItem';
|
||||||
@ -17,7 +17,7 @@ export function DashboardItemProxy({
|
|||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
text: string;
|
text: string;
|
||||||
url: ApiPaths;
|
url: ApiEndpoints;
|
||||||
params: any;
|
params: any;
|
||||||
autoupdate: boolean;
|
autoupdate: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
} from 'react-hook-form';
|
} from 'react-hook-form';
|
||||||
|
|
||||||
import { api, queryClient } from '../../App';
|
import { api, queryClient } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import {
|
import {
|
||||||
NestedDict,
|
NestedDict,
|
||||||
constructField,
|
constructField,
|
||||||
@ -60,7 +60,7 @@ export interface ApiFormAction {
|
|||||||
* @param onFormError : A callback function to call when the form is submitted with errors.
|
* @param onFormError : A callback function to call when the form is submitted with errors.
|
||||||
*/
|
*/
|
||||||
export interface ApiFormProps {
|
export interface ApiFormProps {
|
||||||
url: ApiPaths | string;
|
url: ApiEndpoints | string;
|
||||||
pk?: number | string | undefined;
|
pk?: number | string | undefined;
|
||||||
pathParams?: PathParams;
|
pathParams?: PathParams;
|
||||||
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||||
|
@ -17,9 +17,9 @@ import { useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { doClassicLogin, doSimpleLogin } from '../../functions/auth';
|
import { doClassicLogin, doSimpleLogin } from '../../functions/auth';
|
||||||
import { apiUrl, useServerApiState } from '../../states/ApiState';
|
import { useServerApiState } from '../../states/ApiState';
|
||||||
|
|
||||||
export function AuthenticationForm() {
|
export function AuthenticationForm() {
|
||||||
const classicForm = useForm({
|
const classicForm = useForm({
|
||||||
@ -165,7 +165,7 @@ export function RegistrationForm() {
|
|||||||
function handleRegistration() {
|
function handleRegistration() {
|
||||||
setIsRegistering(true);
|
setIsRegistering(true);
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.user_register), registrationForm.values, {
|
.post(ApiEndpoints.user_register, registrationForm.values, {
|
||||||
headers: { Authorization: '' }
|
headers: { Authorization: '' }
|
||||||
})
|
})
|
||||||
.then((ret) => {
|
.then((ret) => {
|
||||||
|
@ -15,8 +15,8 @@ import { ContextModalProps } from '@mantine/modals';
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { apiUrl, useServerApiState } from '../../states/ApiState';
|
import { useServerApiState } from '../../states/ApiState';
|
||||||
import { useLocalState } from '../../states/LocalState';
|
import { useLocalState } from '../../states/LocalState';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
import { CopyButton } from '../items/CopyButton';
|
import { CopyButton } from '../items/CopyButton';
|
||||||
@ -47,7 +47,7 @@ export function AboutInvenTreeModal({
|
|||||||
|
|
||||||
const { isLoading, data } = useQuery({
|
const { isLoading, data } = useQuery({
|
||||||
queryKey: ['version'],
|
queryKey: ['version'],
|
||||||
queryFn: () => api.get(apiUrl(ApiPaths.version)).then((res) => res.data)
|
queryFn: () => api.get(ApiEndpoints.version).then((res) => res.data)
|
||||||
});
|
});
|
||||||
|
|
||||||
function fillTable(
|
function fillTable(
|
||||||
|
@ -23,8 +23,7 @@ import { Html5QrcodeResult } from 'html5-qrcode/core';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
|
||||||
|
|
||||||
export function QrCodeModal({
|
export function QrCodeModal({
|
||||||
context,
|
context,
|
||||||
@ -66,7 +65,7 @@ export function QrCodeModal({
|
|||||||
|
|
||||||
handlers.append(decodedText);
|
handlers.append(decodedText);
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.barcode), { barcode: decodedText })
|
.post(ApiEndpoints.barcode, { barcode: decodedText })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: response.data?.success || t`Unknown response`,
|
title: response.data?.success || t`Unknown response`,
|
||||||
|
@ -7,9 +7,8 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { navTabs as mainNavTabs } from '../../defaults/links';
|
import { navTabs as mainNavTabs } from '../../defaults/links';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { InvenTreeStyle } from '../../globalStyle';
|
import { InvenTreeStyle } from '../../globalStyle';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
|
||||||
import { ScanButton } from '../items/ScanButton';
|
import { ScanButton } from '../items/ScanButton';
|
||||||
import { MainMenu } from './MainMenu';
|
import { MainMenu } from './MainMenu';
|
||||||
import { NavHoverMenu } from './NavHoverMenu';
|
import { NavHoverMenu } from './NavHoverMenu';
|
||||||
@ -38,7 +37,7 @@ export function Header() {
|
|||||||
queryKey: ['notification-count'],
|
queryKey: ['notification-count'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return api
|
return api
|
||||||
.get(apiUrl(ApiPaths.notifications_list), {
|
.get(ApiEndpoints.notifications_list, {
|
||||||
params: {
|
params: {
|
||||||
read: false,
|
read: false,
|
||||||
limit: 1
|
limit: 1
|
||||||
|
@ -15,7 +15,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
import { StylishText } from '../items/StylishText';
|
import { StylishText } from '../items/StylishText';
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export function NotificationDrawer({
|
|||||||
queryKey: ['notifications', opened],
|
queryKey: ['notifications', opened],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api
|
api
|
||||||
.get(apiUrl(ApiPaths.notifications_list), {
|
.get(ApiEndpoints.notifications_list, {
|
||||||
params: {
|
params: {
|
||||||
read: false,
|
read: false,
|
||||||
limit: 10
|
limit: 10
|
||||||
@ -115,7 +115,10 @@ export function NotificationDrawer({
|
|||||||
color="gray"
|
color="gray"
|
||||||
variant="hover"
|
variant="hover"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
let url = apiUrl(ApiPaths.notifications_list, notification.pk);
|
let url = apiUrl(
|
||||||
|
ApiEndpoints.notifications_list,
|
||||||
|
notification.pk
|
||||||
|
);
|
||||||
api
|
api
|
||||||
.patch(url, {
|
.patch(url, {
|
||||||
read: true
|
read: true
|
||||||
|
@ -6,8 +6,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
|
||||||
import { StylishText } from '../items/StylishText';
|
import { StylishText } from '../items/StylishText';
|
||||||
|
|
||||||
export function PartCategoryTree({
|
export function PartCategoryTree({
|
||||||
@ -26,7 +25,7 @@ export function PartCategoryTree({
|
|||||||
queryKey: ['part_category_tree', opened],
|
queryKey: ['part_category_tree', opened],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api
|
api
|
||||||
.get(apiUrl(ApiPaths.category_tree), {})
|
.get(ApiEndpoints.category_tree, {})
|
||||||
.then((response) =>
|
.then((response) =>
|
||||||
response.data.map((category: any) => {
|
response.data.map((category: any) => {
|
||||||
return {
|
return {
|
||||||
|
@ -30,10 +30,9 @@ import { useEffect, useMemo, useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../enums/ModelType';
|
import { ModelType } from '../../enums/ModelType';
|
||||||
import { UserRoles } from '../../enums/Roles';
|
import { UserRoles } from '../../enums/Roles';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
|
||||||
import { useUserSettingsState } from '../../states/SettingsState';
|
import { useUserSettingsState } from '../../states/SettingsState';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
import { RenderInstance } from '../render/Instance';
|
import { RenderInstance } from '../render/Instance';
|
||||||
@ -258,7 +257,7 @@ export function SearchDrawer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return api
|
return api
|
||||||
.post(apiUrl(ApiPaths.api_search), params)
|
.post(ApiEndpoints.api_search, params)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
return response.data;
|
return response.data;
|
||||||
})
|
})
|
||||||
|
@ -6,8 +6,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
|
||||||
import { StylishText } from '../items/StylishText';
|
import { StylishText } from '../items/StylishText';
|
||||||
|
|
||||||
export function StockLocationTree({
|
export function StockLocationTree({
|
||||||
@ -26,7 +25,7 @@ export function StockLocationTree({
|
|||||||
queryKey: ['stock_location_tree', opened],
|
queryKey: ['stock_location_tree', opened],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api
|
api
|
||||||
.get(apiUrl(ApiPaths.stock_location_tree), {})
|
.get(ApiEndpoints.stock_location_tree, {})
|
||||||
.then((response) =>
|
.then((response) =>
|
||||||
response.data.map((location: any) => {
|
response.data.map((location: any) => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../enums/ModelType';
|
import { ModelType } from '../../enums/ModelType';
|
||||||
|
|
||||||
interface ModelInformationInterface {
|
interface ModelInformationInterface {
|
||||||
@ -8,7 +8,7 @@ interface ModelInformationInterface {
|
|||||||
label_multiple: string;
|
label_multiple: string;
|
||||||
url_overview?: string;
|
url_overview?: string;
|
||||||
url_detail?: string;
|
url_detail?: string;
|
||||||
api_endpoint?: ApiPaths;
|
api_endpoint?: ApiEndpoints;
|
||||||
cui_detail?: string;
|
cui_detail?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,14 +23,14 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/part',
|
url_overview: '/part',
|
||||||
url_detail: '/part/:pk/',
|
url_detail: '/part/:pk/',
|
||||||
cui_detail: '/part/:pk/',
|
cui_detail: '/part/:pk/',
|
||||||
api_endpoint: ApiPaths.part_list
|
api_endpoint: ApiEndpoints.part_list
|
||||||
},
|
},
|
||||||
partparametertemplate: {
|
partparametertemplate: {
|
||||||
label: t`Part Parameter Template`,
|
label: t`Part Parameter Template`,
|
||||||
label_multiple: t`Part Parameter Templates`,
|
label_multiple: t`Part Parameter Templates`,
|
||||||
url_overview: '/partparametertemplate',
|
url_overview: '/partparametertemplate',
|
||||||
url_detail: '/partparametertemplate/:pk/',
|
url_detail: '/partparametertemplate/:pk/',
|
||||||
api_endpoint: ApiPaths.part_parameter_template_list
|
api_endpoint: ApiEndpoints.part_parameter_template_list
|
||||||
},
|
},
|
||||||
supplierpart: {
|
supplierpart: {
|
||||||
label: t`Supplier Part`,
|
label: t`Supplier Part`,
|
||||||
@ -38,7 +38,7 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/supplierpart',
|
url_overview: '/supplierpart',
|
||||||
url_detail: '/purchasing/supplier-part/:pk/',
|
url_detail: '/purchasing/supplier-part/:pk/',
|
||||||
cui_detail: '/supplier-part/:pk/',
|
cui_detail: '/supplier-part/:pk/',
|
||||||
api_endpoint: ApiPaths.supplier_part_list
|
api_endpoint: ApiEndpoints.supplier_part_list
|
||||||
},
|
},
|
||||||
manufacturerpart: {
|
manufacturerpart: {
|
||||||
label: t`Manufacturer Part`,
|
label: t`Manufacturer Part`,
|
||||||
@ -46,15 +46,15 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/manufacturerpart',
|
url_overview: '/manufacturerpart',
|
||||||
url_detail: '/purchasing/manufacturer-part/:pk/',
|
url_detail: '/purchasing/manufacturer-part/:pk/',
|
||||||
cui_detail: '/manufacturer-part/:pk/',
|
cui_detail: '/manufacturer-part/:pk/',
|
||||||
api_endpoint: ApiPaths.manufacturer_part_list
|
api_endpoint: ApiEndpoints.manufacturer_part_list
|
||||||
},
|
},
|
||||||
partcategory: {
|
partcategory: {
|
||||||
label: t`Part Category`,
|
label: t`Part Category`,
|
||||||
label_multiple: t`Part Categories`,
|
label_multiple: t`Part Categories`,
|
||||||
url_overview: '/partcategory',
|
url_overview: '/part/category',
|
||||||
url_detail: '/partcategory/:pk/',
|
url_detail: '/part/category/:pk/',
|
||||||
cui_detail: '/part/category/:pk/',
|
cui_detail: '/part/category/:pk/',
|
||||||
api_endpoint: ApiPaths.category_list
|
api_endpoint: ApiEndpoints.category_list
|
||||||
},
|
},
|
||||||
stockitem: {
|
stockitem: {
|
||||||
label: t`Stock Item`,
|
label: t`Stock Item`,
|
||||||
@ -62,7 +62,7 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/stock/item',
|
url_overview: '/stock/item',
|
||||||
url_detail: '/stock/item/:pk/',
|
url_detail: '/stock/item/:pk/',
|
||||||
cui_detail: '/stock/item/:pk/',
|
cui_detail: '/stock/item/:pk/',
|
||||||
api_endpoint: ApiPaths.stock_item_list
|
api_endpoint: ApiEndpoints.stock_item_list
|
||||||
},
|
},
|
||||||
stocklocation: {
|
stocklocation: {
|
||||||
label: t`Stock Location`,
|
label: t`Stock Location`,
|
||||||
@ -70,12 +70,12 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/stock/location',
|
url_overview: '/stock/location',
|
||||||
url_detail: '/stock/location/:pk/',
|
url_detail: '/stock/location/:pk/',
|
||||||
cui_detail: '/stock/location/:pk/',
|
cui_detail: '/stock/location/:pk/',
|
||||||
api_endpoint: ApiPaths.stock_location_list
|
api_endpoint: ApiEndpoints.stock_location_list
|
||||||
},
|
},
|
||||||
stockhistory: {
|
stockhistory: {
|
||||||
label: t`Stock History`,
|
label: t`Stock History`,
|
||||||
label_multiple: t`Stock Histories`,
|
label_multiple: t`Stock Histories`,
|
||||||
api_endpoint: ApiPaths.stock_tracking_list
|
api_endpoint: ApiEndpoints.stock_tracking_list
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
label: t`Build`,
|
label: t`Build`,
|
||||||
@ -83,7 +83,7 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/build',
|
url_overview: '/build',
|
||||||
url_detail: '/build/:pk/',
|
url_detail: '/build/:pk/',
|
||||||
cui_detail: '/build/:pk/',
|
cui_detail: '/build/:pk/',
|
||||||
api_endpoint: ApiPaths.build_order_list
|
api_endpoint: ApiEndpoints.build_order_list
|
||||||
},
|
},
|
||||||
company: {
|
company: {
|
||||||
label: t`Company`,
|
label: t`Company`,
|
||||||
@ -91,14 +91,14 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/company',
|
url_overview: '/company',
|
||||||
url_detail: '/company/:pk/',
|
url_detail: '/company/:pk/',
|
||||||
cui_detail: '/company/:pk/',
|
cui_detail: '/company/:pk/',
|
||||||
api_endpoint: ApiPaths.company_list
|
api_endpoint: ApiEndpoints.company_list
|
||||||
},
|
},
|
||||||
projectcode: {
|
projectcode: {
|
||||||
label: t`Project Code`,
|
label: t`Project Code`,
|
||||||
label_multiple: t`Project Codes`,
|
label_multiple: t`Project Codes`,
|
||||||
url_overview: '/project-code',
|
url_overview: '/project-code',
|
||||||
url_detail: '/project-code/:pk/',
|
url_detail: '/project-code/:pk/',
|
||||||
api_endpoint: ApiPaths.project_code_list
|
api_endpoint: ApiEndpoints.project_code_list
|
||||||
},
|
},
|
||||||
purchaseorder: {
|
purchaseorder: {
|
||||||
label: t`Purchase Order`,
|
label: t`Purchase Order`,
|
||||||
@ -106,12 +106,12 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/purchasing/purchase-order',
|
url_overview: '/purchasing/purchase-order',
|
||||||
url_detail: '/purchasing/purchase-order/:pk/',
|
url_detail: '/purchasing/purchase-order/:pk/',
|
||||||
cui_detail: '/order/purchase-order/:pk/',
|
cui_detail: '/order/purchase-order/:pk/',
|
||||||
api_endpoint: ApiPaths.purchase_order_list
|
api_endpoint: ApiEndpoints.purchase_order_list
|
||||||
},
|
},
|
||||||
purchaseorderline: {
|
purchaseorderline: {
|
||||||
label: t`Purchase Order Line`,
|
label: t`Purchase Order Line`,
|
||||||
label_multiple: t`Purchase Order Lines`,
|
label_multiple: t`Purchase Order Lines`,
|
||||||
api_endpoint: ApiPaths.purchase_order_line_list
|
api_endpoint: ApiEndpoints.purchase_order_line_list
|
||||||
},
|
},
|
||||||
salesorder: {
|
salesorder: {
|
||||||
label: t`Sales Order`,
|
label: t`Sales Order`,
|
||||||
@ -119,14 +119,14 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/sales/sales-order',
|
url_overview: '/sales/sales-order',
|
||||||
url_detail: '/sales/sales-order/:pk/',
|
url_detail: '/sales/sales-order/:pk/',
|
||||||
cui_detail: '/order/sales-order/:pk/',
|
cui_detail: '/order/sales-order/:pk/',
|
||||||
api_endpoint: ApiPaths.sales_order_list
|
api_endpoint: ApiEndpoints.sales_order_list
|
||||||
},
|
},
|
||||||
salesordershipment: {
|
salesordershipment: {
|
||||||
label: t`Sales Order Shipment`,
|
label: t`Sales Order Shipment`,
|
||||||
label_multiple: t`Sales Order Shipments`,
|
label_multiple: t`Sales Order Shipments`,
|
||||||
url_overview: '/salesordershipment',
|
url_overview: '/salesordershipment',
|
||||||
url_detail: '/salesordershipment/:pk/',
|
url_detail: '/salesordershipment/:pk/',
|
||||||
api_endpoint: ApiPaths.sales_order_shipment_list
|
api_endpoint: ApiEndpoints.sales_order_shipment_list
|
||||||
},
|
},
|
||||||
returnorder: {
|
returnorder: {
|
||||||
label: t`Return Order`,
|
label: t`Return Order`,
|
||||||
@ -134,34 +134,34 @@ export const ModelInformationDict: ModelDictory = {
|
|||||||
url_overview: '/sales/return-order',
|
url_overview: '/sales/return-order',
|
||||||
url_detail: '/sales/return-order/:pk/',
|
url_detail: '/sales/return-order/:pk/',
|
||||||
cui_detail: '/order/return-order/:pk/',
|
cui_detail: '/order/return-order/:pk/',
|
||||||
api_endpoint: ApiPaths.return_order_list
|
api_endpoint: ApiEndpoints.return_order_list
|
||||||
},
|
},
|
||||||
address: {
|
address: {
|
||||||
label: t`Address`,
|
label: t`Address`,
|
||||||
label_multiple: t`Addresses`,
|
label_multiple: t`Addresses`,
|
||||||
url_overview: '/address',
|
url_overview: '/address',
|
||||||
url_detail: '/address/:pk/',
|
url_detail: '/address/:pk/',
|
||||||
api_endpoint: ApiPaths.address_list
|
api_endpoint: ApiEndpoints.address_list
|
||||||
},
|
},
|
||||||
contact: {
|
contact: {
|
||||||
label: t`Contact`,
|
label: t`Contact`,
|
||||||
label_multiple: t`Contacts`,
|
label_multiple: t`Contacts`,
|
||||||
url_overview: '/contact',
|
url_overview: '/contact',
|
||||||
url_detail: '/contact/:pk/',
|
url_detail: '/contact/:pk/',
|
||||||
api_endpoint: ApiPaths.contact_list
|
api_endpoint: ApiEndpoints.contact_list
|
||||||
},
|
},
|
||||||
owner: {
|
owner: {
|
||||||
label: t`Owner`,
|
label: t`Owner`,
|
||||||
label_multiple: t`Owners`,
|
label_multiple: t`Owners`,
|
||||||
url_overview: '/owner',
|
url_overview: '/owner',
|
||||||
url_detail: '/owner/:pk/',
|
url_detail: '/owner/:pk/',
|
||||||
api_endpoint: ApiPaths.owner_list
|
api_endpoint: ApiEndpoints.owner_list
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
label: t`User`,
|
label: t`User`,
|
||||||
label_multiple: t`Users`,
|
label_multiple: t`Users`,
|
||||||
url_overview: '/user',
|
url_overview: '/user',
|
||||||
url_detail: '/user/:pk/',
|
url_detail: '/user/:pk/',
|
||||||
api_endpoint: ApiPaths.user_list
|
api_endpoint: ApiEndpoints.user_list
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ import { ReactNode, useCallback, useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { formatPriceRange } from '../../../defaults/formatters';
|
import { formatPriceRange } from '../../../defaults/formatters';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { bomItemFields } from '../../../forms/BomForms';
|
import { bomItemFields } from '../../../forms/BomForms';
|
||||||
@ -320,7 +320,7 @@ export function BomTable({
|
|||||||
hidden: !user.hasChangeRole(UserRoles.part),
|
hidden: !user.hasChangeRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.bom_list,
|
url: ApiEndpoints.bom_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Bom Item`,
|
title: t`Edit Bom Item`,
|
||||||
fields: bomItemFields(),
|
fields: bomItemFields(),
|
||||||
@ -337,7 +337,7 @@ export function BomTable({
|
|||||||
hidden: !user.hasDeleteRole(UserRoles.part),
|
hidden: !user.hasDeleteRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.bom_list,
|
url: ApiEndpoints.bom_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Bom Item`,
|
title: t`Delete Bom Item`,
|
||||||
successMessage: t`Bom item deleted`,
|
successMessage: t`Bom item deleted`,
|
||||||
@ -355,7 +355,7 @@ export function BomTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.bom_list)}
|
url={apiUrl(ApiEndpoints.bom_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { getDetailUrl } from '../../../functions/urls';
|
import { getDetailUrl } from '../../../functions/urls';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -84,7 +84,7 @@ export function UsedInTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.bom_list)}
|
url={apiUrl(ApiEndpoints.bom_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { getDetailUrl } from '../../../functions/urls';
|
import { getDetailUrl } from '../../../functions/urls';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -223,7 +223,7 @@ export default function BuildLineTable({ params = {} }: { params?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.build_line_list)}
|
url={apiUrl(ApiEndpoints.build_line_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { renderDate } from '../../../defaults/formatters';
|
import { renderDate } from '../../../defaults/formatters';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { getDetailUrl } from '../../../functions/urls';
|
import { getDetailUrl } from '../../../functions/urls';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -135,7 +135,7 @@ export function BuildOrderTable({ params = {} }: { params?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.build_order_list)}
|
url={apiUrl(ApiEndpoints.build_order_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { addressFields } from '../../../forms/CompanyForms';
|
import { addressFields } from '../../../forms/CompanyForms';
|
||||||
import {
|
import {
|
||||||
@ -123,7 +123,7 @@ export function AddressTable({
|
|||||||
hidden: !can_edit,
|
hidden: !can_edit,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.address_list,
|
url: ApiEndpoints.address_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Address`,
|
title: t`Edit Address`,
|
||||||
fields: addressFields(),
|
fields: addressFields(),
|
||||||
@ -136,7 +136,7 @@ export function AddressTable({
|
|||||||
hidden: !can_delete,
|
hidden: !can_delete,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.address_list,
|
url: ApiEndpoints.address_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Address`,
|
title: t`Delete Address`,
|
||||||
successMessage: t`Address deleted`,
|
successMessage: t`Address deleted`,
|
||||||
@ -156,7 +156,7 @@ export function AddressTable({
|
|||||||
fields['company'].value = companyId;
|
fields['company'].value = companyId;
|
||||||
|
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.address_list,
|
url: ApiEndpoints.address_list,
|
||||||
title: t`Add Address`,
|
title: t`Add Address`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
successMessage: t`Address created`,
|
successMessage: t`Address created`,
|
||||||
@ -180,7 +180,7 @@ export function AddressTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.address_list)}
|
url={apiUrl(ApiEndpoints.address_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { Group, Text } from '@mantine/core';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { Thumbnail } from '../../images/Thumbnail';
|
import { Thumbnail } from '../../images/Thumbnail';
|
||||||
@ -55,7 +55,7 @@ export function CompanyTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.company_list)}
|
url={apiUrl(ApiEndpoints.company_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { contactFields } from '../../../forms/CompanyForms';
|
import { contactFields } from '../../../forms/CompanyForms';
|
||||||
import {
|
import {
|
||||||
@ -71,7 +71,7 @@ export function ContactTable({
|
|||||||
hidden: !can_edit,
|
hidden: !can_edit,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.contact_list,
|
url: ApiEndpoints.contact_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Contact`,
|
title: t`Edit Contact`,
|
||||||
fields: contactFields(),
|
fields: contactFields(),
|
||||||
@ -84,7 +84,7 @@ export function ContactTable({
|
|||||||
hidden: !can_delete,
|
hidden: !can_delete,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.contact_list,
|
url: ApiEndpoints.contact_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Contact`,
|
title: t`Delete Contact`,
|
||||||
successMessage: t`Contact deleted`,
|
successMessage: t`Contact deleted`,
|
||||||
@ -104,7 +104,7 @@ export function ContactTable({
|
|||||||
fields['company'].value = companyId;
|
fields['company'].value = companyId;
|
||||||
|
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.contact_list,
|
url: ApiEndpoints.contact_list,
|
||||||
title: t`Create Contact`,
|
title: t`Create Contact`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
successMessage: t`Contact created`,
|
successMessage: t`Contact created`,
|
||||||
@ -128,7 +128,7 @@ export function ContactTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.contact_list)}
|
url={apiUrl(ApiEndpoints.contact_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -7,7 +7,7 @@ import { IconExternalLink, IconFileUpload } from '@tabler/icons-react';
|
|||||||
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { api } from '../../../App';
|
import { api } from '../../../App';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import {
|
import {
|
||||||
addAttachment,
|
addAttachment,
|
||||||
deleteAttachment,
|
deleteAttachment,
|
||||||
@ -78,7 +78,7 @@ export function AttachmentTable({
|
|||||||
model,
|
model,
|
||||||
pk
|
pk
|
||||||
}: {
|
}: {
|
||||||
endpoint: ApiPaths;
|
endpoint: ApiEndpoints;
|
||||||
pk: number;
|
pk: number;
|
||||||
model: string;
|
model: string;
|
||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { TableState } from '../../../hooks/UseTable';
|
import { TableState } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { TableColumn } from '../Column';
|
import { TableColumn } from '../Column';
|
||||||
@ -42,7 +42,7 @@ export function NotificationTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.notifications_list)}
|
url={apiUrl(ApiEndpoints.notifications_list)}
|
||||||
tableState={tableState}
|
tableState={tableState}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { partCategoryFields } from '../../../forms/PartForms';
|
import { partCategoryFields } from '../../../forms/PartForms';
|
||||||
@ -81,7 +81,7 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: apiUrl(ApiPaths.category_list),
|
url: apiUrl(ApiEndpoints.category_list),
|
||||||
title: t`Add Part Category`,
|
title: t`Add Part Category`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
onFormSuccess(data: any) {
|
onFormSuccess(data: any) {
|
||||||
@ -115,7 +115,7 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) {
|
|||||||
hidden: !can_edit,
|
hidden: !can_edit,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.category_list,
|
url: ApiEndpoints.category_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Part Category`,
|
title: t`Edit Part Category`,
|
||||||
fields: partCategoryFields({}),
|
fields: partCategoryFields({}),
|
||||||
@ -131,7 +131,7 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.category_list)}
|
url={apiUrl(ApiEndpoints.category_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Text } from '@mantine/core';
|
import { Text } from '@mantine/core';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import {
|
import {
|
||||||
openCreateApiForm,
|
openCreateApiForm,
|
||||||
@ -101,7 +101,7 @@ export function PartParameterTable({ partId }: { partId: any }) {
|
|||||||
hidden: !user.hasChangeRole(UserRoles.part),
|
hidden: !user.hasChangeRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.part_parameter_list,
|
url: ApiEndpoints.part_parameter_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Part Parameter`,
|
title: t`Edit Part Parameter`,
|
||||||
fields: {
|
fields: {
|
||||||
@ -124,7 +124,7 @@ export function PartParameterTable({ partId }: { partId: any }) {
|
|||||||
hidden: !user.hasDeleteRole(UserRoles.part),
|
hidden: !user.hasDeleteRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.part_parameter_list,
|
url: ApiEndpoints.part_parameter_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Part Parameter`,
|
title: t`Delete Part Parameter`,
|
||||||
successMessage: t`Part parameter deleted`,
|
successMessage: t`Part parameter deleted`,
|
||||||
@ -146,7 +146,7 @@ export function PartParameterTable({ partId }: { partId: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.part_parameter_list,
|
url: ApiEndpoints.part_parameter_list,
|
||||||
title: t`Add Part Parameter`,
|
title: t`Add Part Parameter`,
|
||||||
fields: {
|
fields: {
|
||||||
part: {
|
part: {
|
||||||
@ -175,7 +175,7 @@ export function PartParameterTable({ partId }: { partId: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.part_parameter_list)}
|
url={apiUrl(ApiEndpoints.part_parameter_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { partParameterTemplateFields } from '../../../forms/PartForms';
|
import { partParameterTemplateFields } from '../../../forms/PartForms';
|
||||||
import {
|
import {
|
||||||
@ -77,7 +77,7 @@ export default function PartParameterTemplateTable() {
|
|||||||
hidden: !user.hasChangeRole(UserRoles.part),
|
hidden: !user.hasChangeRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.part_parameter_template_list,
|
url: ApiEndpoints.part_parameter_template_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Parameter Template`,
|
title: t`Edit Parameter Template`,
|
||||||
fields: partParameterTemplateFields(),
|
fields: partParameterTemplateFields(),
|
||||||
@ -90,7 +90,7 @@ export default function PartParameterTemplateTable() {
|
|||||||
hidden: !user.hasDeleteRole(UserRoles.part),
|
hidden: !user.hasDeleteRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.part_parameter_template_list,
|
url: ApiEndpoints.part_parameter_template_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Parameter Template`,
|
title: t`Delete Parameter Template`,
|
||||||
successMessage: t`Parameter template deleted`,
|
successMessage: t`Parameter template deleted`,
|
||||||
@ -106,7 +106,7 @@ export default function PartParameterTemplateTable() {
|
|||||||
|
|
||||||
const addParameterTemplate = useCallback(() => {
|
const addParameterTemplate = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.part_parameter_template_list,
|
url: ApiEndpoints.part_parameter_template_list,
|
||||||
title: t`Create Parameter Template`,
|
title: t`Create Parameter Template`,
|
||||||
fields: partParameterTemplateFields(),
|
fields: partParameterTemplateFields(),
|
||||||
successMessage: t`Parameter template created`,
|
successMessage: t`Parameter template created`,
|
||||||
@ -126,7 +126,7 @@ export default function PartParameterTemplateTable() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.part_parameter_template_list)}
|
url={apiUrl(ApiEndpoints.part_parameter_template_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -4,7 +4,7 @@ import { ReactNode, useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { formatPriceRange } from '../../../defaults/formatters';
|
import { formatPriceRange } from '../../../defaults/formatters';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { shortenString } from '../../../functions/tables';
|
import { shortenString } from '../../../functions/tables';
|
||||||
import { getDetailUrl } from '../../../functions/urls';
|
import { getDetailUrl } from '../../../functions/urls';
|
||||||
@ -271,7 +271,7 @@ export function PartListTable({ props }: { props: InvenTreeTableProps }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.part_list)}
|
url={apiUrl(ApiEndpoints.part_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { partTestTemplateFields } from '../../../forms/PartForms';
|
import { partTestTemplateFields } from '../../../forms/PartForms';
|
||||||
import {
|
import {
|
||||||
@ -79,7 +79,7 @@ export default function PartTestTemplateTable({ partId }: { partId: number }) {
|
|||||||
hidden: !can_edit,
|
hidden: !can_edit,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.part_test_template_list,
|
url: ApiEndpoints.part_test_template_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Test Template`,
|
title: t`Edit Test Template`,
|
||||||
fields: partTestTemplateFields(),
|
fields: partTestTemplateFields(),
|
||||||
@ -92,7 +92,7 @@ export default function PartTestTemplateTable({ partId }: { partId: number }) {
|
|||||||
hidden: !can_delete,
|
hidden: !can_delete,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.part_test_template_list,
|
url: ApiEndpoints.part_test_template_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Test Template`,
|
title: t`Delete Test Template`,
|
||||||
successMessage: t`Test Template deleted`,
|
successMessage: t`Test Template deleted`,
|
||||||
@ -111,7 +111,7 @@ export default function PartTestTemplateTable({ partId }: { partId: number }) {
|
|||||||
fields['part'].value = partId;
|
fields['part'].value = partId;
|
||||||
|
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.part_test_template_list,
|
url: ApiEndpoints.part_test_template_list,
|
||||||
title: t`Create Test Template`,
|
title: t`Create Test Template`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
successMessage: t`Template created`,
|
successMessage: t`Template created`,
|
||||||
@ -133,7 +133,7 @@ export default function PartTestTemplateTable({ partId }: { partId: number }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.part_test_template_list)}
|
url={apiUrl(ApiEndpoints.part_test_template_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -4,7 +4,7 @@ import { IconLayersLinked } from '@tabler/icons-react';
|
|||||||
import { ReactNode, useCallback, useMemo } from 'react';
|
import { ReactNode, useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { openCreateApiForm, openDeleteApiForm } from '../../../functions/forms';
|
import { openCreateApiForm, openDeleteApiForm } from '../../../functions/forms';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -69,7 +69,7 @@ export function RelatedPartTable({ partId }: { partId: number }): ReactNode {
|
|||||||
const addRelatedPart = useCallback(() => {
|
const addRelatedPart = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
title: t`Add Related Part`,
|
title: t`Add Related Part`,
|
||||||
url: ApiPaths.related_part_list,
|
url: ApiEndpoints.related_part_list,
|
||||||
fields: {
|
fields: {
|
||||||
part_1: {
|
part_1: {
|
||||||
hidden: true,
|
hidden: true,
|
||||||
@ -108,7 +108,7 @@ export function RelatedPartTable({ partId }: { partId: number }): ReactNode {
|
|||||||
hidden: !user.hasDeleteRole(UserRoles.part),
|
hidden: !user.hasDeleteRole(UserRoles.part),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.related_part_list,
|
url: ApiEndpoints.related_part_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Related Part`,
|
title: t`Delete Related Part`,
|
||||||
successMessage: t`Related part deleted`,
|
successMessage: t`Related part deleted`,
|
||||||
@ -124,7 +124,7 @@ export function RelatedPartTable({ partId }: { partId: number }): ReactNode {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.related_part_list)}
|
url={apiUrl(ApiEndpoints.related_part_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Code } from '@mantine/core';
|
import { Code } from '@mantine/core';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { TableColumn } from '../Column';
|
import { TableColumn } from '../Column';
|
||||||
@ -43,7 +43,7 @@ export function PluginErrorTable({ props }: { props: InvenTreeTableProps }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.plugin_registry_status)}
|
url={apiUrl(ApiEndpoints.plugin_registry_status)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={registryErrorTableColumns}
|
columns={registryErrorTableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -24,7 +24,7 @@ import { useCallback, useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../../App';
|
import { api } from '../../../App';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { openEditApiForm } from '../../../functions/forms';
|
import { openEditApiForm } from '../../../functions/forms';
|
||||||
import { useCreateApiFormModal } from '../../../hooks/UseForm';
|
import { useCreateApiFormModal } from '../../../hooks/UseForm';
|
||||||
import { useInstance } from '../../../hooks/UseInstance';
|
import { useInstance } from '../../../hooks/UseInstance';
|
||||||
@ -82,7 +82,7 @@ export function PluginDrawer({
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery: { isFetching, error }
|
instanceQuery: { isFetching, error }
|
||||||
} = useInstance<PluginI>({
|
} = useInstance<PluginI>({
|
||||||
endpoint: ApiPaths.plugin_list,
|
endpoint: ApiEndpoints.plugin_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
throwError: true
|
throwError: true
|
||||||
});
|
});
|
||||||
@ -127,7 +127,7 @@ export function PluginDrawer({
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
title: t`Edit plugin`,
|
title: t`Edit plugin`,
|
||||||
url: ApiPaths.plugin_list,
|
url: ApiEndpoints.plugin_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
fields: {
|
fields: {
|
||||||
active: {}
|
active: {}
|
||||||
@ -334,7 +334,7 @@ export function PluginListTable({ props }: { props: InvenTreeTableProps }) {
|
|||||||
confirm: t`Confirm`
|
confirm: t`Confirm`
|
||||||
},
|
},
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
let url = apiUrl(ApiPaths.plugin_list, plugin_id) + 'activate/';
|
let url = apiUrl(ApiEndpoints.plugin_list, plugin_id) + 'activate/';
|
||||||
|
|
||||||
const id = 'plugin-activate';
|
const id = 'plugin-activate';
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ export function PluginListTable({ props }: { props: InvenTreeTableProps }) {
|
|||||||
|
|
||||||
const installPluginModal = useCreateApiFormModal({
|
const installPluginModal = useCreateApiFormModal({
|
||||||
title: t`Install plugin`,
|
title: t`Install plugin`,
|
||||||
url: ApiPaths.plugin_install,
|
url: ApiEndpoints.plugin_install,
|
||||||
fields: {
|
fields: {
|
||||||
packagename: {},
|
packagename: {},
|
||||||
url: {},
|
url: {},
|
||||||
@ -428,7 +428,7 @@ export function PluginListTable({ props }: { props: InvenTreeTableProps }) {
|
|||||||
|
|
||||||
const reloadPlugins = useCallback(() => {
|
const reloadPlugins = useCallback(() => {
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.plugin_reload), {
|
.post(apiUrl(ApiEndpoints.plugin_reload), {
|
||||||
full_reload: true,
|
full_reload: true,
|
||||||
force_reload: true,
|
force_reload: true,
|
||||||
collect_plugins: true
|
collect_plugins: true
|
||||||
@ -482,7 +482,7 @@ export function PluginListTable({ props }: { props: InvenTreeTableProps }) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.plugin_list)}
|
url={apiUrl(ApiEndpoints.plugin_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={pluginTableColumns}
|
columns={pluginTableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { useManufacturerPartParameterFields } from '../../../forms/CompanyForms';
|
import { useManufacturerPartParameterFields } from '../../../forms/CompanyForms';
|
||||||
import { openDeleteApiForm, openEditApiForm } from '../../../functions/forms';
|
import { openDeleteApiForm, openEditApiForm } from '../../../functions/forms';
|
||||||
@ -52,7 +52,7 @@ export default function ManufacturerPartParameterTable({
|
|||||||
hidden: !user.hasChangeRole(UserRoles.purchase_order),
|
hidden: !user.hasChangeRole(UserRoles.purchase_order),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.manufacturer_part_parameter_list,
|
url: ApiEndpoints.manufacturer_part_parameter_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Parameter`,
|
title: t`Edit Parameter`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
@ -66,7 +66,7 @@ export default function ManufacturerPartParameterTable({
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
record.pk &&
|
record.pk &&
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.manufacturer_part_parameter_list,
|
url: ApiEndpoints.manufacturer_part_parameter_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Parameter`,
|
title: t`Delete Parameter`,
|
||||||
onFormSuccess: table.refreshTable,
|
onFormSuccess: table.refreshTable,
|
||||||
@ -82,7 +82,7 @@ export default function ManufacturerPartParameterTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.manufacturer_part_parameter_list)}
|
url={apiUrl(ApiEndpoints.manufacturer_part_parameter_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { ReactNode, useCallback, useMemo } from 'react';
|
import { ReactNode, useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { useManufacturerPartFields } from '../../../forms/CompanyForms';
|
import { useManufacturerPartFields } from '../../../forms/CompanyForms';
|
||||||
@ -91,7 +91,7 @@ export function ManufacturerPartTable({ params }: { params: any }): ReactNode {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
record.pk &&
|
record.pk &&
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.manufacturer_part_list,
|
url: ApiEndpoints.manufacturer_part_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Manufacturer Part`,
|
title: t`Edit Manufacturer Part`,
|
||||||
fields: editManufacturerPartFields,
|
fields: editManufacturerPartFields,
|
||||||
@ -105,7 +105,7 @@ export function ManufacturerPartTable({ params }: { params: any }): ReactNode {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
record.pk &&
|
record.pk &&
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.manufacturer_part_list,
|
url: ApiEndpoints.manufacturer_part_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Manufacturer Part`,
|
title: t`Delete Manufacturer Part`,
|
||||||
successMessage: t`Manufacturer part deleted`,
|
successMessage: t`Manufacturer part deleted`,
|
||||||
@ -121,7 +121,7 @@ export function ManufacturerPartTable({ params }: { params: any }): ReactNode {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.manufacturer_part_list)}
|
url={apiUrl(ApiEndpoints.manufacturer_part_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -5,7 +5,7 @@ import { useCallback, useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ProgressBar } from '../../../components/items/ProgressBar';
|
import { ProgressBar } from '../../../components/items/ProgressBar';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { purchaseOrderLineItemFields } from '../../../forms/PurchaseOrderForms';
|
import { purchaseOrderLineItemFields } from '../../../forms/PurchaseOrderForms';
|
||||||
@ -73,7 +73,7 @@ export function PurchaseOrderLineItemTable({
|
|||||||
});
|
});
|
||||||
|
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.purchase_order_line_list,
|
url: ApiEndpoints.purchase_order_line_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Line Item`,
|
title: t`Edit Line Item`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
@ -222,7 +222,7 @@ export function PurchaseOrderLineItemTable({
|
|||||||
|
|
||||||
const addLine = useCallback(() => {
|
const addLine = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.purchase_order_line_list,
|
url: ApiEndpoints.purchase_order_line_list,
|
||||||
title: t`Add Line Item`,
|
title: t`Add Line Item`,
|
||||||
fields: purchaseOrderLineItemFields({
|
fields: purchaseOrderLineItemFields({
|
||||||
create: true,
|
create: true,
|
||||||
@ -252,7 +252,7 @@ export function PurchaseOrderLineItemTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.purchase_order_line_list)}
|
url={apiUrl(ApiEndpoints.purchase_order_line_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { notYetImplemented } from '../../../functions/notifications';
|
import { notYetImplemented } from '../../../functions/notifications';
|
||||||
@ -116,7 +116,7 @@ export function PurchaseOrderTable({ params }: { params?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.purchase_order_list)}
|
url={apiUrl(ApiEndpoints.purchase_order_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { Text } from '@mantine/core';
|
|||||||
import { ReactNode, useCallback, useMemo } from 'react';
|
import { ReactNode, useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { useSupplierPartFields } from '../../../forms/CompanyForms';
|
import { useSupplierPartFields } from '../../../forms/CompanyForms';
|
||||||
@ -161,7 +161,7 @@ export function SupplierPartTable({ params }: { params: any }): ReactNode {
|
|||||||
});
|
});
|
||||||
const { modal: addSupplierPartModal, open: openAddSupplierPartForm } =
|
const { modal: addSupplierPartModal, open: openAddSupplierPartForm } =
|
||||||
useCreateApiFormModal({
|
useCreateApiFormModal({
|
||||||
url: ApiPaths.supplier_part_list,
|
url: ApiEndpoints.supplier_part_list,
|
||||||
title: t`Add Supplier Part`,
|
title: t`Add Supplier Part`,
|
||||||
fields: addSupplierPartFields,
|
fields: addSupplierPartFields,
|
||||||
onFormSuccess: table.refreshTable,
|
onFormSuccess: table.refreshTable,
|
||||||
@ -194,7 +194,7 @@ export function SupplierPartTable({ params }: { params: any }): ReactNode {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
record.pk &&
|
record.pk &&
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.supplier_part_list,
|
url: ApiEndpoints.supplier_part_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Supplier Part`,
|
title: t`Edit Supplier Part`,
|
||||||
fields: editSupplierPartFields,
|
fields: editSupplierPartFields,
|
||||||
@ -208,7 +208,7 @@ export function SupplierPartTable({ params }: { params: any }): ReactNode {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
record.pk &&
|
record.pk &&
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.supplier_part_list,
|
url: ApiEndpoints.supplier_part_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete Supplier Part`,
|
title: t`Delete Supplier Part`,
|
||||||
successMessage: t`Supplier part deleted`,
|
successMessage: t`Supplier part deleted`,
|
||||||
@ -226,7 +226,7 @@ export function SupplierPartTable({ params }: { params: any }): ReactNode {
|
|||||||
<>
|
<>
|
||||||
{addSupplierPartModal}
|
{addSupplierPartModal}
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.supplier_part_list)}
|
url={apiUrl(ApiEndpoints.supplier_part_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { notYetImplemented } from '../../../functions/notifications';
|
import { notYetImplemented } from '../../../functions/notifications';
|
||||||
@ -112,7 +112,7 @@ export function ReturnOrderTable({ params }: { params?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.return_order_list)}
|
url={apiUrl(ApiEndpoints.return_order_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { notYetImplemented } from '../../../functions/notifications';
|
import { notYetImplemented } from '../../../functions/notifications';
|
||||||
@ -113,7 +113,7 @@ export function SalesOrderTable({ params }: { params?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.sales_order_list)}
|
url={apiUrl(ApiEndpoints.sales_order_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -4,7 +4,7 @@ import { IconReload } from '@tabler/icons-react';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { api } from '../../../App';
|
import { api } from '../../../App';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { ActionButton } from '../../buttons/ActionButton';
|
import { ActionButton } from '../../buttons/ActionButton';
|
||||||
@ -33,7 +33,7 @@ export function CurrencyTable() {
|
|||||||
|
|
||||||
const refreshCurrencies = useCallback(() => {
|
const refreshCurrencies = useCallback(() => {
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.currency_refresh), {})
|
.post(apiUrl(ApiEndpoints.currency_refresh), {})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
table.refreshTable();
|
table.refreshTable();
|
||||||
showNotification({
|
showNotification({
|
||||||
@ -62,7 +62,7 @@ export function CurrencyTable() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.currency_list)}
|
url={apiUrl(ApiEndpoints.currency_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import {
|
import {
|
||||||
openCreateApiForm,
|
openCreateApiForm,
|
||||||
@ -54,7 +54,7 @@ export default function CustomUnitsTable() {
|
|||||||
hidden: !user.hasChangeRole(UserRoles.admin),
|
hidden: !user.hasChangeRole(UserRoles.admin),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.custom_unit_list,
|
url: ApiEndpoints.custom_unit_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit custom unit`,
|
title: t`Edit custom unit`,
|
||||||
fields: {
|
fields: {
|
||||||
@ -71,7 +71,7 @@ export default function CustomUnitsTable() {
|
|||||||
hidden: !user.hasDeleteRole(UserRoles.admin),
|
hidden: !user.hasDeleteRole(UserRoles.admin),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.custom_unit_list,
|
url: ApiEndpoints.custom_unit_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete custom unit`,
|
title: t`Delete custom unit`,
|
||||||
successMessage: t`Custom unit deleted`,
|
successMessage: t`Custom unit deleted`,
|
||||||
@ -87,7 +87,7 @@ export default function CustomUnitsTable() {
|
|||||||
|
|
||||||
const addCustomUnit = useCallback(() => {
|
const addCustomUnit = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.custom_unit_list,
|
url: ApiEndpoints.custom_unit_list,
|
||||||
title: t`Add custom unit`,
|
title: t`Add custom unit`,
|
||||||
fields: {
|
fields: {
|
||||||
name: {},
|
name: {},
|
||||||
@ -112,7 +112,7 @@ export default function CustomUnitsTable() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.custom_unit_list)}
|
url={apiUrl(ApiEndpoints.custom_unit_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { Drawer, Text } from '@mantine/core';
|
|||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { openDeleteApiForm } from '../../../functions/forms';
|
import { openDeleteApiForm } from '../../../functions/forms';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
@ -46,7 +46,7 @@ export default function ErrorReportTable() {
|
|||||||
RowDeleteAction({
|
RowDeleteAction({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.error_report_list,
|
url: ApiEndpoints.error_report_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete error report`,
|
title: t`Delete error report`,
|
||||||
onFormSuccess: table.refreshTable,
|
onFormSuccess: table.refreshTable,
|
||||||
@ -72,7 +72,7 @@ export default function ErrorReportTable() {
|
|||||||
})}
|
})}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.error_report_list)}
|
url={apiUrl(ApiEndpoints.error_report_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { Drawer, Text } from '@mantine/core';
|
|||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { StylishText } from '../../items/StylishText';
|
import { StylishText } from '../../items/StylishText';
|
||||||
@ -62,7 +62,7 @@ export default function FailedTasksTable() {
|
|||||||
})}
|
})}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.task_failed_list)}
|
url={apiUrl(ApiEndpoints.task_failed_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { Group, LoadingOverlay, Stack, Text, Title } from '@mantine/core';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { openCreateApiForm, openDeleteApiForm } from '../../../functions/forms';
|
import { openCreateApiForm, openDeleteApiForm } from '../../../functions/forms';
|
||||||
import { useInstance } from '../../../hooks/UseInstance';
|
import { useInstance } from '../../../hooks/UseInstance';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -32,7 +32,7 @@ export function GroupDrawer({
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery: { isFetching, error }
|
instanceQuery: { isFetching, error }
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.group_list,
|
endpoint: ApiEndpoints.group_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
throwError: true
|
throwError: true
|
||||||
});
|
});
|
||||||
@ -57,7 +57,7 @@ export function GroupDrawer({
|
|||||||
<Stack>
|
<Stack>
|
||||||
<EditApiForm
|
<EditApiForm
|
||||||
props={{
|
props={{
|
||||||
url: ApiPaths.group_list,
|
url: ApiEndpoints.group_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
fields: {
|
fields: {
|
||||||
name: {}
|
name: {}
|
||||||
@ -110,7 +110,7 @@ export function GroupTable() {
|
|||||||
RowDeleteAction({
|
RowDeleteAction({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.group_list,
|
url: ApiEndpoints.group_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete group`,
|
title: t`Delete group`,
|
||||||
successMessage: t`Group deleted`,
|
successMessage: t`Group deleted`,
|
||||||
@ -124,7 +124,7 @@ export function GroupTable() {
|
|||||||
|
|
||||||
const addGroup = useCallback(() => {
|
const addGroup = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.group_list,
|
url: ApiEndpoints.group_list,
|
||||||
title: t`Add group`,
|
title: t`Add group`,
|
||||||
fields: { name: {} },
|
fields: { name: {} },
|
||||||
onFormSuccess: table.refreshTable,
|
onFormSuccess: table.refreshTable,
|
||||||
@ -161,7 +161,7 @@ export function GroupTable() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.group_list)}
|
url={apiUrl(ApiEndpoints.group_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { TableColumn } from '../Column';
|
import { TableColumn } from '../Column';
|
||||||
@ -44,7 +44,7 @@ export default function PendingTasksTable() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.task_pending_list)}
|
url={apiUrl(ApiEndpoints.task_pending_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import {
|
import {
|
||||||
openCreateApiForm,
|
openCreateApiForm,
|
||||||
@ -44,7 +44,7 @@ export default function ProjectCodeTable() {
|
|||||||
hidden: !user.hasChangeRole(UserRoles.admin),
|
hidden: !user.hasChangeRole(UserRoles.admin),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.project_code_list,
|
url: ApiEndpoints.project_code_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit project code`,
|
title: t`Edit project code`,
|
||||||
fields: {
|
fields: {
|
||||||
@ -61,7 +61,7 @@ export default function ProjectCodeTable() {
|
|||||||
hidden: !user.hasDeleteRole(UserRoles.admin),
|
hidden: !user.hasDeleteRole(UserRoles.admin),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.project_code_list,
|
url: ApiEndpoints.project_code_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete project code`,
|
title: t`Delete project code`,
|
||||||
successMessage: t`Project code deleted`,
|
successMessage: t`Project code deleted`,
|
||||||
@ -77,7 +77,7 @@ export default function ProjectCodeTable() {
|
|||||||
|
|
||||||
const addProjectCode = useCallback(() => {
|
const addProjectCode = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.project_code_list,
|
url: ApiEndpoints.project_code_list,
|
||||||
title: t`Add project code`,
|
title: t`Add project code`,
|
||||||
fields: {
|
fields: {
|
||||||
code: {},
|
code: {},
|
||||||
@ -101,7 +101,7 @@ export default function ProjectCodeTable() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.project_code_list)}
|
url={apiUrl(ApiEndpoints.project_code_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -3,7 +3,7 @@ import { Group, Text } from '@mantine/core';
|
|||||||
import { IconCircleCheck, IconCircleX } from '@tabler/icons-react';
|
import { IconCircleCheck, IconCircleX } from '@tabler/icons-react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
import { apiUrl } from '../../../states/ApiState';
|
import { apiUrl } from '../../../states/ApiState';
|
||||||
import { TableColumn } from '../Column';
|
import { TableColumn } from '../Column';
|
||||||
@ -53,7 +53,7 @@ export default function ScheduledTasksTable() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.task_scheduled_list)}
|
url={apiUrl(ApiEndpoints.task_scheduled_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{}}
|
props={{}}
|
||||||
|
@ -5,7 +5,7 @@ import { useCallback, useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { openCreateApiForm, openDeleteApiForm } from '../../../functions/forms';
|
import { openCreateApiForm, openDeleteApiForm } from '../../../functions/forms';
|
||||||
import { useInstance } from '../../../hooks/UseInstance';
|
import { useInstance } from '../../../hooks/UseInstance';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -44,7 +44,7 @@ export function UserDrawer({
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery: { isFetching, error }
|
instanceQuery: { isFetching, error }
|
||||||
} = useInstance<UserDetailI>({
|
} = useInstance<UserDetailI>({
|
||||||
endpoint: ApiPaths.user_list,
|
endpoint: ApiEndpoints.user_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
throwError: true
|
throwError: true
|
||||||
});
|
});
|
||||||
@ -75,7 +75,7 @@ export function UserDrawer({
|
|||||||
<Stack>
|
<Stack>
|
||||||
<EditApiForm
|
<EditApiForm
|
||||||
props={{
|
props={{
|
||||||
url: ApiPaths.user_list,
|
url: ApiEndpoints.user_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
fields: {
|
fields: {
|
||||||
username: {},
|
username: {},
|
||||||
@ -204,7 +204,7 @@ export function UserTable() {
|
|||||||
RowDeleteAction({
|
RowDeleteAction({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openDeleteApiForm({
|
openDeleteApiForm({
|
||||||
url: ApiPaths.user_list,
|
url: ApiEndpoints.user_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Delete user`,
|
title: t`Delete user`,
|
||||||
successMessage: t`User deleted`,
|
successMessage: t`User deleted`,
|
||||||
@ -218,7 +218,7 @@ export function UserTable() {
|
|||||||
|
|
||||||
const addUser = useCallback(() => {
|
const addUser = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.user_list,
|
url: ApiEndpoints.user_list,
|
||||||
title: t`Add user`,
|
title: t`Add user`,
|
||||||
fields: {
|
fields: {
|
||||||
username: {},
|
username: {},
|
||||||
@ -256,7 +256,7 @@ export function UserTable() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.user_list)}
|
url={apiUrl(ApiEndpoints.user_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -4,7 +4,7 @@ import { ReactNode, useMemo } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { formatCurrency, renderDate } from '../../../defaults/formatters';
|
import { formatCurrency, renderDate } from '../../../defaults/formatters';
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { getDetailUrl } from '../../../functions/urls';
|
import { getDetailUrl } from '../../../functions/urls';
|
||||||
import { useTable } from '../../../hooks/UseTable';
|
import { useTable } from '../../../hooks/UseTable';
|
||||||
@ -339,7 +339,7 @@ export function StockItemTable({ params = {} }: { params?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.stock_item_list)}
|
url={apiUrl(ApiEndpoints.stock_item_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { ApiPaths } from '../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../../enums/ModelType';
|
import { ModelType } from '../../../enums/ModelType';
|
||||||
import { UserRoles } from '../../../enums/Roles';
|
import { UserRoles } from '../../../enums/Roles';
|
||||||
import { stockLocationFields } from '../../../forms/StockForms';
|
import { stockLocationFields } from '../../../forms/StockForms';
|
||||||
@ -104,7 +104,7 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: apiUrl(ApiPaths.stock_location_list),
|
url: apiUrl(ApiEndpoints.stock_location_list),
|
||||||
title: t`Add Stock Location`,
|
title: t`Add Stock Location`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
onFormSuccess(data: any) {
|
onFormSuccess(data: any) {
|
||||||
@ -138,7 +138,7 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
|
|||||||
hidden: !can_edit,
|
hidden: !can_edit,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.stock_location_list,
|
url: ApiEndpoints.stock_location_list,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
title: t`Edit Stock Location`,
|
title: t`Edit Stock Location`,
|
||||||
fields: stockLocationFields({}),
|
fields: stockLocationFields({}),
|
||||||
@ -154,7 +154,7 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiPaths.stock_location_list)}
|
url={apiUrl(ApiEndpoints.stock_location_list)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
columns={tableColumns}
|
columns={tableColumns}
|
||||||
props={{
|
props={{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
|
|
||||||
interface DashboardItems {
|
interface DashboardItems {
|
||||||
id: string;
|
id: string;
|
||||||
text: string;
|
text: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
url: ApiPaths;
|
url: ApiEndpoints;
|
||||||
params: any;
|
params: any;
|
||||||
}
|
}
|
||||||
export const dashboardItems: DashboardItems[] = [
|
export const dashboardItems: DashboardItems[] = [
|
||||||
@ -14,119 +14,119 @@ 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: ApiPaths.part_list,
|
url: ApiEndpoints.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: ApiPaths.category_list,
|
url: ApiEndpoints.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: ApiPaths.part_list,
|
url: ApiEndpoints.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: ApiPaths.part_list,
|
url: ApiEndpoints.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: ApiPaths.stock_item_list,
|
url: ApiEndpoints.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: ApiPaths.part_list,
|
url: ApiEndpoints.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: ApiPaths.part_list,
|
url: ApiEndpoints.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: ApiPaths.part_list,
|
url: ApiEndpoints.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: ApiPaths.stock_item_list,
|
url: ApiEndpoints.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: ApiPaths.stock_item_list,
|
url: ApiEndpoints.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: ApiPaths.build_order_list,
|
url: ApiEndpoints.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: ApiPaths.build_order_list,
|
url: ApiEndpoints.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: ApiPaths.purchase_order_list,
|
url: ApiEndpoints.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: ApiPaths.purchase_order_list,
|
url: ApiEndpoints.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: ApiPaths.sales_order_list,
|
url: ApiEndpoints.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: ApiPaths.sales_order_list,
|
url: ApiEndpoints.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: ApiPaths.news,
|
url: ApiEndpoints.news,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -1,106 +1,92 @@
|
|||||||
/*
|
/*
|
||||||
* Enumeration of available API endpoints.
|
* Enumeration of available API endpoints.
|
||||||
|
*
|
||||||
|
* In the cases where endpoints can be accessed with a primary key,
|
||||||
|
* the primary key should be appended to the endpoint.
|
||||||
|
* The exception to this is when the endpoint provides an :id parameter.
|
||||||
*/
|
*/
|
||||||
export enum ApiPaths {
|
|
||||||
api_server_info = 'api-server-info',
|
|
||||||
|
|
||||||
api_search = 'api-search',
|
export enum ApiEndpoints {
|
||||||
|
api_server_info = '',
|
||||||
|
|
||||||
// User information
|
// User API endpoints
|
||||||
user_me = 'api-user-me',
|
user_list = 'user/',
|
||||||
user_roles = 'api-user-roles',
|
user_me = 'user/me/',
|
||||||
user_token = 'api-user-token',
|
user_roles = 'user/roles/',
|
||||||
user_simple_login = 'api-user-simple-login',
|
user_token = 'user/token/',
|
||||||
user_reset = 'api-user-reset',
|
user_simple_login = 'email/generate/',
|
||||||
user_reset_set = 'api-user-reset-set',
|
user_reset = 'auth/password/reset/', // Note leading prefix here
|
||||||
user_sso = 'api-user-sso',
|
user_reset_set = 'auth/password/reset/confirm/', // Note leading prefix here
|
||||||
user_sso_remove = 'api-user-sso-remove',
|
user_sso = 'auth/social/',
|
||||||
user_emails = 'api-user-emails',
|
user_sso_remove = 'auth/social/:id/disconnect/',
|
||||||
user_email_verify = 'api-user-email-verify',
|
user_emails = 'auth/emails/',
|
||||||
user_email_primary = 'api-user-email-primary',
|
user_email_remove = 'auth/emails/:id/remove/',
|
||||||
user_email_remove = 'api-user-email-remove',
|
user_email_verify = 'auth/emails/:id/verify/',
|
||||||
user_logout = 'api-user-logout',
|
user_email_primary = 'auth/emails/:id/primary/',
|
||||||
user_register = 'api-user-register',
|
user_logout = 'auth/logout/',
|
||||||
|
user_register = 'auth/registration/',
|
||||||
|
|
||||||
user_list = 'api-user-list',
|
currency_list = 'currency/exchange/',
|
||||||
group_list = 'api-group-list',
|
currency_refresh = 'currency/refresh/',
|
||||||
owner_list = 'api-owner-list',
|
task_overview = 'background-task/',
|
||||||
|
task_pending_list = 'background-task/pending/',
|
||||||
|
task_scheduled_list = 'background-task/scheduled/',
|
||||||
|
task_failed_list = 'background-task/failed/',
|
||||||
|
api_search = 'search/',
|
||||||
|
settings_global_list = 'settings/global/',
|
||||||
|
settings_user_list = 'settings/user/',
|
||||||
|
notifications_list = 'notifications/',
|
||||||
|
barcode = 'barcode/',
|
||||||
|
news = 'news/',
|
||||||
|
global_status = 'generic/status/',
|
||||||
|
version = 'version/',
|
||||||
|
sso_providers = 'auth/providers/',
|
||||||
|
group_list = 'user/group/',
|
||||||
|
owner_list = 'user/owner/',
|
||||||
|
build_order_list = 'build/',
|
||||||
|
build_order_attachment_list = 'build/attachment/',
|
||||||
|
build_line_list = 'build/line/',
|
||||||
|
bom_list = 'bom/',
|
||||||
|
|
||||||
task_overview = 'api-task-overview',
|
// Part API endpoints
|
||||||
task_pending_list = 'api-task-pending-list',
|
part_list = 'part/',
|
||||||
task_scheduled_list = 'api-task-scheduled-list',
|
part_parameter_list = 'part/parameter/',
|
||||||
task_failed_list = 'api-task-failed-list',
|
part_parameter_template_list = 'part/parameter/template/',
|
||||||
|
category_list = 'part/category/',
|
||||||
|
category_tree = 'part/category/tree/',
|
||||||
|
related_part_list = 'part/related/',
|
||||||
|
part_attachment_list = 'part/attachment/',
|
||||||
|
part_test_template_list = 'part/test-template/',
|
||||||
|
|
||||||
settings_global_list = 'api-settings-global-list',
|
company_list = 'company/',
|
||||||
settings_user_list = 'api-settings-user-list',
|
contact_list = 'company/contact/',
|
||||||
notifications_list = 'api-notifications-list',
|
address_list = 'company/address/',
|
||||||
|
company_attachment_list = 'company/attachment/',
|
||||||
|
supplier_part_list = 'company/part/',
|
||||||
|
manufacturer_part_list = 'company/part/manufacturer/',
|
||||||
|
manufacturer_part_attachment_list = 'company/part/manufacturer/attachment/',
|
||||||
|
manufacturer_part_parameter_list = 'company/part/manufacturer/parameter/',
|
||||||
|
|
||||||
currency_list = 'api-currency-list',
|
// Stock API endpoints
|
||||||
currency_refresh = 'api-currency-refresh',
|
stock_item_list = 'stock/',
|
||||||
|
stock_tracking_list = 'stock/track/',
|
||||||
barcode = 'api-barcode',
|
stock_location_list = 'stock/location/',
|
||||||
news = 'news',
|
stock_location_tree = 'stock/location/tree/',
|
||||||
global_status = 'api-global-status',
|
stock_attachment_list = 'stock/attachment/',
|
||||||
version = 'api-version',
|
purchase_order_list = 'order/po/',
|
||||||
sso_providers = 'api-sso-providers',
|
purchase_order_line_list = 'order/po-line/',
|
||||||
|
purchase_order_attachment_list = 'order/po/attachment/',
|
||||||
// Build order URLs
|
sales_order_list = 'order/so/',
|
||||||
build_order_list = 'api-build-list',
|
sales_order_attachment_list = 'order/so/attachment/',
|
||||||
build_order_attachment_list = 'api-build-attachment-list',
|
sales_order_shipment_list = 'order/so/shipment/',
|
||||||
build_line_list = 'api-build-line-list',
|
return_order_list = 'order/ro/',
|
||||||
|
return_order_attachment_list = 'order/ro/attachment/',
|
||||||
// BOM URLs
|
plugin_list = 'plugins/',
|
||||||
bom_list = 'api-bom-list',
|
plugin_setting_list = 'plugins/:plugin/settings/',
|
||||||
|
plugin_registry_status = 'plugins/status/',
|
||||||
// Part URLs
|
plugin_install = 'plugins/install/',
|
||||||
part_list = 'api-part-list',
|
plugin_reload = 'plugins/reload/',
|
||||||
category_list = 'api-category-list',
|
error_report_list = 'error-report/',
|
||||||
category_tree = 'api-category-tree',
|
project_code_list = 'project-code/',
|
||||||
related_part_list = 'api-related-part-list',
|
custom_unit_list = 'units/'
|
||||||
part_attachment_list = 'api-part-attachment-list',
|
|
||||||
part_parameter_list = 'api-part-parameter-list',
|
|
||||||
part_parameter_template_list = 'api-part-parameter-template-list',
|
|
||||||
part_test_template_list = 'api-part-test-template-list',
|
|
||||||
|
|
||||||
// Company URLs
|
|
||||||
company_list = 'api-company-list',
|
|
||||||
company_attachment_list = 'api-company-attachment-list',
|
|
||||||
supplier_part_list = 'api-supplier-part-list',
|
|
||||||
manufacturer_part_list = 'api-manufacturer-part-list',
|
|
||||||
manufacturer_part_attachment_list = 'api-manufacturer-part-attachment-list',
|
|
||||||
manufacturer_part_parameter_list = 'api-manufacturer-part-parameter-list',
|
|
||||||
address_list = 'api-address-list',
|
|
||||||
contact_list = 'api-contact-list',
|
|
||||||
|
|
||||||
// Stock Item URLs
|
|
||||||
stock_item_list = 'api-stock-item-list',
|
|
||||||
stock_tracking_list = 'api-stock-tracking-list',
|
|
||||||
stock_location_list = 'api-stock-location-list',
|
|
||||||
stock_location_tree = 'api-stock-location-tree',
|
|
||||||
stock_attachment_list = 'api-stock-attachment-list',
|
|
||||||
|
|
||||||
// Purchase Order URLs
|
|
||||||
purchase_order_list = 'api-purchase-order-list',
|
|
||||||
purchase_order_line_list = 'api-purchase-order-line-list',
|
|
||||||
purchase_order_attachment_list = 'api-purchase-order-attachment-list',
|
|
||||||
|
|
||||||
// Sales Order URLs
|
|
||||||
sales_order_list = 'api-sales-order-list',
|
|
||||||
sales_order_attachment_list = 'api-sales-order-attachment-list',
|
|
||||||
sales_order_shipment_list = 'api_sales_order_shipment_list',
|
|
||||||
|
|
||||||
// Return Order URLs
|
|
||||||
return_order_list = 'api-return-order-list',
|
|
||||||
return_order_attachment_list = 'api-return-order-attachment-list',
|
|
||||||
|
|
||||||
// Plugin URLs
|
|
||||||
plugin_list = 'api-plugin-list',
|
|
||||||
plugin_setting_list = 'api-plugin-settings',
|
|
||||||
plugin_install = 'api-plugin-install',
|
|
||||||
plugin_reload = 'api-plugin-reload',
|
|
||||||
plugin_registry_status = 'api-plugin-registry-status',
|
|
||||||
|
|
||||||
error_report_list = 'api-error-report-list',
|
|
||||||
project_code_list = 'api-project-code-list',
|
|
||||||
custom_unit_list = 'api-custom-unit-list'
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import {
|
import {
|
||||||
openCreateApiForm,
|
openCreateApiForm,
|
||||||
openDeleteApiForm,
|
openDeleteApiForm,
|
||||||
@ -31,7 +31,7 @@ export function addAttachment({
|
|||||||
attachmentType,
|
attachmentType,
|
||||||
callback
|
callback
|
||||||
}: {
|
}: {
|
||||||
endpoint: ApiPaths;
|
endpoint: ApiEndpoints;
|
||||||
model: string;
|
model: string;
|
||||||
pk: number;
|
pk: number;
|
||||||
attachmentType: 'file' | 'link';
|
attachmentType: 'file' | 'link';
|
||||||
@ -76,7 +76,7 @@ export function editAttachment({
|
|||||||
attachmentType,
|
attachmentType,
|
||||||
callback
|
callback
|
||||||
}: {
|
}: {
|
||||||
endpoint: ApiPaths;
|
endpoint: ApiEndpoints;
|
||||||
model: string;
|
model: string;
|
||||||
pk: number;
|
pk: number;
|
||||||
attachmentType: 'file' | 'link';
|
attachmentType: 'file' | 'link';
|
||||||
@ -114,7 +114,7 @@ export function deleteAttachment({
|
|||||||
pk,
|
pk,
|
||||||
callback
|
callback
|
||||||
}: {
|
}: {
|
||||||
endpoint: ApiPaths;
|
endpoint: ApiEndpoints;
|
||||||
pk: number;
|
pk: number;
|
||||||
callback: () => void;
|
callback: () => void;
|
||||||
}) {
|
}) {
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { openEditApiForm } from '../functions/forms';
|
import { openEditApiForm } from '../functions/forms';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +144,7 @@ export function editCompany({
|
|||||||
}) {
|
}) {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
title: t`Edit Company`,
|
title: t`Edit Company`,
|
||||||
url: ApiPaths.company_list,
|
url: ApiEndpoints.company_list,
|
||||||
pk: pk,
|
pk: pk,
|
||||||
fields: companyFields(),
|
fields: companyFields(),
|
||||||
successMessage: t`Company updated`,
|
successMessage: t`Company updated`,
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { IconPackages } from '@tabler/icons-react';
|
import { IconPackages } from '@tabler/icons-react';
|
||||||
|
|
||||||
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { openCreateApiForm, openEditApiForm } from '../functions/forms';
|
import { openCreateApiForm, openEditApiForm } from '../functions/forms';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +104,7 @@ export function partFields({
|
|||||||
export function createPart() {
|
export function createPart() {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
title: t`Create Part`,
|
title: t`Create Part`,
|
||||||
url: ApiPaths.part_list,
|
url: ApiEndpoints.part_list,
|
||||||
successMessage: t`Part created`,
|
successMessage: t`Part created`,
|
||||||
fields: partFields({})
|
fields: partFields({})
|
||||||
});
|
});
|
||||||
@ -123,7 +123,7 @@ export function editPart({
|
|||||||
}) {
|
}) {
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
title: t`Edit Part`,
|
title: t`Edit Part`,
|
||||||
url: ApiPaths.part_list,
|
url: ApiEndpoints.part_list,
|
||||||
pk: part_id,
|
pk: part_id,
|
||||||
fields: partFields({ editing: true }),
|
fields: partFields({ editing: true }),
|
||||||
successMessage: t`Part updated`,
|
successMessage: t`Part updated`,
|
||||||
|
@ -2,7 +2,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
import { ApiFormFieldSet } from '../components/forms/fields/ApiFormField';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { useCreateApiFormModal, useEditApiFormModal } from '../hooks/UseForm';
|
import { useCreateApiFormModal, useEditApiFormModal } from '../hooks/UseForm';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +105,7 @@ export function useCreateStockItem() {
|
|||||||
const fields = useStockFields({ create: true });
|
const fields = useStockFields({ create: true });
|
||||||
|
|
||||||
return useCreateApiFormModal({
|
return useCreateApiFormModal({
|
||||||
url: ApiPaths.stock_item_list,
|
url: ApiEndpoints.stock_item_list,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
title: t`Create Stock Item`
|
title: t`Create Stock Item`
|
||||||
});
|
});
|
||||||
@ -125,7 +125,7 @@ export function useEditStockItem({
|
|||||||
const fields = useStockFields({ create: false });
|
const fields = useStockFields({ create: false });
|
||||||
|
|
||||||
return useEditApiFormModal({
|
return useEditApiFormModal({
|
||||||
url: ApiPaths.stock_item_list,
|
url: ApiEndpoints.stock_item_list,
|
||||||
pk: item_id,
|
pk: item_id,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
title: t`Edit Stock Item`,
|
title: t`Edit Stock Item`,
|
||||||
|
@ -4,7 +4,7 @@ import { IconCheck } from '@tabler/icons-react';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { apiUrl, useServerApiState } from '../states/ApiState';
|
import { apiUrl, useServerApiState } from '../states/ApiState';
|
||||||
import { useLocalState } from '../states/LocalState';
|
import { useLocalState } from '../states/LocalState';
|
||||||
import { useSessionState } from '../states/SessionState';
|
import { useSessionState } from '../states/SessionState';
|
||||||
@ -19,7 +19,7 @@ export const doClassicLogin = async (username: string, password: string) => {
|
|||||||
|
|
||||||
// Get token from server
|
// Get token from server
|
||||||
const token = await axios
|
const token = await axios
|
||||||
.get(apiUrl(ApiPaths.user_token), {
|
.get(apiUrl(ApiEndpoints.user_token), {
|
||||||
auth: { username, password },
|
auth: { username, password },
|
||||||
baseURL: host,
|
baseURL: host,
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
@ -54,7 +54,7 @@ export const doClassicLogout = async () => {
|
|||||||
setToken(undefined);
|
setToken(undefined);
|
||||||
|
|
||||||
// Logout from the server session
|
// Logout from the server session
|
||||||
await api.post(apiUrl(ApiPaths.user_logout));
|
await api.post(apiUrl(ApiEndpoints.user_logout));
|
||||||
|
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: t`Logout successful`,
|
title: t`Logout successful`,
|
||||||
@ -69,7 +69,7 @@ export const doClassicLogout = async () => {
|
|||||||
export const doSimpleLogin = async (email: string) => {
|
export const doSimpleLogin = async (email: string) => {
|
||||||
const { host } = useLocalState.getState();
|
const { host } = useLocalState.getState();
|
||||||
const mail = await axios
|
const mail = await axios
|
||||||
.post(apiUrl(ApiPaths.user_simple_login), {
|
.post(apiUrl(ApiEndpoints.user_simple_login), {
|
||||||
email: email
|
email: email
|
||||||
})
|
})
|
||||||
.then((response) => response.data)
|
.then((response) => response.data)
|
||||||
@ -96,7 +96,7 @@ export const doTokenLogin = (token: string) => {
|
|||||||
|
|
||||||
export function handleReset(navigate: any, values: { email: string }) {
|
export function handleReset(navigate: any, values: { email: string }) {
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.user_reset), values, {
|
.post(apiUrl(ApiEndpoints.user_reset), values, {
|
||||||
headers: { Authorization: '' }
|
headers: { Authorization: '' }
|
||||||
})
|
})
|
||||||
.then((val) => {
|
.then((val) => {
|
||||||
@ -127,7 +127,7 @@ export function checkLoginState(
|
|||||||
no_redirect?: boolean
|
no_redirect?: boolean
|
||||||
) {
|
) {
|
||||||
api
|
api
|
||||||
.get(apiUrl(ApiPaths.user_token), {
|
.get(apiUrl(ApiEndpoints.user_token), {
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
params: {
|
params: {
|
||||||
name: 'inventree-web-app'
|
name: 'inventree-web-app'
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
ApiFormFieldType
|
ApiFormFieldType
|
||||||
} from '../components/forms/fields/ApiFormField';
|
} from '../components/forms/fields/ApiFormField';
|
||||||
import { StylishText } from '../components/items/StylishText';
|
import { StylishText } from '../components/items/StylishText';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { PathParams, apiUrl } from '../states/ApiState';
|
import { PathParams, apiUrl } from '../states/ApiState';
|
||||||
import { invalidResponse, permissionDenied } from './notifications';
|
import { invalidResponse, permissionDenied } from './notifications';
|
||||||
import { generateUniqueId } from './uid';
|
import { generateUniqueId } from './uid';
|
||||||
@ -20,7 +20,7 @@ import { generateUniqueId } from './uid';
|
|||||||
* Construct an API url from the provided ApiFormProps object
|
* Construct an API url from the provided ApiFormProps object
|
||||||
*/
|
*/
|
||||||
export function constructFormUrl(
|
export function constructFormUrl(
|
||||||
url: ApiPaths | string,
|
url: ApiEndpoints | string,
|
||||||
pk?: string | number,
|
pk?: string | number,
|
||||||
pathParams?: PathParams
|
pathParams?: PathParams
|
||||||
): string {
|
): string {
|
||||||
|
@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { PathParams, apiUrl } from '../states/ApiState';
|
import { PathParams, apiUrl } from '../states/ApiState';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,7 +25,7 @@ export function useInstance<T = any>({
|
|||||||
refetchOnWindowFocus = false,
|
refetchOnWindowFocus = false,
|
||||||
throwError = false
|
throwError = false
|
||||||
}: {
|
}: {
|
||||||
endpoint: ApiPaths;
|
endpoint: ApiEndpoints;
|
||||||
pk?: string | undefined;
|
pk?: string | undefined;
|
||||||
hasPrimaryKey?: boolean;
|
hasPrimaryKey?: boolean;
|
||||||
params?: any;
|
params?: any;
|
||||||
|
@ -14,7 +14,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
|
|||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { LanguageContext } from '../../contexts/LanguageContext';
|
import { LanguageContext } from '../../contexts/LanguageContext';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
|
|
||||||
export default function Set_Password() {
|
export default function Set_Password() {
|
||||||
@ -58,7 +58,7 @@ export default function Set_Password() {
|
|||||||
// Set password with call to backend
|
// Set password with call to backend
|
||||||
api
|
api
|
||||||
.post(
|
.post(
|
||||||
apiUrl(ApiPaths.user_reset_set),
|
apiUrl(ApiEndpoints.user_reset_set),
|
||||||
{
|
{
|
||||||
uid: uid,
|
uid: uid,
|
||||||
token: token,
|
token: token,
|
||||||
|
@ -8,7 +8,7 @@ import { OptionsApiForm } from '../../components/forms/ApiForm';
|
|||||||
import { PlaceholderPill } from '../../components/items/Placeholder';
|
import { PlaceholderPill } from '../../components/items/Placeholder';
|
||||||
import { StylishText } from '../../components/items/StylishText';
|
import { StylishText } from '../../components/items/StylishText';
|
||||||
import { StatusRenderer } from '../../components/render/StatusRenderer';
|
import { StatusRenderer } from '../../components/render/StatusRenderer';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../enums/ModelType';
|
import { ModelType } from '../../enums/ModelType';
|
||||||
import {
|
import {
|
||||||
createPart,
|
createPart,
|
||||||
@ -28,14 +28,14 @@ import { useCreateApiFormModal } from '../../hooks/UseForm';
|
|||||||
const fields = partCategoryFields({});
|
const fields = partCategoryFields({});
|
||||||
function ApiFormsPlayground() {
|
function ApiFormsPlayground() {
|
||||||
const editCategoryForm: OpenApiFormProps = {
|
const editCategoryForm: OpenApiFormProps = {
|
||||||
url: ApiPaths.category_list,
|
url: ApiEndpoints.category_list,
|
||||||
pk: 2,
|
pk: 2,
|
||||||
title: 'Edit Category',
|
title: 'Edit Category',
|
||||||
fields: fields
|
fields: fields
|
||||||
};
|
};
|
||||||
|
|
||||||
const createAttachmentForm: OpenApiFormProps = {
|
const createAttachmentForm: OpenApiFormProps = {
|
||||||
url: ApiPaths.part_attachment_list,
|
url: ApiEndpoints.part_attachment_list,
|
||||||
title: 'Create Attachment',
|
title: 'Create Attachment',
|
||||||
successMessage: 'Attachment uploaded',
|
successMessage: 'Attachment uploaded',
|
||||||
fields: {
|
fields: {
|
||||||
@ -70,7 +70,7 @@ function ApiFormsPlayground() {
|
|||||||
|
|
||||||
const { modal: createPartModal, open: openCreatePart } =
|
const { modal: createPartModal, open: openCreatePart } =
|
||||||
useCreateApiFormModal({
|
useCreateApiFormModal({
|
||||||
url: ApiPaths.part_list,
|
url: ApiEndpoints.part_list,
|
||||||
title: 'Create part',
|
title: 'Create part',
|
||||||
fields: partFieldsState,
|
fields: partFieldsState,
|
||||||
preFormContent: (
|
preFormContent: (
|
||||||
@ -106,7 +106,7 @@ function ApiFormsPlayground() {
|
|||||||
<Card sx={{ padding: '30px' }}>
|
<Card sx={{ padding: '30px' }}>
|
||||||
<OptionsApiForm
|
<OptionsApiForm
|
||||||
props={{
|
props={{
|
||||||
url: ApiPaths.part_list,
|
url: ApiEndpoints.part_list,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
fields: {
|
fields: {
|
||||||
active: {
|
active: {
|
||||||
|
@ -49,7 +49,7 @@ import { StylishText } from '../../components/items/StylishText';
|
|||||||
import { TitleWithDoc } from '../../components/items/TitleWithDoc';
|
import { TitleWithDoc } from '../../components/items/TitleWithDoc';
|
||||||
import { RenderInstance } from '../../components/render/Instance';
|
import { RenderInstance } from '../../components/render/Instance';
|
||||||
import { ModelInformationDict } from '../../components/render/ModelType';
|
import { ModelInformationDict } from '../../components/render/ModelType';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../enums/ModelType';
|
import { ModelType } from '../../enums/ModelType';
|
||||||
import { notYetImplemented } from '../../functions/notifications';
|
import { notYetImplemented } from '../../functions/notifications';
|
||||||
import { IS_DEV_OR_DEMO } from '../../main';
|
import { IS_DEV_OR_DEMO } from '../../main';
|
||||||
@ -143,7 +143,7 @@ export default function Scan() {
|
|||||||
|
|
||||||
function runBarcode(value: string, id?: string) {
|
function runBarcode(value: string, id?: string) {
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.barcode), { barcode: value })
|
.post(apiUrl(ApiEndpoints.barcode), { barcode: value })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// update item in history
|
// update item in history
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
@ -5,7 +5,7 @@ import { useToggle } from '@mantine/hooks';
|
|||||||
|
|
||||||
import { api } from '../../../../App';
|
import { api } from '../../../../App';
|
||||||
import { EditButton } from '../../../../components/items/EditButton';
|
import { EditButton } from '../../../../components/items/EditButton';
|
||||||
import { ApiPaths } from '../../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../../../states/ApiState';
|
import { apiUrl } from '../../../../states/ApiState';
|
||||||
import { useUserState } from '../../../../states/UserState';
|
import { useUserState } from '../../../../states/UserState';
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ export function AccountDetailPanel() {
|
|||||||
const form = useForm({ initialValues: user });
|
const form = useForm({ initialValues: user });
|
||||||
const [editing, setEditing] = useToggle([false, true] as const);
|
const [editing, setEditing] = useToggle([false, true] as const);
|
||||||
function SaveData(values: any) {
|
function SaveData(values: any) {
|
||||||
api.put(apiUrl(ApiPaths.user_me), values).then((res) => {
|
api.put(apiUrl(ApiEndpoints.user_me), values).then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setEditing();
|
setEditing();
|
||||||
fetchUserState();
|
fetchUserState();
|
||||||
|
@ -19,7 +19,7 @@ import { useEffect, useState } from 'react';
|
|||||||
|
|
||||||
import { api, queryClient } from '../../../../App';
|
import { api, queryClient } from '../../../../App';
|
||||||
import { PlaceholderPill } from '../../../../components/items/Placeholder';
|
import { PlaceholderPill } from '../../../../components/items/Placeholder';
|
||||||
import { ApiPaths } from '../../../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../../../enums/ApiEndpoints';
|
||||||
import { apiUrl } from '../../../../states/ApiState';
|
import { apiUrl } from '../../../../states/ApiState';
|
||||||
import { useUserState } from '../../../../states/UserState';
|
import { useUserState } from '../../../../states/UserState';
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ export function SecurityContent() {
|
|||||||
const { isLoading: isLoadingProvider, data: dataProvider } = useQuery({
|
const { isLoading: isLoadingProvider, data: dataProvider } = useQuery({
|
||||||
queryKey: ['sso-providers'],
|
queryKey: ['sso-providers'],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.get(apiUrl(ApiPaths.sso_providers)).then((res) => res.data)
|
api.get(apiUrl(ApiEndpoints.sso_providers)).then((res) => res.data)
|
||||||
});
|
});
|
||||||
|
|
||||||
// evaluate if security options are enabled
|
// evaluate if security options are enabled
|
||||||
@ -95,10 +95,11 @@ function EmailContent({}: {}) {
|
|||||||
const [user] = useUserState((state) => [state.user]);
|
const [user] = useUserState((state) => [state.user]);
|
||||||
const { isLoading, data, refetch } = useQuery({
|
const { isLoading, data, refetch } = useQuery({
|
||||||
queryKey: ['emails'],
|
queryKey: ['emails'],
|
||||||
queryFn: () => api.get(apiUrl(ApiPaths.user_emails)).then((res) => res.data)
|
queryFn: () =>
|
||||||
|
api.get(apiUrl(ApiEndpoints.user_emails)).then((res) => res.data)
|
||||||
});
|
});
|
||||||
|
|
||||||
function runServerAction(url: ApiPaths) {
|
function runServerAction(url: ApiEndpoints) {
|
||||||
api
|
api
|
||||||
.post(apiUrl(url, undefined, { id: value }), {})
|
.post(apiUrl(url, undefined, { id: value }), {})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -109,7 +110,7 @@ function EmailContent({}: {}) {
|
|||||||
|
|
||||||
function addEmail() {
|
function addEmail() {
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.user_emails), {
|
.post(apiUrl(ApiEndpoints.user_emails), {
|
||||||
email: newEmailValue,
|
email: newEmailValue,
|
||||||
user: user?.pk
|
user: user?.pk
|
||||||
})
|
})
|
||||||
@ -175,13 +176,19 @@ function EmailContent({}: {}) {
|
|||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<Group>
|
<Group>
|
||||||
<Button onClick={() => runServerAction(ApiPaths.user_email_primary)}>
|
<Button
|
||||||
|
onClick={() => runServerAction(ApiEndpoints.user_email_primary)}
|
||||||
|
>
|
||||||
<Trans>Make Primary</Trans>
|
<Trans>Make Primary</Trans>
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => runServerAction(ApiPaths.user_email_verify)}>
|
<Button
|
||||||
|
onClick={() => runServerAction(ApiEndpoints.user_email_verify)}
|
||||||
|
>
|
||||||
<Trans>Re-send Verification</Trans>
|
<Trans>Re-send Verification</Trans>
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => runServerAction(ApiPaths.user_email_remove)}>
|
<Button
|
||||||
|
onClick={() => runServerAction(ApiEndpoints.user_email_remove)}
|
||||||
|
>
|
||||||
<Trans>Remove</Trans>
|
<Trans>Remove</Trans>
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
@ -200,7 +207,8 @@ function SsoContent({ dataProvider }: { dataProvider: any | undefined }) {
|
|||||||
const [currentProviders, setcurrentProviders] = useState<[]>();
|
const [currentProviders, setcurrentProviders] = useState<[]>();
|
||||||
const { isLoading, data } = useQuery({
|
const { isLoading, data } = useQuery({
|
||||||
queryKey: ['sso-list'],
|
queryKey: ['sso-list'],
|
||||||
queryFn: () => api.get(apiUrl(ApiPaths.user_sso)).then((res) => res.data)
|
queryFn: () =>
|
||||||
|
api.get(apiUrl(ApiEndpoints.user_sso)).then((res) => res.data)
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -222,7 +230,7 @@ function SsoContent({ dataProvider }: { dataProvider: any | undefined }) {
|
|||||||
|
|
||||||
function removeProvider() {
|
function removeProvider() {
|
||||||
api
|
api
|
||||||
.post(apiUrl(ApiPaths.user_sso_remove, undefined, { id: value }))
|
.post(apiUrl(ApiEndpoints.user_sso_remove, undefined, { id: value }))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
queryClient.removeQueries({
|
queryClient.removeQueries({
|
||||||
queryKey: ['sso-list']
|
queryKey: ['sso-list']
|
||||||
|
@ -13,7 +13,7 @@ import { api } from '../App';
|
|||||||
import { PageDetail } from '../components/nav/PageDetail';
|
import { PageDetail } from '../components/nav/PageDetail';
|
||||||
import { PanelGroup } from '../components/nav/PanelGroup';
|
import { PanelGroup } from '../components/nav/PanelGroup';
|
||||||
import { NotificationTable } from '../components/tables/notifications/NotificationsTable';
|
import { NotificationTable } from '../components/tables/notifications/NotificationsTable';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { useTable } from '../hooks/UseTable';
|
import { useTable } from '../hooks/UseTable';
|
||||||
import { apiUrl } from '../states/ApiState';
|
import { apiUrl } from '../states/ApiState';
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export default function NotificationsPage() {
|
|||||||
color: 'green',
|
color: 'green',
|
||||||
icon: <IconCircleCheck />,
|
icon: <IconCircleCheck />,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
let url = apiUrl(ApiPaths.notifications_list, record.pk);
|
let url = apiUrl(ApiEndpoints.notifications_list, record.pk);
|
||||||
api
|
api
|
||||||
.patch(url, {
|
.patch(url, {
|
||||||
read: true
|
read: true
|
||||||
@ -64,7 +64,7 @@ export default function NotificationsPage() {
|
|||||||
title: t`Mark as unread`,
|
title: t`Mark as unread`,
|
||||||
icon: <IconCircleX />,
|
icon: <IconCircleX />,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
let url = apiUrl(ApiPaths.notifications_list, record.pk);
|
let url = apiUrl(ApiEndpoints.notifications_list, record.pk);
|
||||||
|
|
||||||
api
|
api
|
||||||
.patch(url, {
|
.patch(url, {
|
||||||
@ -81,7 +81,7 @@ export default function NotificationsPage() {
|
|||||||
icon: <IconTrash />,
|
icon: <IconTrash />,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
api
|
api
|
||||||
.delete(apiUrl(ApiPaths.notifications_list, record.pk))
|
.delete(apiUrl(ApiEndpoints.notifications_list, record.pk))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
readTable.refreshTable();
|
readTable.refreshTable();
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,7 @@ import { BuildOrderTable } from '../../components/tables/build/BuildOrderTable';
|
|||||||
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../enums/ModelType';
|
import { ModelType } from '../../enums/ModelType';
|
||||||
import { buildOrderFields } from '../../forms/BuildForms';
|
import { buildOrderFields } from '../../forms/BuildForms';
|
||||||
import { openEditApiForm } from '../../functions/forms';
|
import { openEditApiForm } from '../../functions/forms';
|
||||||
@ -55,7 +55,7 @@ export default function BuildDetail() {
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.build_order_list,
|
endpoint: ApiEndpoints.build_order_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
part_detail: true
|
part_detail: true
|
||||||
@ -166,7 +166,7 @@ export default function BuildDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.build_order_attachment_list}
|
endpoint={ApiEndpoints.build_order_attachment_list}
|
||||||
model="build"
|
model="build"
|
||||||
pk={Number(id)}
|
pk={Number(id)}
|
||||||
/>
|
/>
|
||||||
@ -178,7 +178,7 @@ export default function BuildDetail() {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.build_order_list, build.pk)}
|
url={apiUrl(ApiEndpoints.build_order_list, build.pk)}
|
||||||
data={build.notes ?? ''}
|
data={build.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
@ -195,7 +195,7 @@ export default function BuildDetail() {
|
|||||||
|
|
||||||
build.pk &&
|
build.pk &&
|
||||||
openEditApiForm({
|
openEditApiForm({
|
||||||
url: ApiPaths.build_order_list,
|
url: ApiEndpoints.build_order_list,
|
||||||
pk: build.pk,
|
pk: build.pk,
|
||||||
title: t`Edit Build Order`,
|
title: t`Edit Build Order`,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Button, Stack, Text } from '@mantine/core';
|
import { Button, Stack } from '@mantine/core';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { PageDetail } from '../../components/nav/PageDetail';
|
import { PageDetail } from '../../components/nav/PageDetail';
|
||||||
import { BuildOrderTable } from '../../components/tables/build/BuildOrderTable';
|
import { BuildOrderTable } from '../../components/tables/build/BuildOrderTable';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { buildOrderFields } from '../../forms/BuildForms';
|
import { buildOrderFields } from '../../forms/BuildForms';
|
||||||
import { openCreateApiForm } from '../../functions/forms';
|
import { openCreateApiForm } from '../../functions/forms';
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ export default function BuildIndex() {
|
|||||||
|
|
||||||
const newBuildOrder = useCallback(() => {
|
const newBuildOrder = useCallback(() => {
|
||||||
openCreateApiForm({
|
openCreateApiForm({
|
||||||
url: ApiPaths.build_order_list,
|
url: ApiEndpoints.build_order_list,
|
||||||
title: t`Add Build Order`,
|
title: t`Add Build Order`,
|
||||||
fields: buildOrderFields(),
|
fields: buildOrderFields(),
|
||||||
successMessage: t`Build order created`,
|
successMessage: t`Build order created`,
|
||||||
|
@ -37,7 +37,7 @@ import { ReturnOrderTable } from '../../components/tables/sales/ReturnOrderTable
|
|||||||
import { SalesOrderTable } from '../../components/tables/sales/SalesOrderTable';
|
import { SalesOrderTable } from '../../components/tables/sales/SalesOrderTable';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../enums/Roles';
|
import { UserRoles } from '../../enums/Roles';
|
||||||
import { editCompany } from '../../forms/CompanyForms';
|
import { editCompany } from '../../forms/CompanyForms';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
@ -62,7 +62,7 @@ export default function CompanyDetail(props: CompanyDetailProps) {
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.company_list,
|
endpoint: ApiEndpoints.company_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {},
|
params: {},
|
||||||
refetchOnMount: true
|
refetchOnMount: true
|
||||||
@ -158,7 +158,7 @@ export default function CompanyDetail(props: CompanyDetailProps) {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.company_attachment_list}
|
endpoint={ApiEndpoints.company_attachment_list}
|
||||||
model="company"
|
model="company"
|
||||||
pk={company.pk ?? -1}
|
pk={company.pk ?? -1}
|
||||||
/>
|
/>
|
||||||
@ -170,7 +170,7 @@ export default function CompanyDetail(props: CompanyDetailProps) {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.company_list, company.pk)}
|
url={apiUrl(ApiEndpoints.company_list, company.pk)}
|
||||||
data={company?.notes ?? ''}
|
data={company?.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
|
@ -14,14 +14,14 @@ import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
|||||||
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
||||||
import ManufacturerPartParameterTable from '../../components/tables/purchasing/ManufacturerPartParameterTable';
|
import ManufacturerPartParameterTable from '../../components/tables/purchasing/ManufacturerPartParameterTable';
|
||||||
import { SupplierPartTable } from '../../components/tables/purchasing/SupplierPartTable';
|
import { SupplierPartTable } from '../../components/tables/purchasing/SupplierPartTable';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
|
|
||||||
export default function ManufacturerPartDetail() {
|
export default function ManufacturerPartDetail() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const { instance: manufacturerPart, instanceQuery } = useInstance({
|
const { instance: manufacturerPart, instanceQuery } = useInstance({
|
||||||
endpoint: ApiPaths.manufacturer_part_list,
|
endpoint: ApiEndpoints.manufacturer_part_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
hasPrimaryKey: true,
|
hasPrimaryKey: true,
|
||||||
params: {
|
params: {
|
||||||
@ -69,7 +69,7 @@ export default function ManufacturerPartDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.manufacturer_part_attachment_list}
|
endpoint={ApiEndpoints.manufacturer_part_attachment_list}
|
||||||
model="manufacturer_part"
|
model="manufacturer_part"
|
||||||
pk={manufacturerPart?.pk}
|
pk={manufacturerPart?.pk}
|
||||||
/>
|
/>
|
||||||
|
@ -12,14 +12,14 @@ import { useParams } from 'react-router-dom';
|
|||||||
import { PageDetail } from '../../components/nav/PageDetail';
|
import { PageDetail } from '../../components/nav/PageDetail';
|
||||||
import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
||||||
import { PurchaseOrderTable } from '../../components/tables/purchasing/PurchaseOrderTable';
|
import { PurchaseOrderTable } from '../../components/tables/purchasing/PurchaseOrderTable';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
|
|
||||||
export default function SupplierPartDetail() {
|
export default function SupplierPartDetail() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const { instance: supplierPart, instanceQuery } = useInstance({
|
const { instance: supplierPart, instanceQuery } = useInstance({
|
||||||
endpoint: ApiPaths.supplier_part_list,
|
endpoint: ApiEndpoints.supplier_part_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
hasPrimaryKey: true,
|
hasPrimaryKey: true,
|
||||||
params: {
|
params: {
|
||||||
|
@ -14,7 +14,7 @@ import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
|||||||
import { PartCategoryTree } from '../../components/nav/PartCategoryTree';
|
import { PartCategoryTree } from '../../components/nav/PartCategoryTree';
|
||||||
import { PartCategoryTable } from '../../components/tables/part/PartCategoryTable';
|
import { PartCategoryTable } from '../../components/tables/part/PartCategoryTable';
|
||||||
import { PartListTable } from '../../components/tables/part/PartTable';
|
import { PartListTable } from '../../components/tables/part/PartTable';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,7 +36,7 @@ export default function CategoryDetail({}: {}) {
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.category_list,
|
endpoint: ApiEndpoints.category_list,
|
||||||
hasPrimaryKey: true,
|
hasPrimaryKey: true,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
|
@ -52,7 +52,7 @@ import { SupplierPartTable } from '../../components/tables/purchasing/SupplierPa
|
|||||||
import { SalesOrderTable } from '../../components/tables/sales/SalesOrderTable';
|
import { SalesOrderTable } from '../../components/tables/sales/SalesOrderTable';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { editPart } from '../../forms/PartForms';
|
import { editPart } from '../../forms/PartForms';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
@ -73,7 +73,7 @@ export default function PartDetail() {
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.part_list,
|
endpoint: ApiEndpoints.part_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
path_detail: true
|
path_detail: true
|
||||||
@ -233,7 +233,7 @@ export default function PartDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.part_attachment_list}
|
endpoint={ApiEndpoints.part_attachment_list}
|
||||||
model="part"
|
model="part"
|
||||||
pk={part.pk ?? -1}
|
pk={part.pk ?? -1}
|
||||||
/>
|
/>
|
||||||
@ -245,7 +245,7 @@ export default function PartDetail() {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.part_list, part.pk)}
|
url={apiUrl(ApiEndpoints.part_list, part.pk)}
|
||||||
data={part.notes ?? ''}
|
data={part.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
|
@ -26,7 +26,7 @@ import { AttachmentTable } from '../../components/tables/general/AttachmentTable
|
|||||||
import { PurchaseOrderLineItemTable } from '../../components/tables/purchasing/PurchaseOrderLineItemTable';
|
import { PurchaseOrderLineItemTable } from '../../components/tables/purchasing/PurchaseOrderLineItemTable';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
@ -40,7 +40,7 @@ export default function PurchaseOrderDetail() {
|
|||||||
const user = useUserState();
|
const user = useUserState();
|
||||||
|
|
||||||
const { instance: order, instanceQuery } = useInstance({
|
const { instance: order, instanceQuery } = useInstance({
|
||||||
endpoint: ApiPaths.purchase_order_list,
|
endpoint: ApiEndpoints.purchase_order_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
supplier_detail: true
|
supplier_detail: true
|
||||||
@ -79,7 +79,7 @@ export default function PurchaseOrderDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.purchase_order_attachment_list}
|
endpoint={ApiEndpoints.purchase_order_attachment_list}
|
||||||
model="order"
|
model="order"
|
||||||
pk={Number(id)}
|
pk={Number(id)}
|
||||||
/>
|
/>
|
||||||
@ -91,7 +91,7 @@ export default function PurchaseOrderDetail() {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.purchase_order_list, id)}
|
url={apiUrl(ApiEndpoints.purchase_order_list, id)}
|
||||||
data={order.notes ?? ''}
|
data={order.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
|
@ -8,7 +8,7 @@ import { PageDetail } from '../../components/nav/PageDetail';
|
|||||||
import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
||||||
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export default function ReturnOrderDetail() {
|
|||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const { instance: order, instanceQuery } = useInstance({
|
const { instance: order, instanceQuery } = useInstance({
|
||||||
endpoint: ApiPaths.return_order_list,
|
endpoint: ApiEndpoints.return_order_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
customer_detail: true
|
customer_detail: true
|
||||||
@ -39,7 +39,7 @@ export default function ReturnOrderDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.return_order_attachment_list}
|
endpoint={ApiEndpoints.return_order_attachment_list}
|
||||||
model="order"
|
model="order"
|
||||||
pk={Number(id)}
|
pk={Number(id)}
|
||||||
/>
|
/>
|
||||||
@ -51,7 +51,7 @@ export default function ReturnOrderDetail() {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.return_order_list, id)}
|
url={apiUrl(ApiEndpoints.return_order_list, id)}
|
||||||
data={order.notes ?? ''}
|
data={order.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
|
@ -17,7 +17,7 @@ import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
|||||||
import { BuildOrderTable } from '../../components/tables/build/BuildOrderTable';
|
import { BuildOrderTable } from '../../components/tables/build/BuildOrderTable';
|
||||||
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ export default function SalesOrderDetail() {
|
|||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const { instance: order, instanceQuery } = useInstance({
|
const { instance: order, instanceQuery } = useInstance({
|
||||||
endpoint: ApiPaths.sales_order_list,
|
endpoint: ApiEndpoints.sales_order_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
customer_detail: true
|
customer_detail: true
|
||||||
@ -77,7 +77,7 @@ export default function SalesOrderDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.sales_order_attachment_list}
|
endpoint={ApiEndpoints.sales_order_attachment_list}
|
||||||
model="order"
|
model="order"
|
||||||
pk={Number(id)}
|
pk={Number(id)}
|
||||||
/>
|
/>
|
||||||
@ -89,7 +89,7 @@ export default function SalesOrderDetail() {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.sales_order_list, id)}
|
url={apiUrl(ApiEndpoints.sales_order_list, id)}
|
||||||
data={order.notes ?? ''}
|
data={order.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
|
@ -9,7 +9,7 @@ import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
|||||||
import { StockLocationTree } from '../../components/nav/StockLocationTree';
|
import { StockLocationTree } from '../../components/nav/StockLocationTree';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import { StockLocationTable } from '../../components/tables/stock/StockLocationTable';
|
import { StockLocationTable } from '../../components/tables/stock/StockLocationTable';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
|
|
||||||
export default function Stock() {
|
export default function Stock() {
|
||||||
@ -27,7 +27,7 @@ export default function Stock() {
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.stock_location_list,
|
endpoint: ApiEndpoints.stock_location_list,
|
||||||
hasPrimaryKey: true,
|
hasPrimaryKey: true,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
|
@ -36,7 +36,7 @@ import { StockLocationTree } from '../../components/nav/StockLocationTree';
|
|||||||
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
import { AttachmentTable } from '../../components/tables/general/AttachmentTable';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
import { ApiPaths } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useEditStockItem } from '../../forms/StockForms';
|
import { useEditStockItem } from '../../forms/StockForms';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
@ -54,7 +54,7 @@ export default function StockDetail() {
|
|||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance({
|
} = useInstance({
|
||||||
endpoint: ApiPaths.stock_item_list,
|
endpoint: ApiEndpoints.stock_item_list,
|
||||||
pk: id,
|
pk: id,
|
||||||
params: {
|
params: {
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
@ -114,7 +114,7 @@ export default function StockDetail() {
|
|||||||
icon: <IconPaperclip />,
|
icon: <IconPaperclip />,
|
||||||
content: (
|
content: (
|
||||||
<AttachmentTable
|
<AttachmentTable
|
||||||
endpoint={ApiPaths.stock_attachment_list}
|
endpoint={ApiEndpoints.stock_attachment_list}
|
||||||
model="stock_item"
|
model="stock_item"
|
||||||
pk={Number(id)}
|
pk={Number(id)}
|
||||||
/>
|
/>
|
||||||
@ -126,7 +126,7 @@ export default function StockDetail() {
|
|||||||
icon: <IconNotes />,
|
icon: <IconNotes />,
|
||||||
content: (
|
content: (
|
||||||
<NotesEditor
|
<NotesEditor
|
||||||
url={apiUrl(ApiPaths.stock_item_list, id)}
|
url={apiUrl(ApiEndpoints.stock_item_list, id)}
|
||||||
data={stockitem.notes ?? ''}
|
data={stockitem.notes ?? ''}
|
||||||
allowEdit={true}
|
allowEdit={true}
|
||||||
/>
|
/>
|
||||||
|
@ -5,7 +5,7 @@ import { api } from '../App';
|
|||||||
import { StatusCodeListInterface } from '../components/render/StatusRenderer';
|
import { StatusCodeListInterface } from '../components/render/StatusRenderer';
|
||||||
import { statusCodeList } from '../defaults/backendMappings';
|
import { statusCodeList } from '../defaults/backendMappings';
|
||||||
import { emptyServerAPI } from '../defaults/defaults';
|
import { emptyServerAPI } from '../defaults/defaults';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../enums/ModelType';
|
import { ModelType } from '../enums/ModelType';
|
||||||
import { AuthProps, ServerAPIProps } from './states';
|
import { AuthProps, ServerAPIProps } from './states';
|
||||||
|
|
||||||
@ -27,14 +27,14 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
|||||||
fetchServerApiState: async () => {
|
fetchServerApiState: async () => {
|
||||||
// Fetch server data
|
// Fetch server data
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.api_server_info))
|
.get(ApiEndpoints.api_server_info)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
set({ server: response.data });
|
set({ server: response.data });
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
// Fetch status data for rendering labels
|
// Fetch status data for rendering labels
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.global_status))
|
.get(ApiEndpoints.global_status)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const newStatusLookup: StatusLookup = {} as StatusLookup;
|
const newStatusLookup: StatusLookup = {} as StatusLookup;
|
||||||
for (const key in response.data) {
|
for (const key in response.data) {
|
||||||
@ -47,7 +47,7 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
|||||||
|
|
||||||
// Fetch login/SSO behaviour
|
// Fetch login/SSO behaviour
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.sso_providers), {
|
.get(ApiEndpoints.sso_providers, {
|
||||||
headers: { Authorization: '' }
|
headers: { Authorization: '' }
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -72,182 +72,17 @@ export function apiPrefix(): string {
|
|||||||
return '/api/';
|
return '/api/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the endpoint associated with a given API path
|
|
||||||
*/
|
|
||||||
export function apiEndpoint(path: ApiPaths): string {
|
|
||||||
switch (path) {
|
|
||||||
case ApiPaths.api_server_info:
|
|
||||||
return '';
|
|
||||||
case ApiPaths.user_list:
|
|
||||||
return 'user/';
|
|
||||||
case ApiPaths.owner_list:
|
|
||||||
return 'user/owner/';
|
|
||||||
case ApiPaths.user_me:
|
|
||||||
return 'user/me/';
|
|
||||||
case ApiPaths.user_roles:
|
|
||||||
return 'user/roles/';
|
|
||||||
case ApiPaths.user_token:
|
|
||||||
return 'user/token/';
|
|
||||||
case ApiPaths.user_simple_login:
|
|
||||||
return 'email/generate/';
|
|
||||||
case ApiPaths.user_reset:
|
|
||||||
// Note leading prefix here
|
|
||||||
return 'auth/password/reset/';
|
|
||||||
case ApiPaths.user_reset_set:
|
|
||||||
// Note leading prefix here
|
|
||||||
return 'auth/password/reset/confirm/';
|
|
||||||
case ApiPaths.user_sso:
|
|
||||||
return 'auth/social/';
|
|
||||||
case ApiPaths.user_sso_remove:
|
|
||||||
return 'auth/social/:id/disconnect/';
|
|
||||||
case ApiPaths.user_emails:
|
|
||||||
return 'auth/emails/';
|
|
||||||
case ApiPaths.user_email_remove:
|
|
||||||
return 'auth/emails/:id/remove/';
|
|
||||||
case ApiPaths.user_email_verify:
|
|
||||||
return 'auth/emails/:id/verify/';
|
|
||||||
case ApiPaths.user_email_primary:
|
|
||||||
return 'auth/emails/:id/primary/';
|
|
||||||
case ApiPaths.user_logout:
|
|
||||||
return 'auth/logout/';
|
|
||||||
case ApiPaths.user_register:
|
|
||||||
return 'auth/registration/';
|
|
||||||
case ApiPaths.currency_list:
|
|
||||||
return 'currency/exchange/';
|
|
||||||
case ApiPaths.currency_refresh:
|
|
||||||
return 'currency/refresh/';
|
|
||||||
case ApiPaths.task_overview:
|
|
||||||
return 'background-task/';
|
|
||||||
case ApiPaths.task_pending_list:
|
|
||||||
return 'background-task/pending/';
|
|
||||||
case ApiPaths.task_scheduled_list:
|
|
||||||
return 'background-task/scheduled/';
|
|
||||||
case ApiPaths.task_failed_list:
|
|
||||||
return 'background-task/failed/';
|
|
||||||
case ApiPaths.api_search:
|
|
||||||
return 'search/';
|
|
||||||
case ApiPaths.settings_global_list:
|
|
||||||
return 'settings/global/';
|
|
||||||
case ApiPaths.settings_user_list:
|
|
||||||
return 'settings/user/';
|
|
||||||
case ApiPaths.notifications_list:
|
|
||||||
return 'notifications/';
|
|
||||||
case ApiPaths.barcode:
|
|
||||||
return 'barcode/';
|
|
||||||
case ApiPaths.news:
|
|
||||||
return 'news/';
|
|
||||||
case ApiPaths.global_status:
|
|
||||||
return 'generic/status/';
|
|
||||||
case ApiPaths.version:
|
|
||||||
return 'version/';
|
|
||||||
case ApiPaths.sso_providers:
|
|
||||||
return 'auth/providers/';
|
|
||||||
case ApiPaths.group_list:
|
|
||||||
return 'user/group/';
|
|
||||||
case ApiPaths.owner_list:
|
|
||||||
return 'user/owner/';
|
|
||||||
case ApiPaths.build_order_list:
|
|
||||||
return 'build/';
|
|
||||||
case ApiPaths.build_order_attachment_list:
|
|
||||||
return 'build/attachment/';
|
|
||||||
case ApiPaths.build_line_list:
|
|
||||||
return 'build/line/';
|
|
||||||
case ApiPaths.bom_list:
|
|
||||||
return 'bom/';
|
|
||||||
case ApiPaths.part_list:
|
|
||||||
return 'part/';
|
|
||||||
case ApiPaths.part_parameter_list:
|
|
||||||
return 'part/parameter/';
|
|
||||||
case ApiPaths.part_parameter_template_list:
|
|
||||||
return 'part/parameter/template/';
|
|
||||||
case ApiPaths.category_list:
|
|
||||||
return 'part/category/';
|
|
||||||
case ApiPaths.category_tree:
|
|
||||||
return 'part/category/tree/';
|
|
||||||
case ApiPaths.related_part_list:
|
|
||||||
return 'part/related/';
|
|
||||||
case ApiPaths.part_attachment_list:
|
|
||||||
return 'part/attachment/';
|
|
||||||
case ApiPaths.part_test_template_list:
|
|
||||||
return 'part/test-template/';
|
|
||||||
case ApiPaths.company_list:
|
|
||||||
return 'company/';
|
|
||||||
case ApiPaths.contact_list:
|
|
||||||
return 'company/contact/';
|
|
||||||
case ApiPaths.address_list:
|
|
||||||
return 'company/address/';
|
|
||||||
case ApiPaths.company_attachment_list:
|
|
||||||
return 'company/attachment/';
|
|
||||||
case ApiPaths.supplier_part_list:
|
|
||||||
return 'company/part/';
|
|
||||||
case ApiPaths.manufacturer_part_list:
|
|
||||||
return 'company/part/manufacturer/';
|
|
||||||
case ApiPaths.manufacturer_part_attachment_list:
|
|
||||||
return 'company/part/manufacturer/attachment/';
|
|
||||||
case ApiPaths.manufacturer_part_parameter_list:
|
|
||||||
return 'company/part/manufacturer/parameter/';
|
|
||||||
case ApiPaths.stock_item_list:
|
|
||||||
return 'stock/';
|
|
||||||
case ApiPaths.stock_tracking_list:
|
|
||||||
return 'stock/track/';
|
|
||||||
case ApiPaths.stock_location_list:
|
|
||||||
return 'stock/location/';
|
|
||||||
case ApiPaths.stock_location_tree:
|
|
||||||
return 'stock/location/tree/';
|
|
||||||
case ApiPaths.stock_attachment_list:
|
|
||||||
return 'stock/attachment/';
|
|
||||||
case ApiPaths.purchase_order_list:
|
|
||||||
return 'order/po/';
|
|
||||||
case ApiPaths.purchase_order_line_list:
|
|
||||||
return 'order/po-line/';
|
|
||||||
case ApiPaths.purchase_order_attachment_list:
|
|
||||||
return 'order/po/attachment/';
|
|
||||||
case ApiPaths.sales_order_list:
|
|
||||||
return 'order/so/';
|
|
||||||
case ApiPaths.sales_order_attachment_list:
|
|
||||||
return 'order/so/attachment/';
|
|
||||||
case ApiPaths.sales_order_shipment_list:
|
|
||||||
return 'order/so/shipment/';
|
|
||||||
case ApiPaths.return_order_list:
|
|
||||||
return 'order/ro/';
|
|
||||||
case ApiPaths.return_order_attachment_list:
|
|
||||||
return 'order/ro/attachment/';
|
|
||||||
case ApiPaths.plugin_list:
|
|
||||||
return 'plugins/';
|
|
||||||
case ApiPaths.plugin_setting_list:
|
|
||||||
return 'plugins/:plugin/settings/';
|
|
||||||
case ApiPaths.plugin_registry_status:
|
|
||||||
return 'plugins/status/';
|
|
||||||
case ApiPaths.plugin_install:
|
|
||||||
return 'plugins/install/';
|
|
||||||
case ApiPaths.plugin_reload:
|
|
||||||
return 'plugins/reload/';
|
|
||||||
case ApiPaths.error_report_list:
|
|
||||||
return 'error-report/';
|
|
||||||
case ApiPaths.project_code_list:
|
|
||||||
return 'project-code/';
|
|
||||||
case ApiPaths.custom_unit_list:
|
|
||||||
return 'units/';
|
|
||||||
default:
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PathParams = Record<string, string | number>;
|
export type PathParams = Record<string, string | number>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an API URL with an endpoint and (optional) pk value
|
* Construct an API URL with an endpoint and (optional) pk value
|
||||||
*/
|
*/
|
||||||
export function apiUrl(
|
export function apiUrl(
|
||||||
path: ApiPaths | string,
|
endpoint: ApiEndpoints | string,
|
||||||
pk?: any,
|
pk?: any,
|
||||||
pathParams?: PathParams
|
pathParams?: PathParams
|
||||||
): string {
|
): string {
|
||||||
let _url = path;
|
let _url = endpoint;
|
||||||
if (Object.values(ApiPaths).includes(path as ApiPaths)) {
|
|
||||||
_url = apiEndpoint(path as ApiPaths);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the URL does not start with a '/', add the API prefix
|
// If the URL does not start with a '/', add the API prefix
|
||||||
if (!_url.startsWith('/')) {
|
if (!_url.startsWith('/')) {
|
||||||
@ -255,8 +90,12 @@ export function apiUrl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_url && pk) {
|
if (_url && pk) {
|
||||||
|
if (_url.indexOf(':id') >= 0) {
|
||||||
|
_url = _url.replace(':id', `${pk}`);
|
||||||
|
} else {
|
||||||
_url += `${pk}/`;
|
_url += `${pk}/`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_url && pathParams) {
|
if (_url && pathParams) {
|
||||||
for (const key in pathParams) {
|
for (const key in pathParams) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { create, createStore } from 'zustand';
|
import { create, createStore } from 'zustand';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { isTrue } from '../functions/conversion';
|
import { isTrue } from '../functions/conversion';
|
||||||
import { PathParams, apiUrl } from './ApiState';
|
import { PathParams, apiUrl } from './ApiState';
|
||||||
import { Setting, SettingsLookup } from './states';
|
import { Setting, SettingsLookup } from './states';
|
||||||
@ -13,7 +13,7 @@ export interface SettingsStateProps {
|
|||||||
settings: Setting[];
|
settings: Setting[];
|
||||||
lookup: SettingsLookup;
|
lookup: SettingsLookup;
|
||||||
fetchSettings: () => void;
|
fetchSettings: () => void;
|
||||||
endpoint: ApiPaths;
|
endpoint: ApiEndpoints;
|
||||||
pathParams?: PathParams;
|
pathParams?: PathParams;
|
||||||
getSetting: (key: string, default_value?: string) => string; // Return a raw setting value
|
getSetting: (key: string, default_value?: string) => string; // Return a raw setting value
|
||||||
isSet: (key: string, default_value?: boolean) => boolean; // Check a "boolean" setting
|
isSet: (key: string, default_value?: boolean) => boolean; // Check a "boolean" setting
|
||||||
@ -26,10 +26,10 @@ export const useGlobalSettingsState = create<SettingsStateProps>(
|
|||||||
(set, get) => ({
|
(set, get) => ({
|
||||||
settings: [],
|
settings: [],
|
||||||
lookup: {},
|
lookup: {},
|
||||||
endpoint: ApiPaths.settings_global_list,
|
endpoint: ApiEndpoints.settings_global_list,
|
||||||
fetchSettings: async () => {
|
fetchSettings: async () => {
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.settings_global_list))
|
.get(apiUrl(ApiEndpoints.settings_global_list))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
set({
|
set({
|
||||||
settings: response.data,
|
settings: response.data,
|
||||||
@ -56,10 +56,10 @@ export const useGlobalSettingsState = create<SettingsStateProps>(
|
|||||||
export const useUserSettingsState = create<SettingsStateProps>((set, get) => ({
|
export const useUserSettingsState = create<SettingsStateProps>((set, get) => ({
|
||||||
settings: [],
|
settings: [],
|
||||||
lookup: {},
|
lookup: {},
|
||||||
endpoint: ApiPaths.settings_user_list,
|
endpoint: ApiEndpoints.settings_user_list,
|
||||||
fetchSettings: async () => {
|
fetchSettings: async () => {
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.settings_user_list))
|
.get(apiUrl(ApiEndpoints.settings_user_list))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
set({
|
set({
|
||||||
settings: response.data,
|
settings: response.data,
|
||||||
@ -94,11 +94,11 @@ export const createPluginSettingsState = ({
|
|||||||
return createStore<SettingsStateProps>()((set, get) => ({
|
return createStore<SettingsStateProps>()((set, get) => ({
|
||||||
settings: [],
|
settings: [],
|
||||||
lookup: {},
|
lookup: {},
|
||||||
endpoint: ApiPaths.plugin_setting_list,
|
endpoint: ApiEndpoints.plugin_setting_list,
|
||||||
pathParams,
|
pathParams,
|
||||||
fetchSettings: async () => {
|
fetchSettings: async () => {
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.plugin_setting_list, undefined, { plugin }))
|
.get(apiUrl(ApiEndpoints.plugin_setting_list, undefined, { plugin }))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const settings = response.data;
|
const settings = response.data;
|
||||||
set({
|
set({
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
import { ApiPaths } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import { UserPermissions, UserRoles } from '../enums/Roles';
|
import { UserPermissions, UserRoles } from '../enums/Roles';
|
||||||
import { doClassicLogout } from '../functions/auth';
|
import { doClassicLogout } from '../functions/auth';
|
||||||
import { apiUrl } from './ApiState';
|
import { apiUrl } from './ApiState';
|
||||||
@ -37,7 +37,7 @@ export const useUserState = create<UserStateProps>((set, get) => ({
|
|||||||
fetchUserState: async () => {
|
fetchUserState: async () => {
|
||||||
// Fetch user data
|
// Fetch user data
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.user_me), {
|
.get(apiUrl(ApiEndpoints.user_me), {
|
||||||
timeout: 2000
|
timeout: 2000
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -58,7 +58,7 @@ export const useUserState = create<UserStateProps>((set, get) => ({
|
|||||||
|
|
||||||
// Fetch role data
|
// Fetch role data
|
||||||
await api
|
await api
|
||||||
.get(apiUrl(ApiPaths.user_roles))
|
.get(apiUrl(ApiEndpoints.user_roles))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const user: UserProps = get().user as UserProps;
|
const user: UserProps = get().user as UserProps;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user