Skip to content

Commit

Permalink
Fix api links missing '/' as well as clean up services
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha-dresden committed Dec 4, 2024
1 parent 00c78c2 commit 9daa6ba
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TableAction, TableListBaseComponent } from 'app/shared/components/table
import { CommitteeMember, CommitteeMemberRoles } from 'app/shared/models/committee-member.model';
import { Store } from '@ngrx/store';
import { selectUserLoginData } from '../../store/user-login-data.selectors';
import { firstValueFrom, lastValueFrom } from 'rxjs';
import { firstValueFrom, lastValueFrom, map } from 'rxjs';
import { CommitteeMemberService } from '../../shared/services/committee-member.service';

@Component({
Expand All @@ -22,8 +22,6 @@ export class ManageCommitteeComponent extends TableListBaseComponent<CommitteeMe

override rowsPerPage = 10;

public members: Promise<CommitteeMember[]>;

sortableHeaders: { field: string; label: string }[] = [
{ field: 'name', label: 'Name' },
{ field: 'email', label: 'Email' },
Expand All @@ -39,7 +37,6 @@ export class ManageCommitteeComponent extends TableListBaseComponent<CommitteeMe
override itemService: CommitteeMemberService,
) {
super(messageService, confirmationService, elementRef);
this.members = this.itemService.getMembers();
}

public override addItem() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ export class SubmitReportStep2Component extends DestroyerComponent implements On
from(this.router.navigateByUrl(this.getContinueUrl?.(this.report) || ''));
if (this.report?.id) {
this.reportService.setActiveReportById(this.report.id).pipe(takeUntil(this.destroy$)).subscribe();
return from(this.router.navigateByUrl(`/reports/f3x/submit/status/${this.report.id}`));
return from(this.router.navigateByUrl(`/reports/f3x/submit/status/${this.report.id}/`));
} else {
return from(this.router.navigateByUrl('/reports'));
return from(this.router.navigateByUrl('/reports/'));
}
}),
);
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/app/shared/resolvers/report.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('ReportResolver', () => {
expect(response).toEqual(form3X);
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/${form3X.id}`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/${form3X.id}/`);
expect(req.request.method).toEqual('GET');
req.flush(form3X);
httpTestingController.verify();
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/app/shared/services/contact.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('ContactService', () => {
expect(response).toEqual(mockResponse);
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/contacts/1`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/contacts/1/`);
expect(req.request.method).toEqual('DELETE');
req.flush(mockResponse);
httpTestingController.verify();
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/services/contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ContactService implements TableListService<Contact> {
}

public get(id: string): Observable<Contact> {
return this.apiService.get<Contact>(`/contacts/${id}`).pipe(map((response) => Contact.fromJSON(response)));
return this.apiService.get<Contact>(`/contacts/${id}/`).pipe(map((response) => Contact.fromJSON(response)));
}

public create(contact: Contact): Observable<Contact> {
Expand All @@ -75,7 +75,7 @@ export class ContactService implements TableListService<Contact> {
}

public delete(contact: Contact): Observable<null> {
return this.apiService.delete<null>(`/contacts/${contact.id}`);
return this.apiService.delete<null>(`/contacts/${contact.id}/`);
}

/**
Expand Down
9 changes: 0 additions & 9 deletions front-end/src/app/shared/services/form-1m.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { ReportService } from './report.service';
import { ApiService } from './api.service';

@Injectable({
providedIn: 'root',
})
export class Form1MService extends ReportService {
override apiEndpoint = '/reports/form-1m';

constructor(
override apiService: ApiService,
override store: Store,
) {
super(apiService, store);
}
}
9 changes: 0 additions & 9 deletions front-end/src/app/shared/services/form-24.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { ReportService } from './report.service';
import { ApiService } from './api.service';

@Injectable({
providedIn: 'root',
})
export class Form24Service extends ReportService {
override apiEndpoint = '/reports/form-24';

constructor(
override apiService: ApiService,
override store: Store,
) {
super(apiService, store);
}
}
2 changes: 1 addition & 1 deletion front-end/src/app/shared/services/form-3x.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Form3XService', () => {
expect(response).toBeNull();
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/form-3x/999`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/form-3x/999/`);
expect(req.request.method).toEqual('DELETE');
req.flush(null);
httpTestingController.verify();
Expand Down
8 changes: 4 additions & 4 deletions front-end/src/app/shared/services/form-3x.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Form3XService extends ReportService {

public async getF3xCoverageDates(): Promise<F3xCoverageDates[]> {
const [response, reportCodeLabelMap] = await Promise.all([
firstValueFrom(this.apiService.get<F3xCoverageDates[]>(`${this.apiEndpoint}/coverage_dates`)),
firstValueFrom(this.apiService.get<F3xCoverageDates[]>(`${this.apiEndpoint}/coverage_dates/`)),
this.getReportCodeLabelMap(),
]);
return response.map((fx3CoverageDate) =>
Expand All @@ -38,7 +38,7 @@ export class Form3XService extends ReportService {
let map = this.f3xReportCodeLabelMap$.getValue();
if (!map) {
map = await firstValueFrom(
this.apiService.get<{ [key in F3xReportCodes]: string }>(`${this.apiEndpoint}/report_code_map`),
this.apiService.get<{ [key in F3xReportCodes]: string }>(`${this.apiEndpoint}/report_code_map/`),
);
this.f3xReportCodeLabelMap$.next(map);
}
Expand All @@ -47,12 +47,12 @@ export class Form3XService extends ReportService {

public getFutureReports(coverage_through_date: string): Observable<Form3X[]> {
return this.apiService
.get<Form3X[]>(`${this.apiEndpoint}/future?after=${coverage_through_date}`)
.get<Form3X[]>(`${this.apiEndpoint}/future/?after=${coverage_through_date}`)
.pipe(map((response) => response.map((r) => Form3X.fromJSON(r))));
}

public getFinalReport(year: number): Promise<Form3X | undefined> {
return firstValueFrom(this.apiService.get<Form3X | undefined>(`${this.apiEndpoint}/final?year=${year}`));
return firstValueFrom(this.apiService.get<Form3X | undefined>(`${this.apiEndpoint}/final/?year=${year}`));
}

public override fecUpdate(report: Form3X, committeeAccount?: CommitteeAccount): Observable<Report> {
Expand Down
9 changes: 0 additions & 9 deletions front-end/src/app/shared/services/form-99.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { ReportService } from './report.service';
import { ApiService } from './api.service';

@Injectable({
providedIn: 'root',
})
export class Form99Service extends ReportService {
override apiEndpoint = '/reports/form-99';

constructor(
override apiService: ApiService,
override store: Store,
) {
super(apiService, store);
}
}
2 changes: 0 additions & 2 deletions front-end/src/app/shared/services/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { DestroyerComponent } from '../components/app-destroyer.component';
import { UserLoginData } from '../models/user.model';
import { UsersService } from '../services/users.service';
import { DateUtils } from '../utils/date.utils';
import { ApiService } from './api.service';

@Injectable({
providedIn: 'root',
Expand All @@ -20,7 +19,6 @@ export class LoginService extends DestroyerComponent {
constructor(
private store: Store,
private router: Router,
private apiService: ApiService,
private cookieService: CookieService,
private usersService: UsersService,
) {
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/services/memo-text.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('MemoTextService', () => {
expect(response).toEqual(memoText);
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/${memoText.id}`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/${memoText.id}/`);
expect(req.request.method).toEqual('GET');
req.flush(memoText);
httpTestingController.verify();
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('MemoTextService', () => {
expect(response).toBeNull();
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/999`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/999/`);
expect(req.request.method).toEqual('DELETE');
req.flush(null);
httpTestingController.verify();
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/services/memo-text.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class MemoTextService {
constructor(private apiService: ApiService) {}

public get(id: string): Observable<MemoText> {
return this.apiService.get<MemoText>(`/memo-text/${id}`).pipe(map((response) => MemoText.fromJSON(response)));
return this.apiService.get<MemoText>(`/memo-text/${id}/`).pipe(map((response) => MemoText.fromJSON(response)));
}

public getForReportId(reportId: string): Observable<MemoText[]> {
Expand All @@ -35,6 +35,6 @@ export class MemoTextService {
}

public delete(memoText: MemoText): Observable<null> {
return this.apiService.delete<null>(`/memo-text/${memoText.id}`);
return this.apiService.delete<null>(`/memo-text/${memoText.id}/`);
}
}
2 changes: 1 addition & 1 deletion front-end/src/app/shared/services/report.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('ReportService', () => {
expect(response).toEqual(mockResponse);
});

const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/1`);
const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/1/`);
expect(req.request.method).toEqual('DELETE');
req.flush(mockResponse);
httpTestingController.verify();
Expand Down
4 changes: 2 additions & 2 deletions front-end/src/app/shared/services/report.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ReportService implements TableListService<Report> {

public get(reportId: string): Observable<Report> {
return this.apiService
.get<Report>(`${this.apiEndpoint}/${reportId}`)
.get<Report>(`${this.apiEndpoint}/${reportId}/`)
.pipe(map((response) => getReportFromJSON(response)));
}

Expand All @@ -72,7 +72,7 @@ export class ReportService implements TableListService<Report> {
}

public delete(report: Report): Observable<null> {
return this.apiService.delete<null>(`${this.apiEndpoint}/${report.id}`);
return this.apiService.delete<null>(`${this.apiEndpoint}/${report.id}/`);
}

/**
Expand Down
9 changes: 0 additions & 9 deletions front-end/src/app/shared/services/transaction-schA.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { DatePipe } from '@angular/common';
import { Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { TransactionService } from './transaction.service';
import { Observable } from 'rxjs';
import { ListRestResponse } from '../models/rest-api.model';
Expand All @@ -18,11 +16,4 @@ export class TransactionSchAService extends TransactionService {
): Observable<ListRestResponse> {
return super.getTableData(pageNumber, ordering, { ...params, schedules: 'A' });
}

constructor(
override apiService: ApiService,
override datePipe: DatePipe,
) {
super(apiService, datePipe);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DatePipe } from '@angular/common';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService, QueryParams } from './api.service';
import { QueryParams } from './api.service';
import { TransactionService } from './transaction.service';
import { ListRestResponse } from '../models/rest-api.model';

Expand All @@ -10,12 +9,6 @@ import { ListRestResponse } from '../models/rest-api.model';
})
export class TransactionSchBService extends TransactionService {
override tableDataEndpoint = '/transactions';
constructor(
override apiService: ApiService,
override datePipe: DatePipe,
) {
super(apiService, datePipe);
}

override getTableData(pageNumber = 1, ordering = '', params: QueryParams = {}): Observable<ListRestResponse> {
// The table data for the Schedule B disbursements also includes the Schedule E expenditures.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DatePipe } from '@angular/common';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService, QueryParams } from './api.service';
import { QueryParams } from './api.service';
import { TransactionService } from './transaction.service';
import { ListRestResponse } from '../models/rest-api.model';

Expand All @@ -10,12 +9,6 @@ import { ListRestResponse } from '../models/rest-api.model';
})
export class TransactionSchCService extends TransactionService {
override tableDataEndpoint = '/transactions';
constructor(
override apiService: ApiService,
override datePipe: DatePipe,
) {
super(apiService, datePipe);
}

override getTableData(pageNumber = 1, ordering = '', params: QueryParams = {}): Observable<ListRestResponse> {
// The table data for the Schedule C loans also includes the Schedule D debts.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { DatePipe } from '@angular/common';
import { Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { TransactionService } from './transaction.service';
import { Observable } from 'rxjs';
import { ListRestResponse } from '../models/rest-api.model';
Expand All @@ -20,11 +18,4 @@ export class TransactionSchC2Service extends TransactionService {
): Observable<ListRestResponse> {
return super.getTableData(pageNumber, ordering, { ...params, schedules: 'C2' });
}

constructor(
override apiService: ApiService,
override datePipe: DatePipe,
) {
super(apiService, datePipe);
}
}
2 changes: 0 additions & 2 deletions front-end/src/app/shared/services/web-print.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { ApiService } from './api.service';
import { ReportService } from './report.service';
import { firstValueFrom } from 'rxjs';
Expand All @@ -11,7 +10,6 @@ export class WebPrintService {
constructor(
private apiService: ApiService,
private reportService: ReportService,
private store: Store,
) {}

/**
Expand Down

0 comments on commit 9daa6ba

Please sign in to comment.