Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(appeals): add environmental impact assessment screening page (a2-1882) #785

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BEGIN TRY

BEGIN TRAN;

-- AlterTable
ALTER TABLE [dbo].[Appeal] ADD [eiaScreeningRequired] BIT;

COMMIT TRAN;

END TRY
BEGIN CATCH

IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRAN;
END;
THROW

END CATCH
1 change: 1 addition & 0 deletions appeals/api/src/database/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ model Appeal {
withdrawalRequestDate DateTime?
caseResubmittedTypeId Int?
caseTransferredId String?
eiaScreeningRequired Boolean?
specialisms AppealSpecialism[]
allocation AppealAllocation?
allocationId Int?
Expand Down
1 change: 1 addition & 0 deletions appeals/api/src/server/endpoints/appeals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ interface SingleAppealDetailsResponse {
withdrawalRequestDate: Date | null;
};
isAffectingNeighbouringSites?: boolean | null;
eiaScreeningRequired?: boolean | null;
}

interface UpdateAppealRequest {
Expand Down
2 changes: 2 additions & 0 deletions appeals/api/src/server/endpoints/appeals.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { representationRoutes } from './representations/representations.routes.j
import { listedBuildingRoutes } from './listed-buildings/listed-buildings.routes.js';
import { caseNotesRoutes } from './case-notes/case-notes.routes.js';
import { representationRejectionReasonsRoutes } from './representation-rejection-reasons/representation-rejection-reasons.routes.js';
import { environmentalImpactAssessmentRoutes } from './environmental-impact-assessment/environmental-impact-assessment.routes.js';

import { default as appealDetailsRoutes } from './appeal-details/routes.js';

Expand Down Expand Up @@ -74,6 +75,7 @@ router.use(linkAppealsRoutes);
router.use(neighbouringSitesRoutes);
router.use(serviceUserRoutes);
router.use(withdrawalRoutes);
router.use(environmentalImpactAssessmentRoutes);
router.use(representationRoutes);
router.use(listedBuildingRoutes);
router.use(caseNotesRoutes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ const formatAppeal = (
createdAt: appeal.caseCreatedDate.toISOString(),
startedAt: appeal.caseStartedDate && appeal.caseStartedDate?.toISOString(),
validAt: appeal.caseValidDate && appeal.caseValidDate?.toISOString(),
documentationSummary: formatDocumentationSummary(appeal)
documentationSummary: formatDocumentationSummary(appeal),
eiaScreeningRequired: appeal.eiaScreeningRequired
};

// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @typedef {import('express').Request} Request */
/** @typedef {import('express').Response} Response */

import { updateEiaScreeningRequirement } from '#endpoints/environmental-impact-assessment/environmental-impact-assessment.service.js';

/**
* @param {Request} req
* @param {Response} res
* @returns {Promise<Response>}
*/
export const patchEiaScreeningRequired = async (req, res) => {
const { appeal } = req;

const eiaScreeningRequired = await updateEiaScreeningRequirement(
appeal.id,
req.body.eiaScreeningRequired
);

return res.send(eiaScreeningRequired);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Router as createRouter } from 'express';
import { patchEiaScreeningRequired } from '#endpoints/environmental-impact-assessment/environmental-impact-assessment.controller.js';
import { checkAppealExistsByIdAndAddToRequest } from '#middleware/check-appeal-exists-and-add-to-request.js';
import { asyncHandler } from '@pins/express';
import { getEiaScreeningRequirementValidator } from '#endpoints/environmental-impact-assessment/environmental-impact-assessment.validator.js';
import { getAppealValidator } from '#endpoints/appeals/appeals.validators.js';

const router = createRouter();

router.patch(
'/:appealId/eia-screening-required' /*
#swagger.tags = ['EIA Screening Required']
#swagger.path = '/appeals/{appealId}/eia-screening-required'
#swagger.description = Sets the EIA screening required boolean'
#swagger.parameters['azureAdUserId'] = {
in: 'header',
required: true,
example: '434bff4e-8191-4ce0-9a0a-91e5d6cdd882'
}
#swagger.requestBody = {
in: 'body',
description: 'EIA Screening Required request',
schema: { $ref: '#/definitions/EiaScreeningRequiredRequest' },
required: true
}
#swagger.responses[200] = {
description: 'Gets the eiaScreeningRequired boolean or null'
}
#swagger.responses[400] = {}
#swagger.responses[404] = {}
*/,
getAppealValidator,
getEiaScreeningRequirementValidator,
checkAppealExistsByIdAndAddToRequest,
asyncHandler(patchEiaScreeningRequired)
);

export { router as environmentalImpactAssessmentRoutes };
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import appealRepository from '#repositories/appeal.repository.js';

/**
*
* @param {Number} appealId
* @param {Boolean} eiaScreeningRequired
*
* @returns {Promise<Boolean | null>}
*/

export const updateEiaScreeningRequirement = async (appealId, eiaScreeningRequired) => {
const result = await appealRepository.setAppealEiaScreeningRequired(
appealId,
eiaScreeningRequired
);

return result?.eiaScreeningRequired || null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { composeMiddleware } from '@pins/express';
import { validationErrorHandler } from '#middleware/error-handler.js';
import { validateRequiredBooleanParameter } from '#common/validators/boolean-parameter.js';

const getEiaScreeningRequirementValidator = composeMiddleware(
validateRequiredBooleanParameter('eiaScreeningRequired'),
validationErrorHandler
);

export { getEiaScreeningRequirementValidator };
7 changes: 6 additions & 1 deletion appeals/api/src/server/openapi-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface AddBusinessDays {

export interface AppellantCaseData {
casedata?: {
/** @example "c6a2477d-52f9-45ef-a271-8ec9bff707a8" */
/** @example "755b15e1-46fd-49ae-8c12-6246ee1f395e" */
submissionId?: string;
/** @example true */
advertisedAppeal?: boolean;
Expand Down Expand Up @@ -2271,6 +2271,11 @@ export interface WithdrawalRequestRequest {
withdrawalRequestDate?: string;
}

export interface EiaScreeningRequiredRequest {
/** @example true */
eiaScreeningRequired?: boolean;
}

export interface Allocation {
level: string;
band: number;
Expand Down
64 changes: 63 additions & 1 deletion appeals/api/src/server/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3343,6 +3343,59 @@
}
}
},
"/appeals/{appealId}/eia-screening-required": {
"patch": {
"tags": ["EIA Screening Required"],
"description": "Sets the EIA screening required boolean",
"parameters": [
{
"name": "appealId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "azureAdUserId",
"in": "header",
"required": true,
"example": "434bff4e-8191-4ce0-9a0a-91e5d6cdd882",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Gets the eiaScreeningRequired boolean or null"
},
"400": {
"description": "Bad Request"
},
"404": {
"description": "Not Found"
}
},
"requestBody": {
"in": "body",
"description": "EIA Screening Required request",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EiaScreeningRequiredRequest"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/EiaScreeningRequiredRequest"
}
}
}
}
}
},
"/appeals/{appealId}/reps/count": {
"get": {
"tags": ["Representations"],
Expand Down Expand Up @@ -4556,7 +4609,7 @@
"properties": {
"submissionId": {
"type": "string",
"example": "c6a2477d-52f9-45ef-a271-8ec9bff707a8"
"example": "755b15e1-46fd-49ae-8c12-6246ee1f395e"
},
"advertisedAppeal": {
"type": "boolean",
Expand Down Expand Up @@ -9165,6 +9218,15 @@
}
}
},
"EiaScreeningRequiredRequest": {
"type": "object",
"properties": {
"eiaScreeningRequired": {
"type": "boolean",
"example": true
}
}
},
"Allocation": {
"type": "object",
"required": ["level", "band", "specialisms"],
Expand Down
17 changes: 17 additions & 0 deletions appeals/api/src/server/repositories/appeal.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ const setAppealWithdrawal = (id, withdrawalRequestDate) => {
});
};

/**
* @param {number} id
* @param {Boolean} eiaScreeningRequired
* @returns {PrismaPromise<import('#db-client').Appeal>}
*/
const setAppealEiaScreeningRequired = (id, eiaScreeningRequired) => {
return databaseConnector.appeal.update({
data: {
eiaScreeningRequired
},
where: {
id
}
});
};

/**
* @param {number} id
* @param {SetInvalidAppealDecisionRequest} data
Expand Down Expand Up @@ -365,6 +381,7 @@ export default {
setAppealDecision,
setAppealWithdrawal,
setInvalidAppealDecision,
setAppealEiaScreeningRequired,
linkAppeal,
unlinkAppeal,
getAppealsByIds
Expand Down
9 changes: 9 additions & 0 deletions appeals/api/src/server/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,15 @@ export const spec = {
}
}
},
EiaScreeningRequiredRequest: {
type: 'object',
properties: {
eiaScreeningRequired: {
type: 'boolean',
example: true
}
}
},
...ApiDefinitions
},
components: {}
Expand Down
1 change: 1 addition & 0 deletions appeals/e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/failed-tests
/cypress/videos
/cypress/screenshots
/cypress/downloads
/cypress/support/browserAuthData
cucumber-messages.ndjson
/reports/report.html
Binary file removed appeals/e2e/cypress/downloads/downloads.html
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@
export function getAppealDetailsFromId(apiClient, appealId) {
return apiClient.get(`appeals/${appealId}`).json();
}

/**
* @param {import('got').Got} apiClient
* @param {string} appealId
* @param {boolean} eiaScreeningRequired
* @returns {Promise<import('./appeal-details.types.js').WebAppeal>}
*/
export function setEnvironmentalImpactAssessmentScreening(
apiClient,
appealId,
eiaScreeningRequired
) {
return apiClient
.patch(`appeals/${appealId}/eia-screening-required`, {
json: { eiaScreeningRequired }
})
.json();
}
Loading
Loading