simplify url-builder function
Signed-off-by: Augustin Husson <augustin.husson@amadeus.com>
This commit is contained in:
parent
cdab0769c6
commit
1927ba4fe0
|
@ -1,4 +1,4 @@
|
|||
const apiPrefix = '/api/v2';
|
||||
const API_PREFIX = '/api/v2';
|
||||
|
||||
export type URLParams = {
|
||||
resource: string;
|
||||
|
@ -6,12 +6,10 @@ export type URLParams = {
|
|||
apiPrefix?: string;
|
||||
};
|
||||
|
||||
export default function buildURL(params: URLParams): string {
|
||||
let url = params.apiPrefix === undefined ? apiPrefix : params.apiPrefix;
|
||||
url = `${url}/${params.resource}`;
|
||||
|
||||
if (params.queryParams !== undefined) {
|
||||
url = `${url}?${params.queryParams.toString()}`;
|
||||
export default function buildURL({ apiPrefix = API_PREFIX, resource, queryParams }: URLParams): string {
|
||||
let url = `${apiPrefix}/${resource}`;
|
||||
if (queryParams !== undefined) {
|
||||
url = `${url}?${queryParams.toString()}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ function CustomTableCell(props: tableCellProperties) {
|
|||
export default function ViewStatus() {
|
||||
const { data } = useAMStatus();
|
||||
if (data === undefined || data === null) {
|
||||
return <></>;
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue