Skip to content

Commit

Permalink
Merge branch 'main' into feat.remove-user-from-team
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrk39 authored Sep 10, 2024
2 parents 90d995f + 36dc1c6 commit 8c83f34
Show file tree
Hide file tree
Showing 35 changed files with 11,932 additions and 31,683 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
2 changes: 1 addition & 1 deletion e2e/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
753 changes: 520 additions & 233 deletions e2e/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"lib": ["es2021"],
"lib": ["ES2022"],
"module": "commonjs",
"target": "es2021",
"target": "ES2022",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
Expand Down
2 changes: 1 addition & 1 deletion interfaces/Portal/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
20,184 changes: 5,336 additions & 14,848 deletions interfaces/Portal/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions interfaces/Portalicious/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum AppRoutes {
project = 'project',
projectMonitoring = 'monitoring',
projectPayments = 'payments',
projectRegistration = 'registration',
projectRegistrations = 'registrations',
projects = 'projects',
projectTeam = 'team',
Expand Down
11 changes: 10 additions & 1 deletion interfaces/Portalicious/src/app/domains/domain-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import {
queryOptions,
UndefinedInitialDataOptions,
} from '@tanstack/angular-query-experimental';
import { HttpWrapperService } from '~/services/http-wrapper.service';
import {
HttpWrapperService,
Perform121ServiceRequestParams,
} from '~/services/http-wrapper.service';

export abstract class DomainApiService {
protected httpWrapperService = inject(HttpWrapperService);
Expand All @@ -21,10 +24,15 @@ export abstract class DomainApiService {
>({
path,
processResponse,
requestOptions = {},
...opts
}: {
path: Parameters<typeof DomainApiService.prototype.pathToQueryKey>[0];
processResponse?: (data: BackendDataShape) => ProcessedResponseShape;
requestOptions?: Omit<
Perform121ServiceRequestParams,
'endpoint' | 'method'
>;
} & Partial<UndefinedInitialDataOptions<ProcessedResponseShape>>) {
return () => {
const queryKey = this.pathToQueryKey(path);
Expand All @@ -38,6 +46,7 @@ export abstract class DomainApiService {
const response =
await this.httpWrapperService.perform121ServiceRequest<BackendDataShape>(
{
...requestOptions,
method: 'GET',
endpoint,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Injectable, Signal } from '@angular/core';
import { DomainApiService } from '~/domains/domain-api.service';
import { Payment } from '~/domains/payment/payment.model';

const BASE_ENDPOINT = (paymentId: Signal<number>) => [
const BASE_ENDPOINT = (projectId: Signal<number>) => [
'programs',
paymentId,
projectId,
'payments',
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO: fix all strict problems in 121 service to avoid hardcoding this type
// TODO: AB#30152 This type should be refactored to use Dto121Service
export interface Payment {
payment: number;
paymentDate: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { UserController } from '@121-service/src/user/user.controller';
import { Dto, Dto121Service } from '~/utils/dto-type';
import { ArrayElement } from '~/utils/type-helpers';

// TODO: AB#30152 This type should be refactored to use Dto121Service
export type Project = Dto<FoundProgramDto>;

// TODO: AB#30152 This type should be refactored to use Dto121Service
export type ProjectMetrics = Dto<ProgramStats>;

export type ProjectUser = ArrayElement<
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { HttpParams } from '@angular/common/http';
import { Injectable, Signal } from '@angular/core';
import { DomainApiService } from '~/domains/domain-api.service';
import { Registration } from '~/domains/registration/registration.model';

const BASE_ENDPOINT = (projectId: Signal<number>) => [
'programs',
projectId,
'registrations',
];

@Injectable({
providedIn: 'root',
})
export class RegistrationApiService extends DomainApiService {
getManyByQuery(projectId: Signal<number>) {
// XXX: the query shouldn't be defined here. This should be removed / refactored when the registrations page is built.
let params = new HttpParams();
params = params.append('limit', 10);
params = params.append('page', 1);

return this.generateQueryOptions<{
data: Registration[];
}>({
path: [...BASE_ENDPOINT(projectId)],
requestOptions: {
params,
},
});
}

getRegistrationById(
projectId: Signal<number>,
registrationId: Signal<number>,
) {
return this.generateQueryOptions<Registration>({
path: [...BASE_ENDPOINT(projectId), registrationId],
});
}

public invalidateCache(
projectId: Signal<number>,
registrationId?: Signal<number>,
): Promise<void> {
const path = [...BASE_ENDPOINT(projectId)];

if (registrationId) {
path.push(registrationId);
}

return this.queryClient.invalidateQueries({
queryKey: this.pathToQueryKey(path),
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MappedPaginatedRegistrationDto } from '@121-service/src/registration/dto/mapped-paginated-registration.dto';
import { Dto } from '~/utils/dto-type';

// TODO: AB#30152 This type should be refactored to use Dto121Service
export type Registration = Dto<MappedPaginatedRegistrationDto>;
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@
i18n-pageTitle="@@page-title-project-registrations"
[projectId]="projectId()"
>
<p i18n>project-registrations works!</p>
@if (registrations.isSuccess()) {
<ul>
@for (registration of registrations.data().data; track $index) {
<li>
<a [routerLink]="registrationLink(registration.id)">
{{ registration.name }}
</a>
</li>
}
</ul>
}
</app-page-layout>
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
inject,
input,
} from '@angular/core';
import { RouterLink } from '@angular/router';
import { injectQuery } from '@tanstack/angular-query-experimental';
import { AppRoutes } from '~/app.routes';
import { PageLayoutComponent } from '~/components/page-layout/page-layout.component';
import { RegistrationApiService } from '~/domains/registration/registration.api.service';

@Component({
selector: 'app-project-registrations',
standalone: true,
imports: [PageLayoutComponent],
imports: [PageLayoutComponent, RouterLink],
templateUrl: './project-registrations.component.html',
styles: ``,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProjectRegistrationsComponent {
// this is injected by the router
projectId = input.required<number>();

private registrationApiService = inject(RegistrationApiService);

registrations = injectQuery(
this.registrationApiService.getManyByQuery(this.projectId),
);

registrationLink = (registrationId: number) => [
'/',
AppRoutes.project,
this.projectId(),
AppRoutes.projectRegistration,
registrationId,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ interface PerformRequestParams {
>;
}

export type Perform121ServiceRequestParams = { endpoint: string } & Omit<
PerformRequestParams,
'url'
>;

@Injectable({
providedIn: 'root',
})
Expand Down Expand Up @@ -181,7 +186,7 @@ export class HttpWrapperService {
}

public async perform121ServiceRequest<T>(
options: { endpoint: string } & Omit<PerformRequestParams, 'url'>,
options: Perform121ServiceRequestParams,
): Promise<T> {
return this.performRequest<T>({
...options,
Expand Down
2 changes: 1 addition & 1 deletion k6/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
4 changes: 2 additions & 2 deletions services/121-service/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
},
parserOptions: {
sourceType: 'script',
ecmaVersion: 2021,
ecmaVersion: 2022,
},
rules: {},
},
Expand All @@ -28,7 +28,7 @@ module.exports = {
],
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2021, // Allows for the parsing of modern ECMAScript features
ecmaVersion: 2022, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: true,
tsconfigRootDir: __dirname,
Expand Down
2 changes: 1 addition & 1 deletion services/121-service/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
2 changes: 1 addition & 1 deletion services/121-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-slim AS base
FROM node:20-slim AS base

# Install curl (Used by healthchecks) and procps (Used by swc)
RUN apt-get update && apt-get install -y curl procps
Expand Down
Loading

0 comments on commit 8c83f34

Please sign in to comment.