-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
portalicious: import reconciliation data
AB#32154 AB#32158
- Loading branch information
Showing
17 changed files
with
542 additions
and
204 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
71 changes: 71 additions & 0 deletions
71
...aces/Portalicious/src/app/components/import-file-dialog/import-file-dialog.component.html
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,71 @@ | ||
<p-dialog | ||
[modal]="true" | ||
[dismissableMask]="true" | ||
[closeOnEscape]="false" | ||
[(visible)]="dialogVisible" | ||
(onShow)="resetForm()" | ||
styleClass="max-w-[46rem]" | ||
> | ||
<ng-template pTemplate="header"> | ||
<h3> | ||
<i class="pi pi-download me-2"></i> | ||
<ng-container>{{ header() }}</ng-container> | ||
</h3> | ||
</ng-template> | ||
|
||
<form | ||
class="space-y-3" | ||
[formGroup]="formGroup" | ||
(ngSubmit)="onFormSubmit()" | ||
> | ||
<ng-content></ng-content> | ||
<div> | ||
<app-file-upload-control | ||
formControlName="file" | ||
[accept]="accept()" | ||
(clearFiles)="resetForm()" | ||
></app-file-upload-control> | ||
<app-form-error [error]="formFieldErrors()('file')" /> | ||
</div> | ||
@if (mutation().isError()) { | ||
<div class="mt-4"> | ||
@let detailedErrors = detailedImportErrors(); | ||
|
||
@if (detailedErrors) { | ||
<app-form-error | ||
error="Something went wrong with this import. Please fix the errors reported below and try again." | ||
i18n-error | ||
/> | ||
|
||
<p-scrollPanel | ||
styleClass="h-32 w-full border border-grey-300 bg-grey-100 p-4" | ||
> | ||
@for (error of detailedErrors; track $index) { | ||
<pre>{{ error | json }}</pre> | ||
} | ||
</p-scrollPanel> | ||
} @else { | ||
<app-form-error [error]="mutation().failureReason()?.message" /> | ||
} | ||
</div> | ||
} | ||
<div class="flex justify-end gap-3 pt-2"> | ||
<p-button | ||
label="Cancel" | ||
i18n-label="@@generic-cancel" | ||
rounded | ||
outlined | ||
severity="contrast" | ||
(click)="dialogVisible.set(false)" | ||
[disabled]="mutation().isPending()" | ||
/> | ||
<p-button | ||
label="Import file" | ||
i18n-label | ||
type="submit" | ||
rounded | ||
[loading]="mutation().isPending()" | ||
/> | ||
</div> | ||
</form> | ||
</p-dialog> |
98 changes: 98 additions & 0 deletions
98
...rfaces/Portalicious/src/app/components/import-file-dialog/import-file-dialog.component.ts
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,98 @@ | ||
import { JsonPipe } from '@angular/common'; | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
computed, | ||
input, | ||
model, | ||
} from '@angular/core'; | ||
import { | ||
FormControl, | ||
FormGroup, | ||
ReactiveFormsModule, | ||
Validators, | ||
} from '@angular/forms'; | ||
|
||
import { CreateMutationResult } from '@tanstack/angular-query-experimental'; | ||
import { ButtonModule } from 'primeng/button'; | ||
import { DialogModule } from 'primeng/dialog'; | ||
import { ScrollPanelModule } from 'primeng/scrollpanel'; | ||
|
||
import { FileUploadControlComponent } from '~/components/file-upload-control/file-upload-control.component'; | ||
import { FormErrorComponent } from '~/components/form-error/form-error.component'; | ||
import { | ||
generateFieldErrors, | ||
genericFieldIsRequiredValidationMessage, | ||
} from '~/utils/form-validation'; | ||
|
||
export type ImportFileDialogFormGroup = | ||
(typeof ImportFileDialogComponent)['prototype']['formGroup']; | ||
|
||
@Component({ | ||
selector: 'app-import-file-dialog', | ||
standalone: true, | ||
imports: [ | ||
DialogModule, | ||
ReactiveFormsModule, | ||
ButtonModule, | ||
FormErrorComponent, | ||
FileUploadControlComponent, | ||
ScrollPanelModule, | ||
JsonPipe, | ||
], | ||
templateUrl: './import-file-dialog.component.html', | ||
styles: ``, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ImportFileDialogComponent { | ||
mutation = | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
input.required<CreateMutationResult<any, Error, any, any>>(); | ||
accept = input.required<string>(); | ||
header = input.required<string>(); | ||
dialogVisible = model<boolean>(false); | ||
|
||
formGroup = new FormGroup({ | ||
file: new FormControl<File | null>(null, { | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
validators: [Validators.required], | ||
}), | ||
}); | ||
|
||
formFieldErrors = generateFieldErrors<ImportFileDialogFormGroup>( | ||
this.formGroup, | ||
{ | ||
file: genericFieldIsRequiredValidationMessage, | ||
}, | ||
); | ||
|
||
detailedImportErrors = computed(() => { | ||
const error = this.mutation().failureReason(); | ||
|
||
if (error instanceof HttpErrorResponse) { | ||
if (Array.isArray(error.error)) { | ||
return error.error as unknown[]; | ||
} | ||
|
||
return [error.error as unknown]; | ||
} | ||
|
||
return undefined; | ||
}); | ||
|
||
resetForm(): void { | ||
this.formGroup.reset(); | ||
this.mutation().reset(); | ||
} | ||
|
||
onFormSubmit(): void { | ||
this.formGroup.markAllAsTouched(); | ||
|
||
if (!this.formGroup.valid) { | ||
return; | ||
} | ||
|
||
this.mutation().mutate(this.formGroup.getRawValue()); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...t-payment/components/import-reconciliation-data/import-reconciliation-data.component.html
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,41 @@ | ||
@if (canImportReconciliationData()) { | ||
<p-button | ||
label="Import reconciliation data" | ||
i18n-label | ||
(click)="importReconciliationData()" | ||
[disabled]="paymentInProgress.isPending()" | ||
icon="pi pi-download" | ||
outlined | ||
rounded | ||
></p-button> | ||
|
||
<app-import-file-dialog | ||
[(dialogVisible)]="dialogVisible" | ||
[mutation]="importReconciliationDataMutation" | ||
accept=".csv,text/csv,text/comma-separated-values,application/csv" | ||
header="Import reconciliation data" | ||
i18n-header | ||
> | ||
<p i18n> | ||
Import the file sent by the FSP to see the transfer status of the | ||
registrations included in this payment. Download the template | ||
<p-button | ||
[link]="true" | ||
(click)="downloadReconciliationTemplatesMutation.mutate()" | ||
>here</p-button | ||
>. | ||
</p> | ||
<p i18n> | ||
Make sure to upload the correct file as this will override the current | ||
file. | ||
</p> | ||
<p> | ||
<span i18n | ||
>The status column in the file should contain one of the following | ||
values:</span | ||
> | ||
<!-- eslint-disable-next-line @angular-eslint/template/i18n --> | ||
<span class="ml-1 font-mono">success, error.</span> | ||
</p> | ||
</app-import-file-dialog> | ||
} |
Oops, something went wrong.