Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emisweb 135: fix (issues on transfer): error when open approve/reject transfer for student and approve failling for staff #41

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/modal/ApproveTransferModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ function ApproveTranfer(props: ApproveTranferProps): React.ReactElement {

{clickedButton === "approve"
? <div className="py-2">
Are you sure you want to{" "} <span className="text-danger"> approve the transfer </span> of{" "} <strong> {`${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[1]?.trackedEntityAttribute.id ?? programTrackedEntityAttributes[2]?.trackedEntityAttribute.id }) ?? ""}, ${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[0]?.trackedEntityAttribute?.id ?? programTrackedEntityAttributes[3]?.trackedEntityAttribute.id}) ?? ""}`} </strong>{" "} from{" "}
Are you sure you want to{" "} <span className="text-danger"> approve the transfer </span> of{" "} <strong> {`${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[1]?.trackedEntityAttribute?.id ?? programTrackedEntityAttributes[2]?.trackedEntityAttribute?.id }) ?? ""}, ${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[0]?.trackedEntityAttribute?.id ?? programTrackedEntityAttributes[3]?.trackedEntityAttribute?.id}) ?? ""}`} </strong>{" "} from{" "}
<strong>{selectedTei?.transferInstance?.orgUnitName}</strong>{" "} to{" "}
<strong>{schoolName}</strong>?
</div>
: <div className="py-2">
Are you sure you want to{" "} <span className="text-danger"> reject the transfer </span> of{" "} <strong> {`${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[1]?.trackedEntityAttribute.id ?? programTrackedEntityAttributes[2]?.trackedEntityAttribute.id }) ?? ""}, ${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[0]?.trackedEntityAttribute?.id ?? programTrackedEntityAttributes[3]?.trackedEntityAttribute.id}) ?? ""}`} </strong>{" "} from{" "}
Are you sure you want to{" "} <span className="text-danger"> reject the transfer </span> of{" "} <strong> {`${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[1]?.trackedEntityAttribute?.id ?? programTrackedEntityAttributes[2]?.trackedEntityAttribute?.id }) ?? ""}, ${attributeFilter({array: selectedTei?.teiInstance?.attributes, attribute: trackedEntityAttributes[0]?.trackedEntityAttribute?.id ?? programTrackedEntityAttributes[3]?.trackedEntityAttribute?.id}) ?? ""}`} </strong>{" "} from{" "}
<strong>{selectedTei?.transferInstance?.orgUnitName}</strong>{" "} to{" "}
<strong>{schoolName}</strong>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/programStages/useGetUsedPProgramStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { getDataStoreKeys } from "../../utils/commons/dataStore/getDataStoreKeys
const useGetUsedProgramStages = () => {
const { performance, finalResult, socioEconomics, registration } = getDataStoreKeys();
const performanceProgramStages = performance?.programStages.map((programStage: simpleProgramStage) => programStage.programStage) ?? [];
return performance ? [...performanceProgramStages, finalResult?.programStage, socioEconomics?.programStage, registration?.programStage] : []
return [...performanceProgramStages, finalResult?.programStage, socioEconomics?.programStage, registration?.programStage].filter(Boolean)
}
export default useGetUsedProgramStages
4 changes: 2 additions & 2 deletions src/hooks/tei/useTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function useTransferTEI() {
getEventsByEnrollment(selectedTei?.transferInstance?.enrollment, selectedTei?.teiInstance?.trackedEntity, programStagesToTransfer)
}, []);

const registrationEvent: any = events?.find((x: any) => x.programStage == getDataStoreData.registration.programStage) ?? {}
const registrationEvent: any = events?.find((x: any) => x?.programStage == getDataStoreData.registration.programStage) ?? {}

async function formatEnrollmentBody(newOu: any, transferEvent: any, tei: any, handleCloseApproval: () => void) {
const trackedEntities = [
Expand All @@ -64,7 +64,7 @@ export function useTransferTEI() {
occurredAt: registrationEvent?.occurredAt,
enrolledAt: registrationEvent?.occurredAt,
events: [
...events?.map((event: any) => ({
...events?.filter(Boolean)?.map((event: any) => ({
...event,
orgUnit: newOu,
})),
Expand Down