diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx index 0c6ac8a4..bbc082c8 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/activity-form.tsx @@ -191,7 +191,7 @@ export const ActivityForm: FC = (props) => { } } - const role = useMemo(() => { + const role: ProjectRole | NonHydratedProjectRole | undefined = useMemo(() => { return showRecentRole ? recentProjectRole : projectRole }, [projectRole, showRecentRole, recentProjectRole]) @@ -248,10 +248,6 @@ export const ActivityForm: FC = (props) => { setValue('file', files[0]) } - const activeRole: ProjectRole | NonHydratedProjectRole | undefined = showRecentRole - ? recentProjectRole - : projectRole - return ( = (props) => { wrap="wrap" position="relative" > - {activeRole !== undefined && ( + {role !== undefined && ( = (props) => { // TODO: Remove once there is a dedicated TimeInfo API useEffect(() => { - if (props.projectId !== undefined && props.selectedRoleId !== undefined) { + if (props.projectId !== undefined && props.roleId !== undefined) { executeUseCase({ projectId: props.projectId, userId: props.userId, year: start.getFullYear() }).then((x) => { - const find = x.find((role) => role.id === props.selectedRoleId) - + const find = x.find((role) => role.id === props.roleId) if (find !== undefined) { setTimeInfo(find.timeInfo) } }) } - }, [executeUseCase, props.projectId, props.roleId, props.selectedRoleId, props.userId, start]) + }, [executeUseCase, props.projectId, props.roleId, props.userId, start]) const { isLoading: daysLoading, executeUseCase: getDaysForActivityDaysPeriodQry } = useGetUseCase( GetDaysForActivityDaysPeriodQry diff --git a/src/features/binnacle/features/activity/ui/components/activity-form/components/select-role-section.tsx b/src/features/binnacle/features/activity/ui/components/activity-form/components/select-role-section.tsx index ed46956f..e004c8c5 100644 --- a/src/features/binnacle/features/activity/ui/components/activity-form/components/select-role-section.tsx +++ b/src/features/binnacle/features/activity/ui/components/activity-form/components/select-role-section.tsx @@ -20,6 +20,7 @@ export const SelectRoleSection: FC = (props: Props) => { const { t } = useTranslation() const { field: showRecentRoleField } = useController({ control, name: 'showRecentRole' }) const { field: recentProjectRoleField } = useController({ control, name: 'recentProjectRole' }) + const { field: projectField } = useController({ control, name: 'project' }) const [recentRoleListIsEmpty, setRecentRoleListIsEmpty] = useState(false) const organizationRef = useRef(null) @@ -64,6 +65,7 @@ export const SelectRoleSection: FC = (props: Props) => { showRecentRoleField.onChange(false) }} onChange={(value) => { + projectField.onChange(value.project) recentProjectRoleField.onChange(value) }} projectRole={recentProjectRoleField.value}