Skip to content

Commit

Permalink
[TEAMMATES#13064] Use AccountRequestUpdateRequest as parameter (TEAM…
Browse files Browse the repository at this point in the history
…MATES#13068)

* Update editAccountRequest parameter type to AccountRequestUpdateRequest

* Fixing the lint

* Refatoring editAccountRequest method

---------

Co-authored-by: Cedric Ong <[email protected]>
  • Loading branch information
Stain19 and cedricongjh authored Apr 24, 2024
1 parent 6b83e4f commit e738e25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)
<AccountRequestUpdateRequest>({
name: res.accountRequestName,
email: res.accountRequestEmail,
institute: res.accountRequestInstitution,
status: accountRequest.status,
comments: res.accountRequestComment,
}),
)
.subscribe({
next: (resp: AccountRequest) => {
accountRequest.comments = resp.comments ?? '';
Expand Down
12 changes: 1 addition & 11 deletions src/web/services/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AccountRequest> {
editAccountRequest(id: string, accountReqUpdateRequest: AccountRequestUpdateRequest): Observable<AccountRequest> {
const paramMap: Record<string, string> = {
id,
};
const accountReqUpdateRequest : AccountRequestUpdateRequest = {
name,
email,
institute,
status,
comments,
};

return this.httpRequestService.put(ResourceEndpoints.ACCOUNT_REQUEST, paramMap, accountReqUpdateRequest);
}

Expand Down

0 comments on commit e738e25

Please sign in to comment.