|
|
@@ -113,6 +113,7 @@ const ProjectClientDetails: React.FC<Props> = ({ |
|
|
|
|
|
|
|
// get customer (client) contact combo |
|
|
|
const [firstCustomerLoaded, setFirstCustomerLoaded] = useState(false) |
|
|
|
const [isMainProjectInfoLoading, setIsMainProjectInfoLoading] = useState(false) |
|
|
|
useEffect(() => { |
|
|
|
if (selectedCustomerId !== undefined) { |
|
|
|
fetchCustomer(selectedCustomerId).then(({ contacts, subsidiaryIds }) => { |
|
|
@@ -120,8 +121,10 @@ const ProjectClientDetails: React.FC<Props> = ({ |
|
|
|
setCustomerSubsidiaryIds(subsidiaryIds); |
|
|
|
|
|
|
|
// if (subsidiaryIds.length > 0) setValue("clientSubsidiaryId", subsidiaryIds[0]) |
|
|
|
// else |
|
|
|
if (isEditMode && !firstCustomerLoaded) { setFirstCustomerLoaded(true) } else setValue("clientSubsidiaryId", null) |
|
|
|
// else |
|
|
|
if (isEditMode && !firstCustomerLoaded) { setFirstCustomerLoaded(true) } |
|
|
|
else if (!isEditMode && isMainProjectInfoLoading) { setIsMainProjectInfoLoading(false) } |
|
|
|
else setValue("clientSubsidiaryId", null) |
|
|
|
// if (contacts.length > 0) setValue("clientContactId", contacts[0].id) |
|
|
|
// else setValue("clientContactId", undefined) |
|
|
|
}); |
|
|
@@ -160,6 +163,7 @@ const ProjectClientDetails: React.FC<Props> = ({ |
|
|
|
const mainProject = mainProjects.find(project => project.projectId === mainProjectId); |
|
|
|
|
|
|
|
if (mainProject !== undefined) { |
|
|
|
setIsMainProjectInfoLoading(() => true) |
|
|
|
setValue("projectName", mainProject.projectName) |
|
|
|
setValue("projectCategoryId", mainProject.projectCategoryId) |
|
|
|
setValue("projectLeadId", mainProject.projectLeadId) |
|
|
|