-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UM-6631 Pt MDMS v2 call modification
- Loading branch information
1 parent
bff1edb
commit 03a7fac
Showing
6 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useMDMSV2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { MdmsServiceV2 } from "../services/elements/MDMSV2"; | ||
import { useQuery } from "react-query"; | ||
|
||
const useMDMS = (tenantId, moduleCode, type, config = {}, payload = []) => { | ||
const usePaymentGateway = () => { | ||
return useQuery("PAYMENT_GATEWAY", () => MdmsServiceV2.getPaymentGateway(tenantId, moduleCode, type), { | ||
select: (data) => { | ||
return data?.[moduleCode]?.[type].filter((e) => e.active).map(({ gateway }) => gateway); | ||
}, | ||
...config, | ||
}); | ||
}; | ||
|
||
const useReceiptKey = () => { | ||
return useQuery("RECEIPT_KEY", () => MdmsServiceV2.getReceiptKey(tenantId, moduleCode, type), config); | ||
}; | ||
|
||
const useBillsGenieKey = () => { | ||
return useQuery("BILLS_GENIE_KEY", () => MdmsServiceV2.getBillsGenieKey(tenantId, moduleCode, type), config); | ||
}; | ||
|
||
const useFSTPPlantInfo = () => { | ||
return useQuery("FSTP_PLANTINFO", () => MdmsServiceV2.getFSTPPlantInfo(tenantId, moduleCode, type), config); | ||
}; | ||
|
||
const _default = () => { | ||
return useQuery([tenantId, moduleCode, type], () => MdmsServiceV2.getMultipleTypes(tenantId, moduleCode, type), config); | ||
}; | ||
|
||
switch (type) { | ||
case "PaymentGateway": | ||
return usePaymentGateway(); | ||
case "ReceiptKey": | ||
return useReceiptKey(); | ||
case "FSTPPlantInfo": | ||
return useFSTPPlantInfo(); | ||
case "BillsGenieKey": | ||
return useBillsGenieKey(); | ||
default: | ||
return _default(); | ||
} | ||
}; | ||
|
||
export default useMDMS; |
2 changes: 1 addition & 1 deletion
2
frontend/micro-ui/web/micro-ui-internals/packages/modules/pt/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters