@ministryofjustice/probation-search-frontend
Version:
A shared UI component to search for probation cases from within your Express/Nunjucks application
51 lines (50 loc) • 1.5 kB
TypeScript
import { RequestHandler } from 'express';
import { AuthenticationClient } from '@ministryofjustice/hmpps-auth-clients';
import { Environment, EnvironmentConfig } from '../environments';
import SearchService from './searchService';
import { ProbationSearchResult } from '../data/probationSearchClient';
export interface CaseSearchOptions {
environment: Environment | EnvironmentConfig;
hmppsAuthClient: AuthenticationClient;
resultPath?: (crn: string) => string;
extraColumns?: {
header: string;
value: (result: ProbationSearchResult) => string;
}[];
maxQueryLength?: number;
allowEmptyQuery?: boolean;
pageSize?: number;
localData?: ProbationSearchResult[];
}
export default class CaseSearchService implements SearchService {
private readonly options;
private readonly client;
constructor(options: CaseSearchOptions);
post: RequestHandler;
get: RequestHandler;
/**
* Render an empty search screen
* @param res
* @param next
* @private
*/
private noSearch;
/**
* Render an error message
* @param req
* @param res
* @param next
* @param text
* @param query
* @param errorMessage
* @private
*/
private errorMessage;
/**
* These parameters are required in the Nunjucks component, we ensure they are
* passed through from the Express router via the results param.
* @param res
* @private
*/
private securityContext;
}