-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/force_environments_to_be_different_names
- Loading branch information
Showing
15 changed files
with
587 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
|
||
export const healthService = service | ||
.enhanceEndpoints({ addTagTypes: ['HealthEvents'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
getHealthEvents: builder.query< | ||
Res['healthEvents'], | ||
Req['getHealthEvents'] | ||
>({ | ||
providesTags: [{ id: 'LIST', type: 'HealthEvents' }], | ||
query: (query: Req['getHealthEvents']) => ({ | ||
url: `projects/${query.projectId}/feature-health/events/`, | ||
}), | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function getHealthEvents( | ||
store: any, | ||
data: Req['getHealthEvents'], | ||
options?: Parameters< | ||
typeof healthService.endpoints.getHealthEvents.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
healthService.endpoints.getHealthEvents.initiate(data, options), | ||
) | ||
} | ||
|
||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useGetHealthEventsQuery, | ||
// END OF EXPORTS | ||
} = healthService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetHealthEventsQuery({ id: 2 }, {}) //get hook | ||
healthService.endpoints.getHealthEvents.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
|
||
export const healthProviderService = service | ||
.enhanceEndpoints({ addTagTypes: ['HealthProviders'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
createHealthProvider: builder.mutation< | ||
Res['healthProvider'], | ||
Req['createHealthProvider'] | ||
>({ | ||
invalidatesTags: [{ id: 'LIST', type: 'HealthProviders' }], | ||
query: (query: Req['createHealthProvider']) => ({ | ||
body: { name: query.name }, | ||
method: 'POST', | ||
url: `projects/${query.projectId}/feature-health/providers/`, | ||
}), | ||
}), | ||
deleteHealthProvider: builder.mutation<void, Req['deleteHealthProvider']>( | ||
{ | ||
invalidatesTags: [{ id: 'LIST', type: 'HealthProviders' }], | ||
query: (query: Req['deleteHealthProvider']) => ({ | ||
method: 'DELETE', | ||
url: `projects/${query.projectId}/feature-health/providers/${query.providerId}/`, | ||
}), | ||
}, | ||
), | ||
getHealthProviders: builder.query< | ||
Res['healthProviders'], | ||
Req['getHealthProviders'] | ||
>({ | ||
providesTags: [{ id: 'LIST', type: 'HealthProviders' }], | ||
query: (query: Req['getHealthProviders']) => ({ | ||
url: `projects/${query.projectId}/feature-health/providers/`, | ||
}), | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function getHealthProviders( | ||
store: any, | ||
data: Req['getHealthProviders'], | ||
options?: Parameters< | ||
typeof healthProviderService.endpoints.getHealthProviders.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
healthProviderService.endpoints.getHealthProviders.initiate(data, options), | ||
) | ||
} | ||
|
||
export async function createHealthProvider( | ||
store: any, | ||
data: Req['createHealthProvider'], | ||
options?: Parameters< | ||
typeof healthProviderService.endpoints.createHealthProvider.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
healthProviderService.endpoints.createHealthProvider.initiate( | ||
data, | ||
options, | ||
), | ||
) | ||
} | ||
|
||
export async function deleteHealthProvider( | ||
store: any, | ||
data: Req['deleteHealthProvider'], | ||
options?: Parameters< | ||
typeof healthProviderService.endpoints.deleteHealthProvider.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
healthProviderService.endpoints.deleteHealthProvider.initiate( | ||
data, | ||
options, | ||
), | ||
) | ||
} | ||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useCreateHealthProviderMutation, | ||
useDeleteHealthProviderMutation, | ||
useGetHealthProvidersQuery, | ||
// END OF EXPORTS | ||
} = healthProviderService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetHealthProvidersQuery({ id: 2 }, {}) //get hook | ||
healthProviderService.endpoints.getHealthProviders.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.