simplify url-builder function

Signed-off-by: Augustin Husson <augustin.husson@amadeus.com>
This commit is contained in:
Augustin Husson 2023-03-02 11:19:04 +01:00
parent cdab0769c6
commit 1927ba4fe0
2 changed files with 6 additions and 8 deletions

View File

@ -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;
}

View File

@ -45,7 +45,7 @@ function CustomTableCell(props: tableCellProperties) {
export default function ViewStatus() {
const { data } = useAMStatus();
if (data === undefined || data === null) {
return <></>;
return null;
}
return (