mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
enable passing of free-form urls to apiUrl (#6012)
This commit is contained in:
parent
fb42878c11
commit
bbf4d2f206
@ -60,7 +60,7 @@ export interface ApiFormAction {
|
||||
* @param onFormError : A callback function to call when the form is submitted with errors.
|
||||
*/
|
||||
export interface ApiFormProps {
|
||||
url: ApiPaths;
|
||||
url: ApiPaths | string;
|
||||
pk?: number | string | undefined;
|
||||
pathParams?: PathParams;
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||
|
@ -19,7 +19,7 @@ import { generateUniqueId } from './uid';
|
||||
* Construct an API url from the provided ApiFormProps object
|
||||
*/
|
||||
export function constructFormUrl(
|
||||
url: ApiPaths,
|
||||
url: ApiPaths | string,
|
||||
pk?: string | number,
|
||||
pathParams?: PathParams
|
||||
): string {
|
||||
|
@ -196,11 +196,14 @@ export type PathParams = Record<string, string | number>;
|
||||
* Construct an API URL with an endpoint and (optional) pk value
|
||||
*/
|
||||
export function apiUrl(
|
||||
path: ApiPaths,
|
||||
path: ApiPaths | string,
|
||||
pk?: any,
|
||||
pathParams?: PathParams
|
||||
): string {
|
||||
let _url = apiEndpoint(path);
|
||||
let _url = path;
|
||||
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 (!_url.startsWith('/')) {
|
||||
|
Loading…
Reference in New Issue
Block a user