From 5fa44e32d7afa92cccd9252b9aee403e4b1a2c01 Mon Sep 17 00:00:00 2001 From: gregorylavery <100631366+gregorylavery@users.noreply.github.com> Date: Thu, 26 Sep 2024 14:16:04 -0700 Subject: [PATCH 1/7] Recreated the fixes directly on the Orca release avoiding the rebase. --- backend/src/types/models/code-tables/index.ts | 1 + .../code-tables/schedule-sector-xref.ts | 6 ++++++ .../src/v1/code-table/code-table.service.ts | 20 ++++++++++++++++++ .../ceeb/ceeb-decision/decision-form.tsx | 21 +++++++++++++++++-- .../ceeb/ceeb-decision/decision-item.tsx | 11 +++++++++- .../src/app/constants/code-table-types.ts | 2 ++ frontend/src/app/store/migrations.ts | 2 ++ .../src/app/store/migrations/migration-18.ts | 12 +++++++++++ .../store/reducers/code-table-selectors.ts | 18 ++++++++++++++++ .../app/store/reducers/code-table-thunks.ts | 11 ++++++++++ frontend/src/app/store/reducers/code-table.ts | 12 +++++++++-- .../app/code-tables/schedule-sector-xref.ts | 6 ++++++ .../app/types/code-tables/schedule-sector.ts | 4 ++++ .../src/app/types/state/code-table-state.ts | 3 +++ 14 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 backend/src/types/models/code-tables/schedule-sector-xref.ts create mode 100644 frontend/src/app/store/migrations/migration-18.ts create mode 100644 frontend/src/app/types/app/code-tables/schedule-sector-xref.ts create mode 100644 frontend/src/app/types/code-tables/schedule-sector.ts diff --git a/backend/src/types/models/code-tables/index.ts b/backend/src/types/models/code-tables/index.ts index 196253555..bfea70379 100644 --- a/backend/src/types/models/code-tables/index.ts +++ b/backend/src/types/models/code-tables/index.ts @@ -55,6 +55,7 @@ export const AvailableCodeTables = [ "non-compliance", "sector", "schedule", + "schedule-sector-type", "decision-type", "team", "complaint-method-received-codes", diff --git a/backend/src/types/models/code-tables/schedule-sector-xref.ts b/backend/src/types/models/code-tables/schedule-sector-xref.ts new file mode 100644 index 000000000..fd6de0e9a --- /dev/null +++ b/backend/src/types/models/code-tables/schedule-sector-xref.ts @@ -0,0 +1,6 @@ +import { BaseCodeTable } from "./code-table"; + +export interface ScheduleSectorXref extends BaseCodeTable { + schedule: string; + sector: string; +} diff --git a/backend/src/v1/code-table/code-table.service.ts b/backend/src/v1/code-table/code-table.service.ts index 481c03f00..e5bb66d9d 100644 --- a/backend/src/v1/code-table/code-table.service.ts +++ b/backend/src/v1/code-table/code-table.service.ts @@ -57,6 +57,7 @@ import { TeamCode } from "../team_code/entities/team_code.entity"; import { TeamType } from "src/types/models/code-tables/team-type"; import { CompMthdRecvCdAgcyCdXref } from "../comp_mthd_recv_cd_agcy_cd_xref/entities/comp_mthd_recv_cd_agcy_cd_xref"; import { ComplaintMethodReceivedType } from "src/types/models/code-tables/complaint-method-received-type"; +import { ScheduleSectorXref } from "src/types/models/code-tables/schedule-sector-xref"; @Injectable() export class CodeTableService { @@ -590,6 +591,25 @@ export class CodeTableService { ); return results; } + case "schedule-sector-type": { + const { data } = await get(token, { + query: "{scheduleSectorXrefs{scheduleCode sectorCode shortDescription longDescription activeIndicator}}", + }); + const results = data.scheduleSectorXrefs.map( + ({ sectorCode, scheduleCode, shortDescription, longDescription, activeIndicator: isActive }) => { + const table: ScheduleSectorXref = { + schedule: scheduleCode, + sector: sectorCode, + shortDescription, + longDescription, + displayOrder: 1, + isActive, + }; + return table; + }, + ); + return results; + } case "discharge": { const { data } = await get(token, { query: "{ dischargeCodes { dischargeCode shortDescription longDescription displayOrder activeIndicator} }", diff --git a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx index 6336ece17..74491abd3 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-form.tsx @@ -7,6 +7,8 @@ import { selectSectorDropdown, selectScheduleDropdown, selectDecisionTypeDropdown, + selectScheduleSectorDropdown, + selectScheduleSectorXref, } from "../../../../../../store/reducers/code-table-selectors"; import { selectLeadAgencyDropdown } from "../../../../../../store/reducers/code-table"; import { Decision } from "../../../../../../types/app/case-files/ceeb/decision/decision"; @@ -77,6 +79,7 @@ export const DecisionForm: FC = ({ const leadAgencyOptions = useAppSelector(selectLeadAgencyDropdown); const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation); const officerOptions = useAppSelector(selectOfficersByAgencyDropdown(ownedByAgencyCode?.agency)); + const scheduleSectorType = useAppSelector(selectScheduleSectorXref); //-- error messgaes const [scheduleErrorMessage, setScheduleErrorMessage] = useState(""); @@ -105,6 +108,8 @@ export const DecisionForm: FC = ({ actionTakenDate, }); + const [_sector, setSector] = useState>(); + useEffect(() => { if (officerAssigned) { applyData({ ...data, assignedTo: officerAssigned }); @@ -185,6 +190,16 @@ export const DecisionForm: FC = ({ updateModel("actionTakenDate", date); }; + const handleScheduleChange = (schedule: string) => { + let options = scheduleSectorType.filter((item) => item.schedule === schedule).map(item => { + const record: Option = { label: item.longDescription, value: item.sector }; + return record + }); + const model = { ...data, sector: "", schedule: schedule }; + applyData(model); + setSector(options); + }; + const handleActionTakenChange = (value: string) => { //-- if the action taken changes make sure to clear the //-- lead agency and inspection number @@ -361,7 +376,9 @@ export const DecisionForm: FC = ({ errorMessage={scheduleErrorMessage} placeholder="Select " onChange={(evt) => { - updateModel("schedule", evt?.value); + if (evt?.value) { + handleScheduleChange(evt.value); + } }} value={getValue("schedule")} /> @@ -377,7 +394,7 @@ export const DecisionForm: FC = ({ id="outcome-decision-sector-category" className="comp-details-input" classNamePrefix="comp-select" - options={sectorsOptions} + options={_sector} enableValidation={true} errorMessage={sectorErrorMessage} placeholder="Select " diff --git a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-item.tsx b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-item.tsx index 478cf652a..90c8eb2c4 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-item.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/ceeb/ceeb-decision/decision-item.tsx @@ -9,6 +9,7 @@ import { selectSectorDropdown, selectScheduleDropdown, selectDecisionTypeDropdown, + selectScheduleSectorDropdown, } from "../../../../../../store/reducers/code-table-selectors"; import { selectOfficersDropdown } from "../../../../../../store/reducers/officer"; import Option from "../../../../../../types/app/option"; @@ -47,6 +48,7 @@ export const DecisionItem: FC = ({ const rationaleOptions = useAppSelector(selectRationaleDropdown); const sectorsOptions = useAppSelector(selectSectorDropdown); const schedulesOptions = useAppSelector(selectScheduleDropdown); + const scheduleSectorsOptions = useAppSelector(selectScheduleSectorDropdown); const decisionTypeOptions = useAppSelector(selectDecisionTypeDropdown); const agencyOptions = useAppSelector(selectLeadAgencyDropdown); const officerOptions = useAppSelector(selectOfficersDropdown(true)); @@ -64,7 +66,14 @@ export const DecisionItem: FC = ({ result = sectorsOptions.find((item) => item.value === sector); break; } - + case "schedule-sector": { + result = scheduleSectorsOptions.find((item) => item.value === sector); + break; + } + case "schedule-sector-type": { + result = scheduleSectorsOptions.find((item) => item.value === sector); + break; + } case "discharge": { result = dischargesOptions.find((item) => item.value === discharge); break; diff --git a/frontend/src/app/constants/code-table-types.ts b/frontend/src/app/constants/code-table-types.ts index 77e5d9d46..7357f5c89 100644 --- a/frontend/src/app/constants/code-table-types.ts +++ b/frontend/src/app/constants/code-table-types.ts @@ -34,6 +34,8 @@ export const CODE_TABLE_TYPES = { TEAM: "team", COMPLAINT_METHOD_RECEIVED: "complaint-method-received-codes", LEAD_AGENCY: "lead-agency", + SCHEDULE_SECTOR: "schedule-sector", + SCHEDULE_SECTOR_TYPE: "schedule-sector-type", // ORGANIZATION_UNIT_TYPE: "organization-unit-type", // ORGANIZATION_UNIT: "organization-unit", diff --git a/frontend/src/app/store/migrations.ts b/frontend/src/app/store/migrations.ts index 121b1f705..08389f6aa 100644 --- a/frontend/src/app/store/migrations.ts +++ b/frontend/src/app/store/migrations.ts @@ -14,6 +14,7 @@ import { AddTeamCode } from "./migrations/migration-14"; import { Decision } from "./migrations/migration-15"; import { AddComplaintMethodReceivedCodes } from "./migrations/migration-16"; import { AddLeadAgencyCode } from "./migrations/migration-17"; +import { AddScheduleSectorTypes } from "./migrations/migration-18"; const BaseMigration = { 0: (state: any) => { @@ -42,6 +43,7 @@ migration = { ...Decision, ...AddComplaintMethodReceivedCodes, ...AddLeadAgencyCode, + ...AddScheduleSectorTypes, }; export default migration; diff --git a/frontend/src/app/store/migrations/migration-18.ts b/frontend/src/app/store/migrations/migration-18.ts new file mode 100644 index 000000000..8e870b269 --- /dev/null +++ b/frontend/src/app/store/migrations/migration-18.ts @@ -0,0 +1,12 @@ +//Add Schedule Sector Type Codes in code table +export const AddScheduleSectorTypes = { + 18: (state: any) => { + return { + ...state, + codeTables: { + ...state.codeTables, + "schedule-sector-type": [], + }, + }; + }, +}; diff --git a/frontend/src/app/store/reducers/code-table-selectors.ts b/frontend/src/app/store/reducers/code-table-selectors.ts index 466a10693..2bf6ae536 100644 --- a/frontend/src/app/store/reducers/code-table-selectors.ts +++ b/frontend/src/app/store/reducers/code-table-selectors.ts @@ -1,5 +1,6 @@ import { RootState } from "../store"; import Option from "../../types/app/option"; +import { ScheduleSectorXref } from "../../types/app/code-tables/schedule-sector-xref"; export const selectDischargeDropdown = (state: RootState): Array