Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
<td opal-lib-moj-sortable-table-row-data id="account">
<a
class="govuk-link govuk-link--no-visited-state"
(click)="onAccountClick(row['Defendant id'])"
(keydown.enter)="onAccountClick(row['Defendant id'])"
(click)="onAccountClick(row['Account id'])"
(keydown.enter)="onAccountClick(row['Account id'])"
tabindex="0"
>{{ row['Account'] }}</a
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { IAbstractTableData } from '@hmcts/opal-frontend-common/components/abstr
import { SortableValuesType } from '@hmcts/opal-frontend-common/components/abstract/abstract-sortable-table/types';

export interface IFinesDraftTableWrapperTableData extends IAbstractTableData<SortableValuesType> {
Account: string;
Account: string | null;
'Account id': number;
ChangedDate: string;
Changed: number;
'Defendant id': number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IFinesDraftTableWrapperTableData } from '../interfaces/fines-draft-tabl
export const FINES_DRAFT_TABLE_WRAPPER_TABLE_DATA_MOCK: IFinesDraftTableWrapperTableData[] = [
{
Account: 'ACC1234567890',
'Account id': 123,
'Defendant id': 101,
Defendant: 'John Doe',
'Date of birth': '1985-06-15',
Expand All @@ -16,6 +17,7 @@ export const FINES_DRAFT_TABLE_WRAPPER_TABLE_DATA_MOCK: IFinesDraftTableWrapperT
},
{
Account: 'ACC0987654321',
'Account id': 456,
'Defendant id': 202,
Defendant: 'Jane Smith',
'Date of birth': '1990-09-25',
Expand Down
37 changes: 20 additions & 17 deletions src/app/flows/fines/fines-draft/services/fines-draft.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,27 @@ export class FinesDraftService {
* @returns {IFinesDraftTableWrapperTableData[]} An array of table data objects.
*/
public populateTableData(response: IOpalFinesDraftAccountsResponse): IFinesDraftTableWrapperTableData[] {
return response.summaries.map(({ draft_account_id, account_snapshot, account_status_date, account_number }) => {
const { defendant_name, date_of_birth, created_date, account_type, business_unit_name, submitted_by_name } =
account_snapshot;
return response.summaries.map(
({ draft_account_id, account_snapshot, account_status_date, account_number, account_id }) => {
const { defendant_name, date_of_birth, created_date, account_type, business_unit_name, submitted_by_name } =
account_snapshot;

return {
Account: account_number,
ChangedDate: account_status_date,
Changed: this.dateService.getDaysAgo(account_status_date),
'Defendant id': draft_account_id,
Defendant: defendant_name,
'Date of birth': date_of_birth,
CreatedDate: created_date,
Created: this.dateService.getDaysAgo(created_date),
'Account type': FINES_ACCOUNT_TYPES[account_type as keyof typeof FINES_ACCOUNT_TYPES],
'Business unit': business_unit_name,
'Submitted by': submitted_by_name,
};
});
return {
Account: account_number,
'Account id': account_id || 0,
ChangedDate: account_status_date,
Changed: this.dateService.getDaysAgo(account_status_date),
'Defendant id': draft_account_id,
Defendant: defendant_name,
'Date of birth': date_of_birth,
CreatedDate: created_date,
Created: this.dateService.getDaysAgo(created_date),
'Account type': FINES_ACCOUNT_TYPES[account_type as keyof typeof FINES_ACCOUNT_TYPES],
'Business unit': business_unit_name,
'Submitted by': submitted_by_name,
};
},
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ export interface IOpalFinesDraftAccountsSummary {
created_at: string;
submitted_by: string;
business_unit_id: number;
validated_at: string | null;
validated_by: string | null;
account_snapshot: IOpalFinesAccountSnapshot;
account_type: string;
account_status: string;
account_status_date: string;
account_number: string;
account_id: number | null;
account_status_date: string;
submitted_by_name: string;
}

interface IOpalFinesAccountSnapshot {
account_type: string;
created_date: string;
submitted_by: string;
approved_date: string;
defendant_name: string;
submitted_by_name: string;
business_unit_name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ export const OPAL_FINES_DRAFT_ACCOUNTS_MOCK: IOpalFinesDraftAccountsResponse = {
submitted_by_name: 'User One',
business_unit_name: 'Business Unit A',
date_of_birth: '1990-05-15',
approved_date: '',
},
account_type: 'TYPE_A',
account_status: 'ACTIVE',
account_status_date: '2023-01-01',
account_number: 'TESTACC123',
account_id: 123,
validated_at: null,
validated_by: null,
submitted_by_name: 'User One',
},
{
draft_account_id: 102,
Expand All @@ -35,11 +40,16 @@ export const OPAL_FINES_DRAFT_ACCOUNTS_MOCK: IOpalFinesDraftAccountsResponse = {
submitted_by_name: 'User Two',
business_unit_name: 'Business Unit B',
date_of_birth: null,
approved_date: '',
},
account_type: 'TYPE_B',
account_status: 'PENDING',
account_status_date: '2023-01-02',
account_number: 'TESTACC123',
account_id: null,
validated_at: null,
validated_by: null,
submitted_by_name: 'User Two',
},
],
};
Loading