Skip to content

Commit

Permalink
fix: 1781 ownership percentage and client number acronym anomalies in…
Browse files Browse the repository at this point in the history
… migrated data (#1802)
  • Loading branch information
mgaseta authored Jan 9, 2025
1 parent b106086 commit d3cc2bb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions frontend/src/views/Seedlot/ContextContainerClassA/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type ClassAContextType = {
updateProgressStatus: (currentStepNum: number, prevStepNum: number) => void,
saveProgressStatus: MutationStatusType,
isFetchingData: boolean,
seedlotDataLoaded: boolean,
genWorthInfoItems: Record<keyof RowItem, InfoDisplayObj[]>,
setGenWorthInfoItems: React.Dispatch<
React.SetStateAction<Record<keyof PrimitiveRowItem | keyof StrTypeRowItem, InfoDisplayObj[]>>
Expand Down Expand Up @@ -108,6 +109,7 @@ const ClassAContext = createContext<ClassAContextType>({
updateProgressStatus: (currentStepNum: number, prevStepNum: number) => { },
saveProgressStatus: 'idle',
isFetchingData: false,
seedlotDataLoaded: false,
geoInfoVals: {} as GeoInfoValType,
genWorthVals: {} as GenWorthValType,
setGenWorthVal: () => { },
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/views/Seedlot/ContextContainerClassA/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,21 @@ const ContextContainerClassA = ({ children }: props) => {
getAllSeedlotInfoQuery.fetchStatus
]);

const [seedlotDataLoaded, setSeedlotDataLoaded] = useState<boolean>(false);

useEffect(() => {
const emptySeedlotData = initEmptySteps();
if (
getAllSeedlotInfoQuery.status === 'success'
&& allStepData !== emptySeedlotData
) {
setSeedlotDataLoaded(true);
}
}, [
getAllSeedlotInfoQuery.status,
allStepData
]);

/**
* Update the progress indicator status
*/
Expand Down Expand Up @@ -765,6 +780,7 @@ const ContextContainerClassA = ({ children }: props) => {
|| fundingSourcesQuery.isFetching
|| getFormDraftQuery.isFetching
),
seedlotDataLoaded,
genWorthInfoItems,
setGenWorthInfoItems,
weightedGwInfoItems,
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/views/Seedlot/ContextContainerClassA/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ export const initOwnershipState = (
defaultAgencyNumber: string,
ownersStepData: Array<SingleOwnerFormSubmitType>,
methodsOfPayment?: Array<MultiOptionsObj>,
fundingSource?: Array<MultiOptionsObj>
fundingSource?: Array<MultiOptionsObj>,
initLoaded?: boolean
): Array<SingleOwnerForm> => {
const seedlotOwners: Array<SingleOwnerForm> = ownersStepData.map((curOwner, index) => {
const ownerState = createOwnerTemplate(index, curOwner);

ownerState.ownerAgency.value = defaultAgencyNumber;
ownerState.ownerAgency.value = initLoaded ? curOwner.ownerClientNumber : defaultAgencyNumber;
ownerState.ownerCode.value = curOwner.ownerLocnCode;

if (methodsOfPayment && methodsOfPayment.length > 0) {
Expand Down Expand Up @@ -1120,7 +1121,8 @@ export const resDataToState = (
defaultAgencyNumber,
fullFormData.seedlotFormOwnershipDtoList,
methodsOfPaymentData,
fundingSourcesData
fundingSourcesData,
true
),
interimStep: initInterimState(
fullFormData.seedlotFormInterimDto.intermStrgClientNumber,
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/views/Seedlot/SeedlotRegFormClassA/RegPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const RegPage = () => {
seedlotData,
getFormDraftQuery,
seedlotSpecies,
popSizeAndDiversityConfig
popSizeAndDiversityConfig,
isFormSubmitted,
seedlotDataLoaded
} = useContext(ClassAContext);

const reloadFormDraft = () => getFormDraftQuery.refetch();
Expand Down Expand Up @@ -171,7 +173,8 @@ const RegPage = () => {
<Row>
<Column className="seedlot-registration-row">
{
isFetchingData || submitSeedlot.status === 'loading'
(isFetchingData || submitSeedlot.status === 'loading')
|| (isFormSubmitted && !seedlotDataLoaded)
? <Loading />
: (
<RegForm
Expand Down

0 comments on commit d3cc2bb

Please sign in to comment.