-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from hmcts/feature/EUI-1450-demo-develop-ud
Feature/eui 1450 demo develop ud
- Loading branch information
Showing
62 changed files
with
1,453 additions
and
239 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FeeAccount } from "../interfaces/feeAccountPayload" | ||
import { http } from '../lib/http' | ||
|
||
export function getAccountUrl(baseUrl: string, accountName: string) { | ||
return `${baseUrl}/accounts/${accountName}` | ||
} | ||
|
||
export function getAccount(accountNumber: string, url: string): Promise<any> { | ||
return new Promise((resolve, reject) => { | ||
http.get(url) | ||
.then(account => { | ||
resolve(account) | ||
}) | ||
.catch(err => { | ||
err && err.status && err.status === 404 ? resolve({data: getMissingFeeAccount(accountNumber), status: 404}) : reject(err) | ||
}) | ||
}) | ||
} | ||
|
||
export function getMissingFeeAccount(accountNumber: string): FeeAccount { | ||
return { | ||
account_number: accountNumber, | ||
account_name: null, | ||
credit_limit: null, | ||
available_balance: 0, | ||
status: null, | ||
effective_date: new Date(), | ||
} | ||
} |
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 |
---|---|---|
@@ -1,51 +1,54 @@ | ||
import { AxiosPromise } from 'axios' | ||
import * as express from 'express' | ||
import { FeeAccount } from '../interfaces/feeAccountPayload' | ||
import { config } from '../lib/config' | ||
import { http } from '../lib/http' | ||
import { getAccount, getAccountUrl } from './accountUtil' | ||
|
||
async function handleAddressRoute(req, res) { | ||
let errReport: any | ||
if (!req.query.accountNames) { | ||
errReport = { | ||
apiError: 'Account is missing', | ||
apiStatusCode: '400', | ||
apiStatusCode: 400, | ||
message: 'Fee And Pay route error', | ||
} | ||
res.status(500).send(errReport) | ||
res.status(errReport.apiStatusCode).send(errReport) | ||
} | ||
const accountNames = req.query.accountNames.split(',') | ||
console.log('accountNames', accountNames) | ||
const accounts = new Array() | ||
const accounts = new Array<FeeAccount>() | ||
const accountPromises = new Array<AxiosPromise<any>>() | ||
accountNames.forEach((accountName: string) => accountPromises.push(getAccount(accountName))) | ||
|
||
accountNames.forEach((accountNumber: string) => { | ||
const url = getAccountUrl(config.services.feeAndPayApi, accountNumber) | ||
accountPromises.push(getAccount(accountNumber, url)) | ||
}) | ||
let responseStatusCode | ||
try { | ||
await Promise.all(accountPromises).then(allAccounts => { | ||
allAccounts.forEach(account => { | ||
accounts.push(account.data) | ||
await Promise.all(accountPromises).then(allAccounts => { | ||
allAccounts.forEach(account => { | ||
if (account.status === 404) { | ||
responseStatusCode = 404 | ||
} | ||
accounts.push(account.data) | ||
}) | ||
}) | ||
}) | ||
} catch (error) { | ||
console.error(error) | ||
errReport = { | ||
apiError: error && error.data && error.data.message ? error.data.message : error, | ||
apiStatusCode: error && error.status ? error.status : '', | ||
message: `Fee And Pay route error `, | ||
} | ||
res.status(500).send(errReport) | ||
res.status(error.status).send(errReport) | ||
return | ||
} | ||
res.send(accounts) | ||
} | ||
|
||
function getAccount(accountName: string): AxiosPromise<any> { | ||
const url = `${config.services.feeAndPayApi}/accounts/${accountName}` | ||
const promise = http.get(url) | ||
return promise | ||
if (responseStatusCode) { | ||
res.status(responseStatusCode).send(accounts) | ||
} else { | ||
res.send(accounts) | ||
} | ||
} | ||
|
||
export const router = express.Router({ mergeParams: true }) | ||
|
||
router.get('', handleAddressRoute) | ||
|
||
export default router |
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,44 @@ | ||
import * as express from 'express' | ||
import { ErrorReport } from '../interfaces/errorReport' | ||
import { config } from '../lib/config' | ||
import { http } from '../lib/http' | ||
import * as log4jui from '../lib/log4jui' | ||
|
||
export const router = express.Router({ mergeParams: true }) | ||
const logger = log4jui.getLogger('outgoing') | ||
|
||
router.put('', inviteUserRoute) | ||
|
||
async function inviteUserRoute(req, res) { | ||
let errReport: ErrorReport | ||
if (!req.params.userId) { | ||
errReport = getErrorReport('UserId is missing', '400', 'User Permissions route error') | ||
res.status(400).send(errReport) | ||
return | ||
} | ||
const payload = req.body | ||
try { | ||
const response = await http.put(getEditPermissionsUrl(config.services.rdProfessionalApi, req.params.userId), payload) | ||
logger.info('response::', response.data) | ||
res.send(response.data) | ||
} catch (error) { | ||
logger.info('error', error) | ||
errReport = getErrorReport(getErrorMessage(error), error.status, getErrorMessage(error)) | ||
res.status(error.status).send(errReport) | ||
} | ||
} | ||
|
||
function getErrorMessage(error: any): string { | ||
return error && error.data ? error.data.message : '' | ||
} | ||
function getErrorReport(apiError: string, apiStatusCode: string, message: string): ErrorReport { | ||
return { | ||
apiError, | ||
apiStatusCode, | ||
message, | ||
} | ||
} | ||
function getEditPermissionsUrl(rdProfessionalApiUrl: string, userId: string): string { | ||
return `${rdProfessionalApiUrl}/refdata/external/v1/organisations/users/${userId}` | ||
} | ||
export default router |
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,5 @@ | ||
export interface ErrorReport { | ||
apiError: string | ||
apiStatusCode: string | ||
message: string | ||
} |
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,8 @@ | ||
export interface FeeAccount { | ||
account_number: string | ||
account_name: string | ||
credit_limit: number | ||
available_balance: number | ||
status: string | ||
effective_date: Date | ||
} |
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
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,27 @@ | ||
import * as express from 'express' | ||
import { config } from '../lib/config' | ||
import { http } from '../lib/http' | ||
import * as log4jui from '../lib/log4jui' | ||
|
||
export const router = express.Router({ mergeParams: true }) | ||
const logger = log4jui.getLogger('outgoing') | ||
|
||
router.put('/', suspendUser) | ||
|
||
async function suspendUser(req, res) { | ||
const payload = req.body | ||
try { | ||
const response = await http.put(`${config.services.rdProfessionalApi}/refdata/external/v1/organisations/users/${req.params.userId}`, payload) | ||
logger.info('response::', response.data) | ||
res.send(response.data) | ||
} catch (error) { | ||
logger.info('error', error) | ||
const errReport = { | ||
apiError: error.data.message, | ||
apiStatusCode: error.status, | ||
message: error.data.message, | ||
} | ||
res.status(error.status).send(errReport) | ||
} | ||
} | ||
export default router |
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
16 changes: 16 additions & 0 deletions
16
src/fee-accounts/components/notifications/fee-account-error-notification.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,16 @@ | ||
<ng-container *ngIf="errorMessages.length > 0"> | ||
<div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="error-summary"> | ||
<h2 class="govuk-error-summary__title" id="error-summary-title"> | ||
There is a problem | ||
</h2> | ||
<div class="govuk-error-summary__body"> | ||
<ul class="govuk-list govuk-error-summary__list"> | ||
<ng-container *ngFor="let errorMessage of errorMessages"> | ||
<li> | ||
<a href="#fee-error">{{ errorMessage }}</a> | ||
</li> | ||
</ng-container> | ||
</ul> | ||
</div> | ||
</div> | ||
</ng-container> |
14 changes: 14 additions & 0 deletions
14
src/fee-accounts/components/notifications/fee-account-error-notification.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,14 @@ | ||
import {Component, OnInit, Input} from '@angular/core'; | ||
@Component({ | ||
selector: 'app-fee-account-notification-banner', | ||
templateUrl: './fee-account-error-notification.component.html', | ||
}) | ||
|
||
export class FeeAccountErrorNotificationComponent implements OnInit { | ||
constructor() {} | ||
@Input() public errorMessages: string[]; | ||
public ngOnInit(): void { | ||
|
||
} | ||
|
||
} |
9 changes: 8 additions & 1 deletion
9
src/fee-accounts/components/transactions/transactions.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 |
---|---|---|
@@ -1 +1,8 @@ | ||
<app-govuk-table [columnConfig]="columnConfig" [rows]="tableRows" [firstCellIsHeader]="false" [caption]="''"></app-govuk-table> | ||
<ng-container *ngIf="transactions.length > 0; else noRows"> | ||
<app-govuk-table | ||
[columnConfig]="columnConfig" [rows]="transactions" [firstCellIsHeader]="false" [caption]="''" | ||
></app-govuk-table> | ||
</ng-container> | ||
<ng-template #noRows> | ||
<p>No transactions found.</p> | ||
</ng-template> |
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
Oops, something went wrong.