From e738e25d852e52ae3b8476c0f80d4252d31601a8 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Braga <98167728+Stain19@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:27:06 -0300 Subject: [PATCH] [#13064] Use AccountRequestUpdateRequest as parameter (#13068) * Update editAccountRequest parameter type to AccountRequestUpdateRequest * Fixing the lint * Refatoring editAccountRequest method --------- Co-authored-by: Cedric Ong <67156011+cedricongjh@users.noreply.github.com> --- .../account-request-table.component.ts | 14 +++++++++----- src/web/services/account.service.ts | 12 +----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/web/app/components/account-requests-table/account-request-table.component.ts b/src/web/app/components/account-requests-table/account-request-table.component.ts index 07ba413d77b..3e7fc957730 100755 --- a/src/web/app/components/account-requests-table/account-request-table.component.ts +++ b/src/web/app/components/account-requests-table/account-request-table.component.ts @@ -13,6 +13,7 @@ import { AccountService } from '../../../services/account.service'; import { SimpleModalService } from '../../../services/simple-modal.service'; import { StatusMessageService } from '../../../services/status-message.service'; import { AccountRequest, MessageOutput } from '../../../types/api-output'; +import { AccountRequestUpdateRequest } from '../../../types/api-request'; import { ErrorMessageOutput } from '../../error-message-output'; import { SimpleModalType } from '../simple-modal/simple-modal-type'; import { collapseAnim } from '../teammates-common/collapse-anim'; @@ -70,11 +71,14 @@ export class AccountRequestTableComponent { modalRef.result.then((res: EditRequestModalComponentResult) => { this.accountService.editAccountRequest( accountRequest.id, - res.accountRequestName, - res.accountRequestEmail, - res.accountRequestInstitution, - accountRequest.status, - res.accountRequestComment) + ({ + name: res.accountRequestName, + email: res.accountRequestEmail, + institute: res.accountRequestInstitution, + status: accountRequest.status, + comments: res.accountRequestComment, + }), + ) .subscribe({ next: (resp: AccountRequest) => { accountRequest.comments = resp.comments ?? ''; diff --git a/src/web/services/account.service.ts b/src/web/services/account.service.ts index 35c9c238111..343b28dae72 100644 --- a/src/web/services/account.service.ts +++ b/src/web/services/account.service.ts @@ -118,20 +118,10 @@ export class AccountService { /** * Edits an account request by calling API. */ - editAccountRequest(id: string, name: string, email: string, institute: string, - status: AccountRequestStatus, comments: string) - : Observable { + editAccountRequest(id: string, accountReqUpdateRequest: AccountRequestUpdateRequest): Observable { const paramMap: Record = { id, }; - const accountReqUpdateRequest : AccountRequestUpdateRequest = { - name, - email, - institute, - status, - comments, - }; - return this.httpRequestService.put(ResourceEndpoints.ACCOUNT_REQUEST, paramMap, accountReqUpdateRequest); }