From 12bf786355c44e54f072e9770690b3963f723f51 Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Fri, 29 Sep 2023 10:36:03 -0700 Subject: [PATCH 01/15] SIMSBIOHUB-275: Removed Project Coordinator from codebase (pending database migration) --- api/src/models/project-create.test.ts | 75 --------- api/src/models/project-create.ts | 26 ---- api/src/models/project-update.ts | 20 --- api/src/models/project-view.ts | 27 ---- api/src/openapi/schemas/project.ts | 36 +---- api/src/paths/project/list.ts | 4 - api/src/paths/project/{projectId}/update.ts | 36 ----- api/src/paths/project/{projectId}/view.ts | 31 +--- api/src/repositories/project-repository.ts | 64 +------- api/src/services/eml-service.ts | 44 ++---- api/src/services/project-service.ts | 24 +-- .../search-filter/ProjectAdvancedFilters.tsx | 42 +----- .../ProjectCoordinatorForm.test.tsx | 61 -------- .../components/ProjectCoordinatorForm.tsx | 142 ------------------ .../projects/create/CreateProjectForm.tsx | 16 +- .../projects/edit/EditProjectForm.tsx | 12 -- .../projects/edit/EditProjectPage.tsx | 1 - .../projects/list/ProjectsListFilterForm.tsx | 8 +- .../features/projects/view/ProjectDetails.tsx | 9 -- .../components/ProjectCoordinator.test.tsx | 44 ------ .../view/components/ProjectCoordinator.tsx | 34 ----- app/src/hooks/api/useProjectApi.test.ts | 2 - app/src/interfaces/useProjectApi.interface.ts | 36 +---- app/src/test-helpers/project-helpers.ts | 7 - .../seeds/03_basic_project_survey_setup.ts | 10 -- .../smoke_1_CreateProjectMinimal.spec.ts | 2 - .../project/project-create-page.ts | 37 ----- 27 files changed, 24 insertions(+), 826 deletions(-) delete mode 100644 app/src/features/projects/components/ProjectCoordinatorForm.test.tsx delete mode 100644 app/src/features/projects/components/ProjectCoordinatorForm.tsx delete mode 100644 app/src/features/projects/view/components/ProjectCoordinator.test.tsx delete mode 100644 app/src/features/projects/view/components/ProjectCoordinator.tsx diff --git a/api/src/models/project-create.test.ts b/api/src/models/project-create.test.ts index 79e7e0b056..25cf59f608 100644 --- a/api/src/models/project-create.test.ts +++ b/api/src/models/project-create.test.ts @@ -1,7 +1,6 @@ import { expect } from 'chai'; import { describe } from 'mocha'; import { - PostCoordinatorData, PostIUCNData, PostLocationData, PostObjectivesData, @@ -17,10 +16,6 @@ describe('PostProjectObject', () => { projectPostObject = new PostProjectObject(null); }); - it('sets coordinator', function () { - expect(projectPostObject.coordinator).to.equal(null); - }); - it('sets project', function () { expect(projectPostObject.project).to.equal(null); }); @@ -97,10 +92,6 @@ describe('PostProjectObject', () => { before(() => { projectPostObject = new PostProjectObject(obj); }); - - it('sets coordinator', function () { - expect(projectPostObject.coordinator.first_name).to.equal(obj.coordinator.first_name); - }); }); }); @@ -200,72 +191,6 @@ describe('PostObjectivesData', () => { }); }); -describe('PostCoordinatorData', () => { - describe('No values provided', () => { - let projectCoordinatorData: PostCoordinatorData; - - before(() => { - projectCoordinatorData = new PostCoordinatorData(null); - }); - - it('sets first_name', function () { - expect(projectCoordinatorData.first_name).to.eql(null); - }); - - it('sets last_name', function () { - expect(projectCoordinatorData.last_name).to.eql(null); - }); - - it('sets email_address', function () { - expect(projectCoordinatorData.email_address).to.eql(null); - }); - - it('sets coordinator_agency', function () { - expect(projectCoordinatorData.coordinator_agency).to.eql(null); - }); - - it('sets share_contact_details', function () { - expect(projectCoordinatorData.share_contact_details).to.eql(false); - }); - }); - - describe('All values provided', () => { - let projectCoordinatorData: PostCoordinatorData; - - const obj = { - first_name: 'first', - last_name: 'last', - email_address: 'email@example.com', - coordinator_agency: 'agency', - share_contact_details: 'true' - }; - - before(() => { - projectCoordinatorData = new PostCoordinatorData(obj); - }); - - it('sets first_name', function () { - expect(projectCoordinatorData.first_name).to.eql(obj.first_name); - }); - - it('sets last_name', function () { - expect(projectCoordinatorData.last_name).to.eql(obj.last_name); - }); - - it('sets email_address', function () { - expect(projectCoordinatorData.email_address).to.eql(obj.email_address); - }); - - it('sets coordinator_agency', function () { - expect(projectCoordinatorData.coordinator_agency).to.eql(obj.coordinator_agency); - }); - - it('sets share_contact_details', function () { - expect(projectCoordinatorData.share_contact_details).to.eql(true); - }); - }); -}); - describe('PostIUCNData', () => { describe('No values provided', () => { let projectIUCNData: PostIUCNData; diff --git a/api/src/models/project-create.ts b/api/src/models/project-create.ts index c9f867414a..3c52222f07 100644 --- a/api/src/models/project-create.ts +++ b/api/src/models/project-create.ts @@ -12,7 +12,6 @@ const defaultLog = getLogger('models/project-create'); * @class PostProjectObject */ export class PostProjectObject { - coordinator: PostCoordinatorData; project: PostProjectData; objectives: PostObjectivesData; location: PostLocationData; @@ -22,7 +21,6 @@ export class PostProjectObject { constructor(obj?: any) { defaultLog.debug({ label: 'PostProjectObject', message: 'params', obj }); - this.coordinator = (obj?.coordinator && new PostCoordinatorData(obj.coordinator)) || null; this.project = (obj?.project && new PostProjectData(obj.project)) || null; this.objectives = (obj?.project && new PostObjectivesData(obj.objectives)) || null; this.location = (obj?.location && new PostLocationData(obj.location)) || null; @@ -31,30 +29,6 @@ export class PostProjectObject { } } -/** - * Processes POST /project contact data - * - * @export - * @class PostCoordinatorData - */ -export class PostCoordinatorData { - first_name: string; - last_name: string; - email_address: string; - coordinator_agency: string; - share_contact_details: boolean; - - constructor(obj?: any) { - defaultLog.debug({ label: 'PostCoordinatorData', message: 'params', obj }); - - this.first_name = obj?.first_name || null; - this.last_name = obj?.last_name || null; - this.email_address = obj?.email_address || null; - this.coordinator_agency = obj?.coordinator_agency || null; - this.share_contact_details = (obj?.share_contact_details === 'true' && true) || false; - } -} - /** * Processes POST /project project data. * diff --git a/api/src/models/project-update.ts b/api/src/models/project-update.ts index 0e83ed9e3d..871ac566f6 100644 --- a/api/src/models/project-update.ts +++ b/api/src/models/project-update.ts @@ -33,26 +33,6 @@ export class PutObjectivesData { } } -export class PutCoordinatorData { - first_name: string; - last_name: string; - email_address: string; - coordinator_agency: string; - share_contact_details: boolean; - revision_count: number; - - constructor(obj?: any) { - defaultLog.debug({ label: 'PutCoordinatorData', message: 'params', obj }); - - this.first_name = obj?.first_name || null; - this.last_name = obj?.last_name || null; - this.email_address = obj?.email_address || null; - this.coordinator_agency = obj?.coordinator_agency || null; - this.share_contact_details = (obj?.share_contact_details === 'true' && true) || false; - this.revision_count = obj?.revision_count ?? null; - } -} - export class PutLocationData { location_description: string; geometry: Feature[]; diff --git a/api/src/models/project-view.ts b/api/src/models/project-view.ts index 29741233e5..7d48c38f9d 100644 --- a/api/src/models/project-view.ts +++ b/api/src/models/project-view.ts @@ -4,7 +4,6 @@ import { ProjectMetadataPublish } from '../repositories/history-publish-reposito import { ProjectUser } from '../repositories/project-participation-repository'; export interface IProjectAdvancedFilters { - coordinator_agency?: string; permit_number?: string; project_programs?: number[]; start_date?: string; @@ -16,7 +15,6 @@ export interface IProjectAdvancedFilters { species?: number[]; } export interface IGetProject { - coordinator: GetCoordinatorData; project: ProjectData; objectives: GetObjectivesData; participants: ProjectUser[]; @@ -41,7 +39,6 @@ export const ProjectListData = z.object({ project_id: z.number(), uuid: z.string(), project_name: z.string(), - coordinator_agency: z.string(), project_programs: z.array(z.number()).default([]), regions: z.array(z.string()).default([]), start_date: z.string(), @@ -66,30 +63,6 @@ export class GetObjectivesData { } } -/** - * Pre-processes GET /projects/{id} coordinator data - * - * @export - * @class GetCoordinatorData - */ -export class GetCoordinatorData { - first_name: string; - last_name: string; - email_address: string; - coordinator_agency: string; - share_contact_details: string; - revision_count: number; - - constructor(coordinatorData?: any) { - this.first_name = coordinatorData?.coordinator_first_name || ''; - this.last_name = coordinatorData?.coordinator_last_name || ''; - this.email_address = coordinatorData?.coordinator_email_address || ''; - this.coordinator_agency = coordinatorData?.coordinator_agency_name || ''; - this.share_contact_details = coordinatorData?.coordinator_public ? 'true' : 'false'; - this.revision_count = coordinatorData?.revision_count ?? null; - } -} - /** * Pre-processes GET /projects/{id} location data * diff --git a/api/src/openapi/schemas/project.ts b/api/src/openapi/schemas/project.ts index d1bbfa0082..d94dc4446d 100644 --- a/api/src/openapi/schemas/project.ts +++ b/api/src/openapi/schemas/project.ts @@ -6,31 +6,8 @@ import { PROJECT_ROLE } from '../../constants/roles'; export const projectCreatePostRequestObject = { title: 'Project post request object', type: 'object', - required: ['coordinator', 'project', 'location', 'iucn', 'participants'], + required: ['project', 'location', 'iucn', 'participants'], properties: { - coordinator: { - title: 'Project coordinator', - type: 'object', - required: ['first_name', 'last_name', 'email_address', 'coordinator_agency', 'share_contact_details'], - properties: { - first_name: { - type: 'string' - }, - last_name: { - type: 'string' - }, - email_address: { - type: 'string' - }, - coordinator_agency: { - type: 'string' - }, - share_contact_details: { - type: 'string', - enum: ['true', 'false'] - } - } - }, project: { title: 'Project details', type: 'object', @@ -113,17 +90,6 @@ export const projectCreatePostRequestObject = { }; const projectUpdateProperties = { - coordinator: { - type: 'object', - properties: { - first_name: { type: 'string' }, - last_name: { type: 'string' }, - email_address: { type: 'string' }, - coordinator_agency: { type: 'string' }, - share_contact_details: { type: 'string' }, - revision_count: { type: 'number' } - } - }, project: { type: 'object', properties: {} }, objectives: { type: 'object', properties: {} }, location: { type: 'object', properties: {} }, diff --git a/api/src/paths/project/list.ts b/api/src/paths/project/list.ts index de1e5a0071..77350a74ec 100644 --- a/api/src/paths/project/list.ts +++ b/api/src/paths/project/list.ts @@ -36,10 +36,6 @@ GET.apiDoc = { 'application/json': { schema: { properties: { - coordinator_agency: { - type: 'string', - nullable: true - }, start_date: { type: 'string', nullable: true diff --git a/api/src/paths/project/{projectId}/update.ts b/api/src/paths/project/{projectId}/update.ts index 94271fc07d..32b21cef25 100644 --- a/api/src/paths/project/{projectId}/update.ts +++ b/api/src/paths/project/{projectId}/update.ts @@ -33,7 +33,6 @@ export const GET: Operation = [ ]; export enum GET_ENTITIES { - coordinator = 'coordinator', project = 'project', objectives = 'objectives', location = 'location', @@ -112,40 +111,6 @@ GET.apiDoc = { } } }, - coordinator: { - title: 'Project coordinator', - type: 'object', - nullable: true, - required: [ - 'first_name', - 'last_name', - 'email_address', - 'coordinator_agency', - 'share_contact_details', - 'revision_count' - ], - properties: { - first_name: { - type: 'string' - }, - last_name: { - type: 'string' - }, - email_address: { - type: 'string' - }, - coordinator_agency: { - type: 'string' - }, - share_contact_details: { - type: 'string', - enum: ['true', 'false'] - }, - revision_count: { - type: 'number' - } - } - }, objectives: { description: 'The project objectives', type: 'object', @@ -393,7 +358,6 @@ PUT.apiDoc = { }; export interface IUpdateProject { - coordinator: any | null; project: any | null; objectives: any | null; location: { geometry: Feature[]; location_description: string } | null; diff --git a/api/src/paths/project/{projectId}/view.ts b/api/src/paths/project/{projectId}/view.ts index 370013d274..aab169d805 100644 --- a/api/src/paths/project/{projectId}/view.ts +++ b/api/src/paths/project/{projectId}/view.ts @@ -63,7 +63,7 @@ GET.apiDoc = { properties: { projectData: { type: 'object', - required: ['project', 'coordinator', 'participants', 'objectives', 'location', 'iucn'], + required: ['project', 'participants', 'objectives', 'location', 'iucn'], properties: { project: { description: 'Basic project metadata', @@ -101,35 +101,6 @@ GET.apiDoc = { } } }, - coordinator: { - title: 'Project coordinator', - type: 'object', - required: [ - 'first_name', - 'last_name', - 'email_address', - 'coordinator_agency', - 'share_contact_details' - ], - properties: { - first_name: { - type: 'string' - }, - last_name: { - type: 'string' - }, - email_address: { - type: 'string' - }, - coordinator_agency: { - type: 'string' - }, - share_contact_details: { - type: 'string', - enum: ['true', 'false'] - } - } - }, participants: { title: 'Project participants', type: 'array', diff --git a/api/src/repositories/project-repository.ts b/api/src/repositories/project-repository.ts index 5ecc6e285b..7170f8e5b2 100644 --- a/api/src/repositories/project-repository.ts +++ b/api/src/repositories/project-repository.ts @@ -2,10 +2,9 @@ import { isArray } from 'lodash'; import SQL, { SQLStatement } from 'sql-template-strings'; import { ApiExecuteSQLError } from '../errors/api-error'; import { PostProjectObject } from '../models/project-create'; -import { PutCoordinatorData, PutLocationData, PutObjectivesData, PutProjectData } from '../models/project-update'; +import { PutLocationData, PutObjectivesData, PutProjectData } from '../models/project-update'; import { GetAttachmentsData, - GetCoordinatorData, GetIUCNClassificationData, GetLocationData, GetObjectivesData, @@ -38,7 +37,6 @@ export class ProjectRepository extends BaseRepository { p.start_date, p.end_date, p.revision_count, - p.coordinator_agency_name as coordinator_agency, array_remove(array_agg(DISTINCT rl.region_name), null) as regions, array_agg(distinct p2.program_id) as project_programs FROM @@ -72,10 +70,6 @@ export class ProjectRepository extends BaseRepository { } if (filterFields && Object.keys(filterFields).length !== 0 && filterFields.constructor === Object) { - if (filterFields.coordinator_agency) { - sqlStatement.append(SQL` AND p.coordinator_agency_name = ${filterFields.coordinator_agency}`); - } - if (filterFields.start_date && !filterFields.end_date) { sqlStatement.append(SQL` AND p.start_date >= ${filterFields.start_date}`); } @@ -105,7 +99,6 @@ export class ProjectRepository extends BaseRepository { if (filterFields.keyword) { const keyword_string = '%'.concat(filterFields.keyword).concat('%'); sqlStatement.append(SQL` AND p.name ilike ${keyword_string}`); - sqlStatement.append(SQL` OR p.coordinator_agency_name ilike ${keyword_string}`); sqlStatement.append(SQL` OR a.name ilike ${keyword_string}`); sqlStatement.append(SQL` OR s.name ilike ${keyword_string}`); } @@ -117,7 +110,6 @@ export class ProjectRepository extends BaseRepository { p.name, p.start_date, p.end_date, - p.coordinator_agency_name, p.uuid, p.revision_count `); @@ -165,11 +157,6 @@ export class ProjectRepository extends BaseRepository { p.start_date, p.end_date, p.comments, - p.coordinator_first_name, - p.coordinator_last_name, - p.coordinator_email_address, - p.coordinator_agency_name, - p.coordinator_public, p.geojson as geometry, p.create_date, p.create_user, @@ -226,34 +213,6 @@ export class ProjectRepository extends BaseRepository { return new GetObjectivesData(result); } - async getCoordinatorData(projectId: number): Promise { - const sqlStatement = SQL` - SELECT - coordinator_first_name, - coordinator_last_name, - coordinator_email_address, - coordinator_agency_name, - coordinator_public, - revision_count - FROM - project - WHERE - project_id = ${projectId}; - `; - - const response = await this.connection.sql(sqlStatement); - const result = response?.rows?.[0]; - - if (!result) { - throw new ApiExecuteSQLError('Failed to get project contact data', [ - 'ProjectRepository->getCoordinatorData', - 'rows was null or undefined, expected rows != null' - ]); - } - - return new GetCoordinatorData(result); - } - async getLocationData(projectId: number): Promise { const sqlStatement = SQL` SELECT @@ -366,11 +325,6 @@ export class ProjectRepository extends BaseRepository { start_date, end_date, comments, - coordinator_first_name, - coordinator_last_name, - coordinator_email_address, - coordinator_agency_name, - coordinator_public, geojson, geography ) VALUES ( @@ -380,11 +334,6 @@ export class ProjectRepository extends BaseRepository { ${postProjectData.project.start_date}, ${postProjectData.project.end_date}, ${postProjectData.project.comments}, - ${postProjectData.coordinator.first_name}, - ${postProjectData.coordinator.last_name}, - ${postProjectData.coordinator.email_address}, - ${postProjectData.coordinator.coordinator_agency}, - ${postProjectData.coordinator.share_contact_details}, ${JSON.stringify(postProjectData.location.geometry)} `; @@ -526,10 +475,9 @@ export class ProjectRepository extends BaseRepository { project: PutProjectData | null, location: PutLocationData | null, objectives: PutObjectivesData | null, - coordinator: PutCoordinatorData | null, revision_count: number ): Promise { - if (!project && !location && !objectives && !coordinator) { + if (!project && !location && !objectives) { // Nothing to update throw new ApiExecuteSQLError('Nothing to update for Project Data', [ 'ProjectRepository->updateProjectData', @@ -578,14 +526,6 @@ export class ProjectRepository extends BaseRepository { sqlSetStatements.push(SQL`objectives = ${objectives.objectives}`); } - if (coordinator) { - sqlSetStatements.push(SQL`coordinator_first_name = ${coordinator.first_name}`); - sqlSetStatements.push(SQL`coordinator_last_name = ${coordinator.last_name}`); - sqlSetStatements.push(SQL`coordinator_email_address = ${coordinator.email_address}`); - sqlSetStatements.push(SQL`coordinator_agency_name = ${coordinator.coordinator_agency}`); - sqlSetStatements.push(SQL`coordinator_public = ${coordinator.share_contact_details}`); - } - sqlSetStatements.forEach((item, index) => { sqlStatement.append(item); if (index < sqlSetStatements.length - 1) { diff --git a/api/src/services/eml-service.ts b/api/src/services/eml-service.ts index 813287244b..289db68d38 100644 --- a/api/src/services/eml-service.ts +++ b/api/src/services/eml-service.ts @@ -665,45 +665,30 @@ export class EmlService extends DBService { /** * Creates an object representing the dataset creator from the given projectData. + * + * @TODO * * @param {IGetProject} projectData * @return {*} {Record} * @memberof EmlService */ _getProjectDatasetCreator(projectData: IGetProject): Record { - const primaryContact = projectData.coordinator; - if (JSON.parse(primaryContact.share_contact_details)) { - // return full details of the primary contact iff it is public. - return { - organizationName: primaryContact.coordinator_agency, - electronicMailAddress: primaryContact.email_address - }; - } - - return { organizationName: primaryContact.coordinator_agency }; + return { organizationName: null }; } /** * Creates an object representing the primary contact for the given project. + * + * @TODO * * @param {IGetProject} projectData * @return {*} {Record} * @memberof EmlService */ _getProjectContact(projectData: IGetProject): Record { - const primaryContact = projectData.coordinator; - - if (JSON.parse(primaryContact.share_contact_details)) { - // return full details of the primary contact iff it is public - return { - individualName: { givenName: primaryContact.first_name, surName: primaryContact.last_name }, - organizationName: primaryContact.coordinator_agency, - electronicMailAddress: primaryContact.email_address - }; - } - return { organizationName: primaryContact.coordinator_agency }; + return { organizationName: null }; } /** @@ -725,27 +710,16 @@ export class EmlService extends DBService { /** * Creates an object representing all contacts for the given project. + * + * @TODO * * @param {IGetProject} projectData * @return {*} {Record[]} * @memberof EmlService */ _getProjectPersonnel(projectData: IGetProject): Record[] { - const primaryContact = projectData.coordinator; - - if (JSON.parse(primaryContact.share_contact_details)) { - // return full details of the primary contact iff it is public - return [ - { - individualName: { givenName: primaryContact.first_name, surName: primaryContact.last_name }, - organizationName: primaryContact.coordinator_agency, - electronicMailAddress: primaryContact.email_address, - role: 'pointOfContact' - } - ]; - } - return [{ organizationName: primaryContact.coordinator_agency }]; + return [{ organizationName: null }]; } /** diff --git a/api/src/services/project-service.ts b/api/src/services/project-service.ts index 36a6f5e8c2..8d0a1615e3 100644 --- a/api/src/services/project-service.ts +++ b/api/src/services/project-service.ts @@ -6,7 +6,6 @@ import { HTTP400 } from '../errors/http-error'; import { IPostIUCN, PostProjectObject } from '../models/project-create'; import { IPutIUCN, - PutCoordinatorData, PutIUCNData, PutLocationData, PutObjectivesData, @@ -14,7 +13,6 @@ import { } from '../models/project-update'; import { GetAttachmentsData, - GetCoordinatorData, GetIUCNClassificationData, GetLocationData, GetObjectivesData, @@ -70,7 +68,6 @@ export class ProjectService extends DBService { name: row.project_name, start_date: row.start_date, end_date: row.end_date, - coordinator_agency: row.coordinator_agency, completion_status: (row.end_date && moment(row.end_date).endOf('day').isBefore(moment()) && COMPLETION_STATUS.COMPLETED) || COMPLETION_STATUS.ACTIVE, @@ -83,14 +80,12 @@ export class ProjectService extends DBService { const [ projectData, objectiveData, - coordinatorData, projectParticipantsData, locationData, iucnData ] = await Promise.all([ this.getProjectData(projectId), this.getObjectivesData(projectId), - this.getCoordinatorData(projectId), this.getProjectParticipantsData(projectId), this.getLocationData(projectId), this.getIUCNClassificationData(projectId) @@ -99,7 +94,6 @@ export class ProjectService extends DBService { return { project: projectData, objectives: objectiveData, - coordinator: coordinatorData, participants: projectParticipantsData, location: locationData, iucn: iucnData @@ -121,7 +115,6 @@ export class ProjectService extends DBService { async getProjectEntitiesById(projectId: number, entities: string[]): Promise> { const results: Partial = { - coordinator: undefined, project: undefined, objectives: undefined, location: undefined, @@ -130,14 +123,6 @@ export class ProjectService extends DBService { const promises: Promise[] = []; - if (entities.includes(GET_ENTITIES.coordinator)) { - promises.push( - this.getCoordinatorData(projectId).then((value) => { - results.coordinator = value; - }) - ); - } - if (entities.includes(GET_ENTITIES.location)) { promises.push( this.getLocationData(projectId).then((value) => { @@ -191,10 +176,6 @@ export class ProjectService extends DBService { return this.projectRepository.getObjectivesData(projectId); } - async getCoordinatorData(projectId: number): Promise { - return this.projectRepository.getCoordinatorData(projectId); - } - async getProjectParticipantsData(projectId: number): Promise { return this.projectParticipationService.getProjectParticipants(projectId); } @@ -368,7 +349,7 @@ export class ProjectService extends DBService { async updateProject(projectId: number, entities: IUpdateProject): Promise { const promises: Promise[] = []; - if (entities?.project || entities?.location || entities?.objectives || entities?.coordinator) { + if (entities?.project || entities?.location || entities?.objectives) { promises.push(this.updateProjectData(projectId, entities)); } @@ -404,14 +385,12 @@ export class ProjectService extends DBService { const putProjectData = (entities?.project && new PutProjectData(entities.project)) || null; const putLocationData = (entities?.location && new PutLocationData(entities.location)) || null; const putObjectivesData = (entities?.objectives && new PutObjectivesData(entities.objectives)) || null; - const putCoordinatorData = (entities?.coordinator && new PutCoordinatorData(entities.coordinator)) || null; // Update project table const revision_count = putProjectData?.revision_count ?? putLocationData?.revision_count ?? putObjectivesData?.revision_count ?? - putCoordinatorData?.revision_count ?? null; if (!revision_count && revision_count !== 0) { @@ -423,7 +402,6 @@ export class ProjectService extends DBService { putProjectData, putLocationData, putObjectivesData, - putCoordinatorData, revision_count ); } diff --git a/app/src/components/search-filter/ProjectAdvancedFilters.tsx b/app/src/components/search-filter/ProjectAdvancedFilters.tsx index dd4fdb3873..7f04162e8f 100644 --- a/app/src/components/search-filter/ProjectAdvancedFilters.tsx +++ b/app/src/components/search-filter/ProjectAdvancedFilters.tsx @@ -1,7 +1,6 @@ import FormControl from '@mui/material/FormControl'; import Grid from '@mui/material/Grid'; import assert from 'assert'; -import AutocompleteFreeSoloField from 'components/fields/AutocompleteFreeSoloField'; import CustomTextField from 'components/fields/CustomTextField'; import MultiAutocompleteFieldVariableSize, { IMultiAutocompleteFieldOption @@ -11,10 +10,9 @@ import { CodesContext } from 'contexts/codesContext'; import { useFormikContext } from 'formik'; import { useBiohubApi } from 'hooks/useBioHubApi'; import { debounce } from 'lodash-es'; -import React, { useContext, useMemo } from 'react'; +import { useContext, useMemo } from 'react'; export interface IProjectAdvancedFilters { - coordinator_agency: string; permit_number: string; project_programs: number[]; start_date: string; @@ -27,7 +25,6 @@ export interface IProjectAdvancedFilters { } export const ProjectAdvancedFiltersInitialValues: IProjectAdvancedFilters = { - coordinator_agency: '', permit_number: '', project_programs: [], start_date: '', @@ -39,16 +36,12 @@ export const ProjectAdvancedFiltersInitialValues: IProjectAdvancedFilters = { species: [] }; -export interface IProjectAdvancedFiltersProps { - coordinator_agency: string[]; -} - /** * Project - Advanced filters * * @return {*} */ -const ProjectAdvancedFilters: React.FC = (props) => { +const ProjectAdvancedFilters = () => { const formikProps = useFormikContext(); const biohubApi = useBiohubApi(); @@ -107,28 +100,6 @@ const ProjectAdvancedFilters: React.FC = (props) = }) || [] } /> - {/* */} @@ -140,15 +111,6 @@ const ProjectAdvancedFilters: React.FC = (props) = endRequired={false} /> - - - diff --git a/app/src/features/projects/components/ProjectCoordinatorForm.test.tsx b/app/src/features/projects/components/ProjectCoordinatorForm.test.tsx deleted file mode 100644 index 65ca37e5f9..0000000000 --- a/app/src/features/projects/components/ProjectCoordinatorForm.test.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import ProjectCoordinatorForm, { - ProjectCoordinatorInitialValues, - ProjectCoordinatorYupSchema -} from 'features/projects/components/ProjectCoordinatorForm'; -import { Formik } from 'formik'; -import { render, waitFor } from 'test-helpers/test-utils'; - -const handleSaveAndNext = jest.fn(); - -const agencies = ['Agency 1', 'Agency 2', 'Agency 3']; - -const projectCoordinatorFilledValues = { - coordinator: { - first_name: 'Nerea', - last_name: 'Oneal', - email_address: 'quxu@mailinator.com', - coordinator_agency: 'Agency 3', - share_contact_details: 'true' - } -}; - -describe('Project Contact Form', () => { - it('renders correctly the empty component correctly', async () => { - const { getByLabelText } = render( - { - handleSaveAndNext(values); - }}> - {() => } - - ); - - await waitFor(() => { - expect(getByLabelText('First Name', { exact: false })).toBeVisible(); - }); - }); - - it('renders correctly the filled component correctly', async () => { - const { getByLabelText, getByDisplayValue } = render( - { - handleSaveAndNext(values); - }}> - {() => } - - ); - - await waitFor(() => { - expect(getByLabelText('First Name', { exact: false })).toBeVisible(); - expect(getByDisplayValue('Nerea', { exact: false })).toBeVisible(); - }); - }); -}); diff --git a/app/src/features/projects/components/ProjectCoordinatorForm.tsx b/app/src/features/projects/components/ProjectCoordinatorForm.tsx deleted file mode 100644 index ee881b9e9c..0000000000 --- a/app/src/features/projects/components/ProjectCoordinatorForm.tsx +++ /dev/null @@ -1,142 +0,0 @@ -import Box from '@mui/material/Box'; -import FormControl from '@mui/material/FormControl'; -import FormControlLabel from '@mui/material/FormControlLabel'; -import FormHelperText from '@mui/material/FormHelperText'; -import Grid from '@mui/material/Grid'; -import Radio from '@mui/material/Radio'; -import RadioGroup from '@mui/material/RadioGroup'; -import Typography from '@mui/material/Typography'; -import AutocompleteFreeSoloField from 'components/fields/AutocompleteFreeSoloField'; -import CustomTextField from 'components/fields/CustomTextField'; -import { useFormikContext } from 'formik'; -import { ICreateProjectRequest } from 'interfaces/useProjectApi.interface'; -import React from 'react'; -import yup from 'utils/YupSchema'; - -export interface IProjectCoordinatorForm { - coordinator: { - first_name: string; - last_name: string; - email_address: string; - coordinator_agency: string; - share_contact_details: string; - }; -} - -export const ProjectCoordinatorInitialValues: IProjectCoordinatorForm = { - coordinator: { - first_name: '', - last_name: '', - email_address: '', - coordinator_agency: '', - share_contact_details: 'false' - } -}; - -export const ProjectCoordinatorYupSchema = yup.object().shape({ - coordinator: yup.object().shape({ - first_name: yup.string().max(50, 'Cannot exceed 50 characters').required('First Name is Required'), - last_name: yup.string().max(50, 'Cannot exceed 50 characters').required('Last Name is Required'), - email_address: yup - .string() - .max(500, 'Cannot exceed 500 characters') - .email('Must be a valid email address') - .required('Business Email Address is Required'), - coordinator_agency: yup - .string() - .max(300, 'Cannot exceed 300 characters') - .required('Coordinator Agency is Required') - .nullable(), - share_contact_details: yup.string().required('Please select an option') - }) -}); - -export interface IProjectCoordinatorFormProps { - coordinator_agency: string[]; -} - -/** - * Create project - coordinator fields - * - * @return {*} - */ -const ProjectCoordinatorForm: React.FC = (props) => { - const { values, touched, handleSubmit, errors, handleChange } = useFormikContext(); - - return ( -
- - - - - - - - - - - - - - - - - - Share Contact Details - - - Do you want the project contact's name and email address visible to the public? - - - - } - label="No" - /> - } - label="Yes" - /> - {errors.coordinator?.share_contact_details} - - - - -
- ); -}; - -export default ProjectCoordinatorForm; diff --git a/app/src/features/projects/create/CreateProjectForm.tsx b/app/src/features/projects/create/CreateProjectForm.tsx index 10885bc677..862990f059 100644 --- a/app/src/features/projects/create/CreateProjectForm.tsx +++ b/app/src/features/projects/create/CreateProjectForm.tsx @@ -11,10 +11,6 @@ import { IGetAllCodeSetsResponse } from 'interfaces/useCodesApi.interface'; import { ICreateProjectRequest, IGetProjectParticipant } from 'interfaces/useProjectApi.interface'; import React, { useContext } from 'react'; import { alphabetizeObjects } from 'utils/Utils'; -import ProjectCoordinatorForm, { - ProjectCoordinatorInitialValues, - ProjectCoordinatorYupSchema -} from '../components/ProjectCoordinatorForm'; import ProjectDetailsForm, { ProjectDetailsFormInitialValues, ProjectDetailsFormYupSchema @@ -48,13 +44,12 @@ export interface ICreateProjectForm { export const initialProjectFieldData: ICreateProjectRequest = { ...ProjectDetailsFormInitialValues, ...ProjectObjectivesFormInitialValues, - ...ProjectCoordinatorInitialValues, ...ProjectLocationFormInitialValues, ...ProjectIUCNFormInitialValues, ...ProjectUserRoleFormInitialValues }; -export const validationProjectYupSchema = ProjectCoordinatorYupSchema.concat(ProjectDetailsFormYupSchema) +export const validationProjectYupSchema = ProjectDetailsFormYupSchema .concat(ProjectObjectivesFormYupSchema) .concat(ProjectUserRoleYupSchema); // TODO: (https://apps.nrs.gov.bc.ca/int/jira/browse/SIMSBIOHUB-161) Commenting out location form (yup schema) temporarily, while its decided where exactly project/survey locations should be defined @@ -169,15 +164,6 @@ const CreateProjectForm: React.FC = (props) => { - - }> - - - = (props) => { - - }> - - - { const editProjectDataLoader = useDataLoader((projectId: number) => biohubApi.project.getProjectForUpdate(projectId, [ - UPDATE_GET_ENTITIES.coordinator, UPDATE_GET_ENTITIES.project, UPDATE_GET_ENTITIES.objectives, UPDATE_GET_ENTITIES.location, diff --git a/app/src/features/projects/list/ProjectsListFilterForm.tsx b/app/src/features/projects/list/ProjectsListFilterForm.tsx index 155b47c005..e0f707c2a1 100644 --- a/app/src/features/projects/list/ProjectsListFilterForm.tsx +++ b/app/src/features/projects/list/ProjectsListFilterForm.tsx @@ -39,13 +39,7 @@ const ProjectsListFilterForm: React.FC = (props) = <> - { - return item.name; - }) || [] - } - /> +