mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
API URL fixes (#6381)
- Part of https://github.com/inventree/InvenTree/issues/5697 - Cherry picking just the API fixes
This commit is contained in:
parent
e1e63fa644
commit
9197517f38
@ -19,7 +19,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { doClassicLogin, doSimpleLogin } from '../../functions/auth';
|
import { doClassicLogin, doSimpleLogin } from '../../functions/auth';
|
||||||
import { useServerApiState } from '../../states/ApiState';
|
import { apiUrl, 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(ApiEndpoints.user_register, registrationForm.values, {
|
.post(apiUrl(ApiEndpoints.user_register), registrationForm.values, {
|
||||||
headers: { Authorization: '' }
|
headers: { Authorization: '' }
|
||||||
})
|
})
|
||||||
.then((ret) => {
|
.then((ret) => {
|
||||||
|
@ -16,7 +16,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { useServerApiState } from '../../states/ApiState';
|
import { apiUrl, 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(ApiEndpoints.version).then((res) => res.data)
|
queryFn: () => api.get(apiUrl(ApiEndpoints.version)).then((res) => res.data)
|
||||||
});
|
});
|
||||||
|
|
||||||
function fillTable(
|
function fillTable(
|
||||||
|
@ -24,6 +24,7 @@ import { useEffect, useState } from 'react';
|
|||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
|
import { apiUrl } from '../../states/ApiState';
|
||||||
|
|
||||||
export function QrCodeModal({
|
export function QrCodeModal({
|
||||||
context,
|
context,
|
||||||
@ -65,7 +66,7 @@ export function QrCodeModal({
|
|||||||
|
|
||||||
handlers.append(decodedText);
|
handlers.append(decodedText);
|
||||||
api
|
api
|
||||||
.post(ApiEndpoints.barcode, { barcode: decodedText })
|
.post(apiUrl(ApiEndpoints.barcode), { barcode: decodedText })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: response.data?.success || t`Unknown response`,
|
title: response.data?.success || t`Unknown response`,
|
||||||
|
@ -9,6 +9,7 @@ import { api } from '../../App';
|
|||||||
import { navTabs as mainNavTabs } from '../../defaults/links';
|
import { navTabs as mainNavTabs } from '../../defaults/links';
|
||||||
import { ApiEndpoints } 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';
|
||||||
@ -37,7 +38,7 @@ export function Header() {
|
|||||||
queryKey: ['notification-count'],
|
queryKey: ['notification-count'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return api
|
return api
|
||||||
.get(ApiEndpoints.notifications_list, {
|
.get(apiUrl(ApiEndpoints.notifications_list), {
|
||||||
params: {
|
params: {
|
||||||
read: false,
|
read: false,
|
||||||
limit: 1
|
limit: 1
|
||||||
|
@ -36,7 +36,7 @@ export function NotificationDrawer({
|
|||||||
queryKey: ['notifications', opened],
|
queryKey: ['notifications', opened],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api
|
api
|
||||||
.get(ApiEndpoints.notifications_list, {
|
.get(apiUrl(ApiEndpoints.notifications_list), {
|
||||||
params: {
|
params: {
|
||||||
read: false,
|
read: false,
|
||||||
limit: 10
|
limit: 10
|
||||||
|
@ -7,6 +7,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiEndpoints } 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({
|
||||||
@ -25,7 +26,7 @@ export function PartCategoryTree({
|
|||||||
queryKey: ['part_category_tree', opened],
|
queryKey: ['part_category_tree', opened],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api
|
api
|
||||||
.get(ApiEndpoints.category_tree, {})
|
.get(apiUrl(ApiEndpoints.category_tree), {})
|
||||||
.then((response) =>
|
.then((response) =>
|
||||||
response.data.map((category: any) => {
|
response.data.map((category: any) => {
|
||||||
return {
|
return {
|
||||||
|
@ -33,6 +33,7 @@ import { api } from '../../App';
|
|||||||
import { ApiEndpoints } 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';
|
||||||
@ -257,7 +258,7 @@ export function SearchDrawer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return api
|
return api
|
||||||
.post(ApiEndpoints.api_search, params)
|
.post(apiUrl(ApiEndpoints.api_search), params)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
return response.data;
|
return response.data;
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { ApiEndpoints } 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({
|
||||||
@ -25,7 +26,7 @@ export function StockLocationTree({
|
|||||||
queryKey: ['stock_location_tree', opened],
|
queryKey: ['stock_location_tree', opened],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api
|
api
|
||||||
.get(ApiEndpoints.stock_location_tree, {})
|
.get(apiUrl(ApiEndpoints.stock_location_tree), {})
|
||||||
.then((response) =>
|
.then((response) =>
|
||||||
response.data.map((location: any) => {
|
response.data.map((location: any) => {
|
||||||
return {
|
return {
|
||||||
|
@ -142,7 +142,7 @@ export function PartThumbTable({
|
|||||||
{ limit: limit, offset: offset, search: filterQuery }
|
{ limit: limit, offset: offset, search: filterQuery }
|
||||||
],
|
],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return api.get(ApiEndpoints.part_thumbs_list, {
|
return api.get(apiUrl(ApiEndpoints.part_thumbs_list), {
|
||||||
params: {
|
params: {
|
||||||
offset: offset,
|
offset: offset,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
|
@ -27,14 +27,14 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
|||||||
fetchServerApiState: async () => {
|
fetchServerApiState: async () => {
|
||||||
// Fetch server data
|
// Fetch server data
|
||||||
await api
|
await api
|
||||||
.get(ApiEndpoints.api_server_info)
|
.get(apiUrl(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(ApiEndpoints.global_status)
|
.get(apiUrl(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(ApiEndpoints.sso_providers, {
|
.get(apiUrl(ApiEndpoints.sso_providers), {
|
||||||
headers: { Authorization: '' }
|
headers: { Authorization: '' }
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user