Skip to content

Commit

Permalink
fixes (bcgov#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-aot authored Mar 23, 2024
1 parent 3134d5b commit bbd447e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions epictrack-api/src/api/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
from .set_work_decision_maker import SetWorkDecisionMaker
from .set_work_state import SetWorkState
from .change_phase_end_event import ChangePhaseEndEvent
from .set_project_state import SetProjectState
1 change: 1 addition & 0 deletions epictrack-api/src/api/actions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ def get_additional_params(
ActionEnum.SET_WORK_STATE: "SetWorkState",
ActionEnum.CHANGE_PHASE_END_EVENT: "ChangePhaseEndEvent",
ActionEnum.SET_FEDERAL_INVOLVEMENT: "SetFederalInvolvement",
ActionEnum.SET_PROJECT_STATE: "SetProjectState",
}
4 changes: 2 additions & 2 deletions epictrack-api/src/api/actions/set_project_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Sets the state of the project"""
from api.actions.base import ActionFactory
from api.models.event import Event
from api.models.project import Project
from api.models.project import Project, ProjectStateEnum


class SetProjectState(ActionFactory):
Expand All @@ -10,5 +10,5 @@ class SetProjectState(ActionFactory):
def run(self, source_event: Event, params) -> None:
"""Sets the federal involvement field to None"""
project = Project.find_by_id(source_event.work.project_id)
project.project_state = params.get("project_state")
project.project_state = ProjectStateEnum(params.get("project_state"))
project.update(project.as_dict(recursive=False), commit=False)
Binary file not shown.
6 changes: 3 additions & 3 deletions epictrack-web/src/components/shared/MasterTrackTable/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ColumnFilter = {
id: string;
value: unknown
}
id: string;
value: unknown;
};
8 changes: 3 additions & 5 deletions epictrack-web/src/components/workPlan/event/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,12 @@ const EventForm = ({
ctx.selectedWorkPhase?.work_phase.legislated &&
selectedConfiguration?.event_category_id !== EventCategory.EXTENSION
) {
const diff = dayjs(ctx.selectedWorkPhase.work_phase.end_date).diff(
ctx.selectedWorkPhase.work_phase.start_date,
"day"
);
return dayjs(ctx.selectedWorkPhase.work_phase.end_date);
}
return dayjs(new Date());
}, [ctx.selectedWorkPhase, selectedConfiguration]);

console.log("Actual Date Min", actualDateMin);
console.log("Actual Date Max", actualDateMax);
const methods = useForm({
resolver: yupResolver(schema),
defaultValues: event,
Expand Down Expand Up @@ -757,6 +754,7 @@ const EventForm = ({
isFormFieldsLocked={isFormFieldsLocked}
configurationId={selectedConfiguration?.id}
decisionMakerPositionId={decisionMakerPositionIds}
decisionMakerId={ctx.work?.decision_by_id}
/>
</When>
<When
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { Staff } from "../../../../models/staff";

export interface DecisionInputProps {
configurationId?: number;
decisionMakerPositionId: number[];
decisionMakerPositionId?: number[];
decisionMakerId?: number;
isFormFieldsLocked: boolean;
}
const DecisionInput = ({
decisionMakerPositionId,
decisionMakerId,
configurationId,
isFormFieldsLocked,
}: DecisionInputProps) => {
Expand Down Expand Up @@ -48,11 +50,18 @@ const DecisionInput = ({
};
const getDecisionMakers = async () => {
try {
const result = await staffService.getStaffByPosition(
decisionMakerPositionId.join(",")
);
if (result.status === 200) {
setDecisionMakers(result.data as Staff[]);
if (decisionMakerId) {
const result = await staffService.getById(String(decisionMakerId));
if (result.status === 200) {
setDecisionMakers([result.data as Staff]);
}
} else if (decisionMakerPositionId) {
const result = await staffService.getStaffByPosition(
decisionMakerPositionId.join(",")
);
if (result.status === 200) {
setDecisionMakers(result.data as Staff[]);
}
}
} catch (e) {
showNotification(COMMON_ERROR_MESSAGE, {
Expand Down

0 comments on commit bbd447e

Please sign in to comment.