From 6e16a4995602752793cfa400bd70abf3eed9b355 Mon Sep 17 00:00:00 2001 From: Stephen Daly Date: Thu, 11 Jan 2024 11:24:16 +0000 Subject: [PATCH] PP-11212 Small refactorings - Remove unused enum values - Extract some types declared inline into interfaces --- src/lib/providers.ts | 2 - .../gateway_accounts/gateway_accounts.http.ts | 48 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/lib/providers.ts b/src/lib/providers.ts index f816fa67..5f3ac985 100644 --- a/src/lib/providers.ts +++ b/src/lib/providers.ts @@ -1,7 +1,5 @@ export const providers = { sandbox: 'sandbox', worldpay: 'worldpay', - smartpay: 'smartpay', - epdq: 'epdq', stripe: 'stripe' } diff --git a/src/web/modules/gateway_accounts/gateway_accounts.http.ts b/src/web/modules/gateway_accounts/gateway_accounts.http.ts index 3476ab95..39d772c1 100644 --- a/src/web/modules/gateway_accounts/gateway_accounts.http.ts +++ b/src/web/modules/gateway_accounts/gateway_accounts.http.ts @@ -72,6 +72,19 @@ async function listCSV(req: Request, res: Response): Promise { res.status(200).send(format(data)) } +interface CreateGatewayAccountPageData { + linkedCredentials: string; + live: string; + provider: string; + recovered?: object; + service?: Service; + description?: string; + flash: object; + errors?: ClientFormError[]; + errorMap?: object; + csrf: string; +} + async function create(req: Request, res: Response): Promise { const serviceId = req.query.service as string const live = req.query.live as string @@ -81,18 +94,7 @@ async function create(req: Request, res: Response): Promise { throw new Error('Expected "live" and "provider" query parameters') } - const context: { - linkedCredentials: string; - live: string; - provider: string; - recovered?: object; - service?: Service; - description?: string; - flash: object; - errors?: ClientFormError[]; - errorMap?: object; - csrf: string; - } = { + const context: CreateGatewayAccountPageData = { linkedCredentials: req.query.credentials as string, live, provider, @@ -630,6 +632,17 @@ async function searchRequest(req: Request, res: Response, next: NextFunction): P } } +interface AgentInitiatedMotoPageData { + account: GatewayAccount; + service: Service; + products: Product[]; + csrf: string; + formValues?: object; + flash: object; + errors?: object; + errorMap?: object[]; +} + async function agentInitiatedMotoPage( req: Request, res: Response @@ -642,16 +655,7 @@ async function agentInitiatedMotoPage( Products.accounts.listProductsByType(id, ProductType.Moto) ]) - const context: { - account: GatewayAccount; - service: Service; - products: Product[]; - csrf: string; - formValues?: object; - flash: object; - errors?: object; - errorMap?: object[]; - } = { + const context: AgentInitiatedMotoPageData = { account: account, service: service, products: products,