diff --git a/app/src/features/projects/components/ProjectUserForm.tsx b/app/src/features/projects/components/ProjectUserForm.tsx index 8236e255a3..08e7ba98e7 100644 --- a/app/src/features/projects/components/ProjectUserForm.tsx +++ b/app/src/features/projects/components/ProjectUserForm.tsx @@ -60,6 +60,10 @@ const ProjectUserForm: React.FC = (props) => { useEffect(() => { props.users.forEach((user, index) => { setFieldValue(`participants[${index}].system_user_id`, user.system_user_id); + setFieldValue(`participants[${index}].display_name`, user.display_name); + setFieldValue(`participants[${index}].email`, user.email); + setFieldValue(`participants[${index}].agency`, user.agency); + setFieldValue(`participants[${index}].identity_source`, user.identity_source); setFieldValue(`participants[${index}].project_role_names`, (user as IGetProjectParticipant).project_role_names); }); setSelectedUsers(props.users); @@ -70,6 +74,10 @@ const ProjectUserForm: React.FC = (props) => { setFieldValue(`participants[${selectedUsers.length - 1}]`, { system_user_id: user.system_user_id, + display_name: user.display_name, + email: user.email, + agency: user.agency, + identity_source: user.identity_source, project_role_names: [] }); clearErrors(); diff --git a/app/src/features/projects/create/CreateProjectForm.tsx b/app/src/features/projects/create/CreateProjectForm.tsx index 3819ce7620..703a927862 100644 --- a/app/src/features/projects/create/CreateProjectForm.tsx +++ b/app/src/features/projects/create/CreateProjectForm.tsx @@ -91,16 +91,27 @@ const CreateProjectForm: React.FC = (props) => { const { keycloakWrapper } = useContext(AuthStateContext); - const getLoggedInUserAsParticipant = (): IGetProjectParticipant => { - const loggedInUser = keycloakWrapper?.user; - return { - system_user_id: loggedInUser?.system_user_id, - display_name: loggedInUser?.display_name, - email: loggedInUser?.email, - agency: loggedInUser?.agency, - identity_source: loggedInUser?.identity_source, - project_role_names: [PROJECT_ROLE.COORDINATOR] - } as IGetProjectParticipant; + const getProjectParticipants = (): IGetProjectParticipant[] => { + let participants: IGetProjectParticipant[] = []; + + // load initial values from draft webform + if (props.initialValues?.participants) { + participants = props.initialValues?.participants as IGetProjectParticipant[]; + } else { + // this is a fresh form and the logged in user needs to be added as a participant + const loggedInUser = keycloakWrapper?.user; + participants = [ + { + system_user_id: loggedInUser?.system_user_id, + display_name: loggedInUser?.display_name, + email: loggedInUser?.email, + agency: loggedInUser?.agency, + identity_source: loggedInUser?.identity_source, + project_role_names: [PROJECT_ROLE.COORDINATOR] + } as IGetProjectParticipant + ]; + } + return participants; }; return ( @@ -182,7 +193,7 @@ const CreateProjectForm: React.FC = (props) => { } + component={} /> diff --git a/app/src/features/projects/edit/EditProjectForm.tsx b/app/src/features/projects/edit/EditProjectForm.tsx index a074849828..5ae3e2d6bc 100644 --- a/app/src/features/projects/edit/EditProjectForm.tsx +++ b/app/src/features/projects/edit/EditProjectForm.tsx @@ -70,8 +70,6 @@ const EditProjectForm: React.FC = (props) => { enableReinitialize={true} onSubmit={handleSubmit}> <> - {/* */} -