Skip to content

Commit

Permalink
feat: created getUrlKeyParam util function
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukeybooi committed Jul 13, 2023
1 parent 51d1044 commit aca9eb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IConfigurableColumnsProps } from 'providers/datatableColumnsConfigurato
import { IMetadataDispatcherActionsContext } from 'providers/metadataDispatcher/contexts';
import { IEntityEndpointsEvaluator, useModelApiHelper } from 'components/configurableForm/useActionEndpoint';
import { IUseMutateResponse, useMutate } from 'hooks/useMutate';
import { getUrlKeyParam } from 'utils';

export interface IWithUrlRepositoryArgs {
getListUrl: string;
Expand Down Expand Up @@ -97,8 +98,9 @@ const createRepository = (args: ICreateUrlRepositoryArgs): IUrlRepository => {

const fetch = (payload: IGetListDataPayload): Promise<ITableDataInternalResponse> => {
const getDataPayload = convertPayload(payload);
const key = getUrlKeyParam(getListUrl);

const getDataUrl = `${backendUrl}${getListUrl}?${qs.stringify(getDataPayload)}`;
const getDataUrl = `${backendUrl}${getListUrl}${key}${qs.stringify(getDataPayload)}`;

return axios({
url: getDataUrl,
Expand Down
2 changes: 2 additions & 0 deletions shesha-reactjs/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,5 @@ export const evaluateDynamicFilters = async (

return convertedFilters;
};

export const getUrlKeyParam = (url: string = ''): '?' | '&' => (url?.includes('?') ? '&' : '?');

0 comments on commit aca9eb0

Please sign in to comment.