-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate admin-console client service to ts (#1531)
* feat(public/services/billingservice): added billing service * feat(public/services/exampleservice): added example service * test(public/services/billingservice): adds tests for getBillingInfo * test(public/services/exampleservice): adds tests for getSingleExampleForm and getExampleForms * refactor(billingservice): added dto types to fe/be and type annnotation on get for fe * style(public/exampleservice): added curly braces; added type annotation on methods * refactor(examples): adds dto to params and updated fe file naming to fit be * test(examplesservice): updated tests to use new dto shape * refactor(billing): updated billing fe/be to use dto * test(billingservice): updated tests to use dto for params * refactor(examples-list/controller): updated to use ExamplesService * refactor(billing/client/controller): replaced AdminService with new BillingService * refactor(forms/client/routes): replaced AdminConsole with ExamplesService * chore(main.js): deletes old admin-console.client.service * test(billingservice): updated test blocks * test(exampleservice): updated test blocks * style(types/billing): imported LoginStatistic rather than redefining
- Loading branch information
Showing
16 changed files
with
291 additions
and
108 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
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
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
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
68 changes: 0 additions & 68 deletions
68
src/public/modules/users/services/admin-console.client.service.js
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
import axios from 'axios' | ||
|
||
import { BillingInfoDto, BillingQueryDto } from '../../types/api/billing' | ||
|
||
// Exported for testing | ||
export const BILLING_ENDPOINT = '/billing' | ||
|
||
/** | ||
* Gets the billing information for the given month and year | ||
* @param billingQueryParams The formId and the specific month to get the information for | ||
* @returns Promise<BillingResult> The billing statistics of the given month | ||
*/ | ||
export const getBillingInfo = ( | ||
billingQueryParams: BillingQueryDto, | ||
): Promise<BillingInfoDto> => { | ||
return axios | ||
.get<BillingInfoDto>(BILLING_ENDPOINT, { | ||
params: billingQueryParams, | ||
}) | ||
.then(({ data }) => data) | ||
} |
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,42 @@ | ||
import axios from 'axios' | ||
|
||
import { | ||
ExampleFormsQueryDto, | ||
ExampleFormsResult, | ||
ExampleSingleFormResult, | ||
} from '../../types/api' | ||
|
||
export const EXAMPLES_ENDPOINT = '/examples' | ||
|
||
/** | ||
* Gets example forms that matches the specified parameters for listing | ||
* @param exampleFormsSearchParams The search terms to query the backend for | ||
* @returns The list of retrieved examples if `shouldGetTotalNumResults` is false | ||
* @returns The list of retrieved examples with the total results if `shouldGetTotalNumResults` is true | ||
*/ | ||
export const getExampleForms = ( | ||
exampleFormsSearchParams: ExampleFormsQueryDto, | ||
): Promise<ExampleFormsResult> => { | ||
return axios | ||
.get<ExampleFormsResult>(EXAMPLES_ENDPOINT, { | ||
params: exampleFormsSearchParams, | ||
// disable IE ajax request caching (so search requests don't get cached) | ||
headers: { 'If-Modified-Since': '0' }, | ||
}) | ||
.then(({ data }) => data) | ||
} | ||
/** | ||
* Gets a single form for examples | ||
* @param formId The id of the form to search for | ||
* @returns The information of the example form | ||
*/ | ||
export const getSingleExampleForm = ( | ||
formId: string, | ||
): Promise<ExampleSingleFormResult> => { | ||
return axios | ||
.get<ExampleSingleFormResult>(`${EXAMPLES_ENDPOINT}/${formId}`, { | ||
// disable IE ajax request caching (so search requests don't get cached) | ||
headers: { 'If-Modified-Since': '0' }, | ||
}) | ||
.then(({ data }) => data) | ||
} |
Oops, something went wrong.