@undp/carbon-library 1.0.175-CARBON-347.8 → 1.0.175-CARBON-347.9

Sign up to get free protection for your applications and to get access to all the features.
package/dist/esm/index.js CHANGED
@@ -15642,26 +15642,34 @@ var Loading = function () {
15642
15642
  };
15643
15643
 
15644
15644
  var InvestmentCreationComponent = function (props) {
15645
- var t = props.t, useLocation = props.useLocation, onNavigateToProgrammeManagementView = props.onNavigateToProgrammeManagementView, onNavigateToProgrammeView = props.onNavigateToProgrammeView;
15645
+ var t = props.t, useLocation = props.useLocation, onNavigateToProgrammeManagementView = props.onNavigateToProgrammeManagementView, onNavigateToProgrammeView = props.onNavigateToProgrammeView, onNavigateToInvestmentManagementView = props.onNavigateToInvestmentManagementView;
15646
15646
  var state = useLocation().state;
15647
15647
  var _a = useState(), data = _a[0], setData = _a[1];
15648
- var _b = useState(), projectData = _b[0], setProjectData = _b[1];
15649
- var _c = useState([]), allProjectData = _c[0], setAllProjectData = _c[1];
15648
+ var _b = useState({}), companyNames = _b[0], setCompanyNames = _b[1];
15649
+ var _c = useState({}); _c[0]; var setUserOrganization = _c[1];
15650
+ var _d = useState({}), investmentNames = _d[0], setInvestmentNames = _d[1];
15651
+ var _e = useState(), projectData = _e[0], setProjectData = _e[1];
15652
+ var _f = useState(), investmentData = _f[0], setInvestmentData = _f[1];
15653
+ var _g = useState([]), allProjectData = _g[0], setAllProjectData = _g[1];
15650
15654
  var formOne = Form.useForm()[0];
15651
15655
  var formTwo = Form.useForm()[0];
15652
15656
  var post = useConnection().post;
15653
- var _d = useState(false), loading = _d[0], setLoading = _d[1];
15654
- var _e = useState("New"), typeCreation = _e[0], setTypeCreation = _e[1];
15655
- var _f = useState(InvestmentOwnershipType.PROJECT), investmentOwnershipType = _f[0], setInvestmentOwnershipType = _f[1];
15656
- var _g = useState(false), loadingList = _g[0], setLoadingList = _g[1];
15657
- var _h = useState(false), loadingProgData = _h[0], setLoadingProgData = _h[1];
15658
- var _j = useState(0), current = _j[0], setCurrent = _j[1];
15659
- var _k = useState(0), currentPercTotal = _k[0], setCurrentPercTotal = _k[1];
15660
- var _l = useState([]), organisationsList = _l[0], setOrganisationList = _l[1];
15661
- var _m = useState([]), instrument = _m[0], setInstrument = _m[1];
15662
- var _o = useState(), stepOneData = _o[0], setStepOneData = _o[1];
15663
- var _p = useState(), govData = _p[0], setGovData = _p[1];
15657
+ var _h = useState(false), loading = _h[0], setLoading = _h[1];
15658
+ var _j = useState("New"), typeCreation = _j[0], setTypeCreation = _j[1];
15659
+ var _k = useState(InvestmentOwnershipType.PROJECT), investmentOwnershipType = _k[0], setInvestmentOwnershipType = _k[1];
15660
+ var _l = useState(false), loadingList = _l[0], setLoadingList = _l[1];
15661
+ var _m = useState(false), loadingInvestment = _m[0], setLoadingInvestment = _m[1];
15662
+ var _o = useState(false), loadingProgData = _o[0], setLoadingProgData = _o[1];
15663
+ var _p = useState(0), current = _p[0], setCurrent = _p[1];
15664
+ var _q = useState(0), currentPercTotal = _q[0], setCurrentPercTotal = _q[1];
15665
+ var _r = useState([]), organisationsList = _r[0], setOrganisationList = _r[1];
15666
+ var _s = useState([]), nationalInvestmentList = _s[0], setNationalInvestmentList = _s[1];
15667
+ var _t = useState([]), instrument = _t[0], setInstrument = _t[1];
15668
+ var _u = useState(), stepOneData = _u[0], setStepOneData = _u[1];
15669
+ var _v = useState(), govData = _v[0], setGovData = _v[1];
15664
15670
  var userInfoState = useUserContext().userInfoState;
15671
+ var _w = useState([]), ministrySectoralScope = _w[0], setMinistrySectoralScope = _w[1];
15672
+ var _x = useState({}), prevInvestor = _x[0], setPrevInvestor = _x[1];
15665
15673
  var instrumentOptions = Object.keys(Instrument).map(function (k, index) { return ({
15666
15674
  label: addSpaces(Object.values(Instrument)[index]),
15667
15675
  value: Object.values(Instrument)[index],
@@ -15721,7 +15729,9 @@ var InvestmentCreationComponent = function (props) {
15721
15729
  _a.label = 1;
15722
15730
  case 1:
15723
15731
  _a.trys.push([1, 5, 6, 7]);
15732
+ if (!data) return [3 /*break*/, 4];
15724
15733
  if (!!(data === null || data === void 0 ? void 0 : data.programmeId)) return [3 /*break*/, 3];
15734
+ console.log("data non existing", data);
15725
15735
  console.log("getting all Project data");
15726
15736
  return [4 /*yield*/, post("national/programme/query", {
15727
15737
  page: 1,
@@ -15737,17 +15747,7 @@ var InvestmentCreationComponent = function (props) {
15737
15747
  case 2:
15738
15748
  response = _a.sent();
15739
15749
  if (response.data) {
15740
- if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) == CompanyRole.PROGRAMME_DEVELOPER &&
15741
- stepOneData.toCompanyId != userInfoState.companyId) {
15742
- setAllProjectData(response === null || response === void 0 ? void 0 : response.data.map(function (obj) {
15743
- if (obj.companyId.includes(userInfoState.companyId)) {
15744
- return obj;
15745
- }
15746
- }));
15747
- }
15748
- else {
15749
- setAllProjectData(response === null || response === void 0 ? void 0 : response.data);
15750
- }
15750
+ setAllProjectData(response === null || response === void 0 ? void 0 : response.data);
15751
15751
  console.log("all Project data", response === null || response === void 0 ? void 0 : response.data);
15752
15752
  }
15753
15753
  return [3 /*break*/, 4];
@@ -15781,16 +15781,108 @@ var InvestmentCreationComponent = function (props) {
15781
15781
  return [2 /*return*/];
15782
15782
  });
15783
15783
  }); };
15784
- var getOrganisationsDetails = function () { return __awaiter(void 0, void 0, void 0, function () {
15785
- var filterAnd, filterOr, _i, _a, c, response, error_3;
15784
+ var setSelectedInvestment = function (value) { return __awaiter(void 0, void 0, void 0, function () {
15785
+ return __generator(this, function (_a) {
15786
+ console.log("setSelectedInvestment", value);
15787
+ setInvestmentData(investmentNames[value]);
15788
+ return [2 /*return*/];
15789
+ });
15790
+ }); };
15791
+ var getNationalInvestmentDetails = function () { return __awaiter(void 0, void 0, void 0, function () {
15792
+ var filterAnd, response, investmentData_1, _i, _a, investment, error_3;
15786
15793
  return __generator(this, function (_b) {
15787
15794
  switch (_b.label) {
15788
15795
  case 0:
15789
- setLoadingList(true);
15796
+ setLoadingInvestment(true);
15790
15797
  _b.label = 1;
15791
15798
  case 1:
15792
15799
  _b.trys.push([1, 3, 4, 5]);
15793
15800
  filterAnd = [];
15801
+ filterAnd = [
15802
+ {
15803
+ key: "category",
15804
+ operation: "=",
15805
+ value: InvestmentOwnershipType.NATIONAL.toString(),
15806
+ },
15807
+ {
15808
+ key: "amount",
15809
+ operation: ">",
15810
+ value: 0,
15811
+ },
15812
+ ];
15813
+ if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.PROGRAMME_DEVELOPER) {
15814
+ filterAnd.push({
15815
+ key: "toCompanyId",
15816
+ operation: "=",
15817
+ value: userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyId,
15818
+ });
15819
+ }
15820
+ return [4 /*yield*/, post("national/programme/investmentQuery", {
15821
+ page: 1,
15822
+ size: 100,
15823
+ filterAnd: filterAnd,
15824
+ })];
15825
+ case 2:
15826
+ response = _b.sent();
15827
+ if (response.data) {
15828
+ setNationalInvestmentList(response === null || response === void 0 ? void 0 : response.data);
15829
+ investmentData_1 = {};
15830
+ for (_i = 0, _a = response === null || response === void 0 ? void 0 : response.data; _i < _a.length; _i++) {
15831
+ investment = _a[_i];
15832
+ investmentData_1[investment.requestId] = investment;
15833
+ }
15834
+ setInvestmentNames(investmentData_1);
15835
+ console.log(investmentData_1);
15836
+ }
15837
+ return [3 /*break*/, 5];
15838
+ case 3:
15839
+ error_3 = _b.sent();
15840
+ console.log("Error in getting national Investments list", error_3);
15841
+ return [3 /*break*/, 5];
15842
+ case 4:
15843
+ setLoadingInvestment(false);
15844
+ return [7 /*endfinally*/];
15845
+ case 5: return [2 /*return*/];
15846
+ }
15847
+ });
15848
+ }); };
15849
+ var getUserOrganization = function () { return __awaiter(void 0, void 0, void 0, function () {
15850
+ var response, error_4;
15851
+ return __generator(this, function (_a) {
15852
+ switch (_a.label) {
15853
+ case 0:
15854
+ _a.trys.push([0, 2, , 3]);
15855
+ return [4 /*yield*/, post("national/organisation/query", {
15856
+ page: 1,
15857
+ size: 100,
15858
+ filterAnd: [
15859
+ { key: "companyId", operation: "=", value: userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyId },
15860
+ ],
15861
+ })];
15862
+ case 1:
15863
+ response = _a.sent();
15864
+ console.log("getUserOrganization", response.data[0]);
15865
+ setUserOrganization(response.data[0]);
15866
+ setMinistrySectoralScope(response.data[0].sectoralScope);
15867
+ return [3 /*break*/, 3];
15868
+ case 2:
15869
+ error_4 = _a.sent();
15870
+ console.log("Error in getting user organization", error_4);
15871
+ return [3 /*break*/, 3];
15872
+ case 3: return [2 /*return*/];
15873
+ }
15874
+ });
15875
+ }); };
15876
+ var getOrganisationsDetails = function () { return __awaiter(void 0, void 0, void 0, function () {
15877
+ var filterAnd, filterOr, _i, _a, c, filters, response, companyName, _b, _c, company, error_5;
15878
+ return __generator(this, function (_d) {
15879
+ switch (_d.label) {
15880
+ case 0:
15881
+ setLoadingList(true);
15882
+ _d.label = 1;
15883
+ case 1:
15884
+ _d.trys.push([1, 3, 4, 5]);
15885
+ filterAnd = [];
15794
15886
  filterOr = [];
15795
15887
  filterAnd = [
15796
15888
  {
@@ -15806,29 +15898,37 @@ var InvestmentCreationComponent = function (props) {
15806
15898
  // value: userInfoState?.companyId,
15807
15899
  // });
15808
15900
  // }
15809
- for (_i = 0, _a = data === null || data === void 0 ? void 0 : data.companyId; _i < _a.length; _i++) {
15810
- c = _a[_i];
15811
- filterOr.push({
15812
- key: "companyId",
15813
- operation: "=",
15814
- value: c,
15815
- });
15901
+ if (data === null || data === void 0 ? void 0 : data.companyId) {
15902
+ for (_i = 0, _a = data === null || data === void 0 ? void 0 : data.companyId; _i < _a.length; _i++) {
15903
+ c = _a[_i];
15904
+ filterOr.push({
15905
+ key: "companyId",
15906
+ operation: "=",
15907
+ value: c,
15908
+ });
15909
+ }
15816
15910
  }
15817
- return [4 /*yield*/, post("national/organisation/queryNames", {
15818
- page: 1,
15819
- size: 100,
15820
- filterAnd: filterAnd,
15821
- filterOr: filterOr,
15822
- })];
15911
+ filters = void 0;
15912
+ if (filterOr.length) {
15913
+ filters.filterOr = filterOr;
15914
+ }
15915
+ return [4 /*yield*/, post("national/organisation/queryNames", __assign({ page: 1, size: 100, filterAnd: filterAnd }, filters))];
15823
15916
  case 2:
15824
- response = _b.sent();
15917
+ response = _d.sent();
15825
15918
  if (response.data) {
15826
15919
  setOrganisationList(response === null || response === void 0 ? void 0 : response.data);
15920
+ companyName = {};
15921
+ for (_b = 0, _c = response === null || response === void 0 ? void 0 : response.data; _b < _c.length; _b++) {
15922
+ company = _c[_b];
15923
+ companyName[Number(company.companyId)] = company.name;
15924
+ }
15925
+ setCompanyNames(companyName);
15926
+ console.log(companyName);
15827
15927
  }
15828
15928
  return [3 /*break*/, 5];
15829
15929
  case 3:
15830
- error_3 = _b.sent();
15831
- console.log("Error in getting organization list", error_3);
15930
+ error_5 = _d.sent();
15931
+ console.log("Error in getting organization list", error_5);
15832
15932
  return [3 /*break*/, 5];
15833
15933
  case 4:
15834
15934
  setLoadingList(false);
@@ -15843,55 +15943,71 @@ var InvestmentCreationComponent = function (props) {
15843
15943
  return;
15844
15944
  }
15845
15945
  if (state === null || state === void 0 ? void 0 : state.record) {
15946
+ console.log("condition 1 data", state === null || state === void 0 ? void 0 : state.record);
15846
15947
  setData(state === null || state === void 0 ? void 0 : state.record);
15847
15948
  }
15848
15949
  else {
15950
+ console.log("condition 2 data", { ownership: true });
15849
15951
  setData({ ownership: true });
15850
15952
  }
15851
15953
  }, []);
15852
15954
  useEffect(function () {
15853
- if (data) {
15854
- var keys = Object.keys(data);
15855
- if (keys[0] !== "ownership") {
15856
- getOrganisationsDetails();
15857
- }
15858
- }
15955
+ // if (data) {
15956
+ // const keys = Object.keys(data);
15957
+ // if (keys[0] !== "ownership") {
15958
+ // getOrganisationsDetails();
15959
+ // }
15960
+ // }
15961
+ getNationalInvestmentDetails();
15962
+ getOrganisationsDetails();
15859
15963
  getGovernmentDetails();
15860
15964
  getAllProjectData();
15965
+ getUserOrganization();
15861
15966
  }, [data]);
15862
- if (!data || allProjectData.length == 0) {
15967
+ if (!data && allProjectData.length == 0) {
15863
15968
  return React.createElement(Loading, null);
15864
15969
  }
15865
15970
  console.log("data", data);
15866
- var companyName = {};
15867
15971
  if (data && Object.keys(data)[0] !== "ownership") {
15868
- for (var _i = 0, _q = data === null || data === void 0 ? void 0 : data.company; _i < _q.length; _i++) {
15869
- var company = _q[_i];
15870
- companyName[company === null || company === void 0 ? void 0 : company.companyId] = company;
15871
- }
15972
+ // for (const company of data!?.company) {
15973
+ // companyName[company?.companyId] = company;
15974
+ // }
15872
15975
  if (!data.proponentPercentage) {
15873
15976
  data.proponentPercentage = [100];
15874
15977
  }
15875
15978
  }
15876
15979
  var nextOne = function (val) {
15980
+ console.log("step 1 values", val);
15981
+ if (val.typeCreation == InvestmentCreationType.EXISTING) {
15982
+ val.toCompanyId = investmentData.toCompanyId;
15983
+ }
15877
15984
  setCurrent(current + 1);
15878
15985
  setStepOneData(val);
15879
15986
  if (data === null || data === void 0 ? void 0 : data.programmeId)
15880
15987
  setSelectedProgramme(data.programmeId);
15988
+ if (prevInvestor && prevInvestor != val.toCompanyId && !(data === null || data === void 0 ? void 0 : data.programmeId)) {
15989
+ formTwo.resetFields();
15990
+ setCurrentPercTotal(0);
15991
+ setProjectData(undefined);
15992
+ }
15881
15993
  };
15882
15994
  var prevOne = function () {
15883
15995
  setCurrent(current - 1);
15996
+ setPrevInvestor(stepOneData.toCompanyId);
15997
+ // formTwo.resetFields();
15998
+ // setCurrentPercTotal(0);
15999
+ // setProjectData(undefined);
15884
16000
  };
15885
16001
  var submitInvestment = function (val) { return __awaiter(void 0, void 0, void 0, function () {
15886
- var payload, response, error_4;
16002
+ var payload, response, error_6;
15887
16003
  return __generator(this, function (_a) {
15888
16004
  switch (_a.label) {
15889
16005
  case 0:
15890
16006
  console.log(val);
15891
16007
  console.log(stepOneData);
16008
+ console.log("OwnershipType", investmentOwnershipType);
15892
16009
  setLoading(true);
15893
16010
  payload = stepOneData;
15894
- payload.programmeId = data.programmeId;
15895
16011
  payload.amount = parseFloat(payload.amount);
15896
16012
  if (payload.interestRate) {
15897
16013
  payload.interestRate = parseFloat(payload.interestRate);
@@ -15899,15 +16015,27 @@ var InvestmentCreationComponent = function (props) {
15899
16015
  if (payload.paymentPerMetric) {
15900
16016
  payload.paymentPerMetric = parseFloat(payload.paymentPerMetric);
15901
16017
  }
15902
- payload.fromCompanyIds = data.companyId.map(function (e) { return Number(e); });
15903
- payload.percentage = val.percentage;
15904
16018
  payload.toCompanyId = Number(payload.toCompanyId);
15905
16019
  _a.label = 1;
15906
16020
  case 1:
15907
- _a.trys.push([1, 3, 4, 5]);
16021
+ _a.trys.push([1, 6, 7, 8]);
16022
+ response = void 0;
16023
+ if (!(investmentOwnershipType == InvestmentOwnershipType.PROJECT)) return [3 /*break*/, 3];
16024
+ if (typeCreation == InvestmentCreationType.EXISTING) {
16025
+ payload.nationalInvestmentId = investmentData.requestId;
16026
+ }
16027
+ payload.programmeId = projectData === null || projectData === void 0 ? void 0 : projectData.programmeId;
16028
+ payload.fromCompanyIds = projectData === null || projectData === void 0 ? void 0 : projectData.companyId.map(function (e) { return Number(e); });
16029
+ payload.percentage = val.percentage;
15908
16030
  return [4 /*yield*/, post("national/programme/addInvestment", payload)];
15909
16031
  case 2:
15910
16032
  response = _a.sent();
16033
+ return [3 /*break*/, 5];
16034
+ case 3: return [4 /*yield*/, post("national/organisation/addInvestment", payload)];
16035
+ case 4:
16036
+ response = _a.sent();
16037
+ _a.label = 5;
16038
+ case 5:
15911
16039
  console.log("investment creation -> ", response);
15912
16040
  if ((response === null || response === void 0 ? void 0 : response.statusText) === "SUCCESS") {
15913
16041
  message.open({
@@ -15917,22 +16045,24 @@ var InvestmentCreationComponent = function (props) {
15917
16045
  style: { textAlign: "right", marginRight: 15, marginTop: 10 },
15918
16046
  });
15919
16047
  }
15920
- onNavigateToProgrammeView(data.programmeId);
15921
- return [3 /*break*/, 5];
15922
- case 3:
15923
- error_4 = _a.sent();
15924
- console.log("Error in investment creation - ", error_4);
16048
+ (data === null || data === void 0 ? void 0 : data.programmeId)
16049
+ ? onNavigateToProgrammeView(data === null || data === void 0 ? void 0 : data.programmeId)
16050
+ : onNavigateToInvestmentManagementView();
16051
+ return [3 /*break*/, 8];
16052
+ case 6:
16053
+ error_6 = _a.sent();
16054
+ console.log("Error in investment creation - ", error_6);
15925
16055
  message.open({
15926
16056
  type: "error",
15927
- content: error_4 === null || error_4 === void 0 ? void 0 : error_4.message,
16057
+ content: error_6 === null || error_6 === void 0 ? void 0 : error_6.message,
15928
16058
  duration: 4,
15929
16059
  style: { textAlign: "right", marginRight: 15, marginTop: 10 },
15930
16060
  });
15931
- return [3 /*break*/, 5];
15932
- case 4:
16061
+ return [3 /*break*/, 8];
16062
+ case 7:
15933
16063
  setLoading(false);
15934
16064
  return [7 /*endfinally*/];
15935
- case 5: return [2 /*return*/];
16065
+ case 8: return [2 /*return*/];
15936
16066
  }
15937
16067
  });
15938
16068
  }); };
@@ -15946,6 +16076,10 @@ var InvestmentCreationComponent = function (props) {
15946
16076
  var onChangeTypeCreation = function (e) {
15947
16077
  console.log("radio checked", e.target.value);
15948
16078
  setTypeCreation(e.target.value);
16079
+ formOne.resetFields();
16080
+ formTwo.resetFields();
16081
+ setCurrentPercTotal(0);
16082
+ setProjectData(undefined);
15949
16083
  };
15950
16084
  var onChangeInvestmentOwnershipType = function (e) {
15951
16085
  console.log("investment ownership type radio checked", e.target.value);
@@ -15984,7 +16118,18 @@ var InvestmentCreationComponent = function (props) {
15984
16118
  message: "".concat(t("programme:investorName"), " ").concat(t("isRequired")),
15985
16119
  },
15986
16120
  ] },
15987
- React.createElement(Select, { size: "large", loading: loadingList }, organisationsList.map(function (organisation) { return (React.createElement(Select.Option, { key: organisation.companyId, value: organisation.companyId }, organisation.name)); }))))),
16121
+ React.createElement(Select, { size: "large", loading: loadingList }, organisationsList.map(function (organisation) {
16122
+ if (data === null || data === void 0 ? void 0 : data.programmeId) {
16123
+ if (data.companyId
16124
+ .map(function (id) { return Number(id); })
16125
+ .includes(Number(organisation.companyId))) {
16126
+ return (React.createElement(Select.Option, { key: organisation.companyId, value: organisation.companyId }, organisation.name));
16127
+ }
16128
+ }
16129
+ else {
16130
+ return (React.createElement(Select.Option, { key: organisation.companyId, value: organisation.companyId }, organisation.name));
16131
+ }
16132
+ }))))),
15988
16133
  React.createElement(Col, { xl: 12, md: 24 },
15989
16134
  React.createElement("div", { className: "details-part-two" },
15990
16135
  React.createElement(Form.Item, { label: t("programme:amountInvested"), name: "amount", rules: [
@@ -16183,7 +16328,7 @@ var InvestmentCreationComponent = function (props) {
16183
16328
  message: "".concat(t("programme:existingInvestmentSource"), " ").concat(t("isRequired")),
16184
16329
  },
16185
16330
  ] },
16186
- React.createElement(Select, { size: "large", loading: loadingList }, organisationsList.map(function (organisation) { return (React.createElement(Select.Option, { key: organisation.companyId, value: organisation.companyId }, organisation.name)); })))))),
16331
+ React.createElement(Select, { size: "large", loading: loadingInvestment, onChange: setSelectedInvestment }, nationalInvestmentList.map(function (investment) { return (React.createElement(Select.Option, { key: investment.requestId, value: investment.requestId }, investment.investmentName)); })))))),
16187
16332
  React.createElement(Row, { className: "row", gutter: [16, 16] },
16188
16333
  React.createElement(Col, { xl: 12, md: 24 },
16189
16334
  React.createElement("div", { className: "details-part-two" },
@@ -16212,6 +16357,21 @@ var InvestmentCreationComponent = function (props) {
16212
16357
  });
16213
16358
  }); },
16214
16359
  },
16360
+ function (_a) {
16361
+ var getFieldValue = _a.getFieldValue;
16362
+ return ({
16363
+ validator: function (rule, v) {
16364
+ if (getFieldValue("amount") &&
16365
+ investmentData &&
16366
+ investmentData.amount <
16367
+ parseFloat(getFieldValue("amount"))) {
16368
+ // eslint-disable-next-line prefer-promise-reject-errors
16369
+ return Promise.reject("Amount > Available");
16370
+ }
16371
+ return Promise.resolve();
16372
+ },
16373
+ });
16374
+ },
16215
16375
  ] },
16216
16376
  React.createElement(Input, { size: "large" })))),
16217
16377
  React.createElement(Col, { xl: 12, md: 24 },
@@ -16221,7 +16381,9 @@ var InvestmentCreationComponent = function (props) {
16221
16381
  "/",
16222
16382
  React.createElement(InputNumber, { size: "large", width: "100%", formatter: function (value) {
16223
16383
  return "$".concat(addCommSep(value));
16224
- }, disabled: true })))))))),
16384
+ }, disabled: true, value: investmentData
16385
+ ? investmentData.amount
16386
+ : 0 })))))))),
16225
16387
  React.createElement(Form.Item, null,
16226
16388
  React.createElement("div", { className: "steps-actions" },
16227
16389
  React.createElement(Button, { type: "primary", htmlType: "submit", loading: loading, onSubmit: nextOne }, t("programme:next")))))))),
@@ -16252,105 +16414,140 @@ var InvestmentCreationComponent = function (props) {
16252
16414
  InvestmentOwnershipType.NATIONAL &&
16253
16415
  (data === null || data === void 0 ? void 0 : data.programmeId))) {
16254
16416
  return (React.createElement("div", { className: "condition-radio-container" },
16255
- React.createElement(Radio.Button, { className: "condition-radio", value: k, onChange: onChangeInvestmentOwnershipType, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) ==
16417
+ React.createElement(Tooltip, { title: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) ==
16256
16418
  CompanyRole.PROGRAMME_DEVELOPER &&
16257
16419
  stepOneData.toCompanyId !=
16258
16420
  userInfoState.companyId &&
16259
16421
  k ==
16260
- InvestmentOwnershipType.NATIONAL }, t("programme:" + k))));
16422
+ InvestmentOwnershipType.NATIONAL
16423
+ ? "This action is unauthorized due to the selected investor name."
16424
+ : "", color: TooltipColor, key: TooltipColor },
16425
+ React.createElement(Radio.Button, { className: "condition-radio", value: k, onChange: onChangeInvestmentOwnershipType, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) ==
16426
+ CompanyRole.PROGRAMME_DEVELOPER &&
16427
+ stepOneData.toCompanyId !=
16428
+ userInfoState.companyId &&
16429
+ k ==
16430
+ InvestmentOwnershipType.NATIONAL }, t("programme:" + k)))));
16261
16431
  }
16262
16432
  })))))))),
16263
- React.createElement("div", { className: "programme-sought-form-container ownership-container" }, Object.keys(data).length > 0 && (React.createElement("div", { className: "programme-sought-form" },
16264
- React.createElement(Form, { labelCol: { span: 20 }, wrapperCol: { span: 24 }, form: formTwo, name: "investment-sought", className: "investment-sought-form", layout: "vertical", requiredMark: true, onChange: onPercentageChange, onFinish: submitInvestment },
16265
- investmentOwnershipType ==
16266
- InvestmentOwnershipType.PROJECT && (React.createElement("div", null,
16267
- React.createElement(Row, { className: "row", gutter: [16, 16] },
16268
- React.createElement(Col, { xl: 12, md: 24 },
16269
- React.createElement("div", { className: "details-part-one" },
16270
- React.createElement(Form.Item, { label: t("programme:title"), name: "projectId", wrapperCol: { span: 24 }, rules: [
16271
- {
16272
- required: true,
16273
- message: "".concat(t("programme:title"), " ").concat(t("isRequired")),
16274
- },
16275
- ] },
16276
- React.createElement(Select, { size: "large", loading: loadingProgData, defaultValue: allProjectData.length == 1
16277
- ? allProjectData[0].title
16278
- : null, disabled: allProjectData.length == 1, onChange: setSelectedProgramme }, allProjectData.map(function (project) { return (React.createElement(Select.Option, { key: project.programmeId, value: project.programmeId }, project.title)); })))))), projectData === null || projectData === void 0 ? void 0 :
16279
- projectData.companyId.map(function (companyId, index) {
16280
- if (formTwo.getFieldValue("percentage") &&
16281
- formTwo.getFieldValue("percentage")[index] &&
16282
- companyId == stepOneData.toCompanyId) {
16283
- formTwo.getFieldValue("percentage")[index] = 0;
16284
- }
16285
- return (React.createElement(Row, { className: "row", gutter: [16, 16] },
16286
- React.createElement(Col, { xl: 8, md: 15 },
16287
- React.createElement("div", { className: "label" },
16288
- companyName[companyId].name,
16289
- React.createElement("span", { className: "required-mark" }, "*"))),
16290
- React.createElement(Col, { xl: 8, md: 9 },
16291
- React.createElement(Form.Item, { className: "inline", name: ["percentage", index], initialValue: 0, rules: [
16292
- {
16293
- pattern: new RegExp(/^[+]?([.]\d+|\d+[.]?\d*)$/g),
16294
- message: "Percentage Should be a positive number",
16295
- },
16296
- {
16297
- required: true,
16298
- message: "Required field",
16299
- },
16300
- function (_a) {
16301
- var getFieldValue = _a.getFieldValue;
16302
- return ({
16303
- validator: function (rule, v) {
16304
- if (getFieldValue([
16305
- "percentage",
16306
- index,
16307
- ]) &&
16308
- parseFloat(getFieldValue([
16433
+ React.createElement("div", { className: "programme-sought-form-container ownership-container" },
16434
+ React.createElement("div", { className: "programme-sought-form" },
16435
+ React.createElement(Form, { labelCol: { span: 20 }, wrapperCol: { span: 24 }, form: formTwo, name: "investment-sought", className: "investment-sought-form", layout: "vertical", requiredMark: true, onChange: onPercentageChange, onFinish: submitInvestment },
16436
+ allProjectData.length > 0 &&
16437
+ investmentOwnershipType ==
16438
+ InvestmentOwnershipType.PROJECT && (React.createElement("div", null,
16439
+ React.createElement(Row, { className: "row", gutter: [16, 16] },
16440
+ React.createElement(Col, { xl: 12, md: 24 },
16441
+ React.createElement("div", { className: "details-part-one" },
16442
+ React.createElement(Form.Item, { label: t("programme:title"), name: "projectId", wrapperCol: { span: 24 }, initialValue: allProjectData.length == 1
16443
+ ? allProjectData[0].programmeId
16444
+ : null, rules: [
16445
+ {
16446
+ required: true,
16447
+ message: "".concat(t("programme:title"), " ").concat(t("isRequired")),
16448
+ },
16449
+ ] },
16450
+ React.createElement(Select, { size: "large", loading: loadingProgData,
16451
+ // defaultValue={
16452
+ // allProjectData.length == 1
16453
+ // ? allProjectData[0].programmeId
16454
+ // : null
16455
+ // }
16456
+ disabled: allProjectData.length == 1, onChange: setSelectedProgramme }, allProjectData.map(function (project) {
16457
+ if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) ==
16458
+ CompanyRole.PROGRAMME_DEVELOPER &&
16459
+ Number(stepOneData.toCompanyId) !=
16460
+ userInfoState.companyId) {
16461
+ if (project.companyId
16462
+ .map(function (id) { return Number(id); })
16463
+ .includes(userInfoState.companyId)) {
16464
+ return (React.createElement(Select.Option, { key: project.programmeId, value: project.programmeId }, project.title));
16465
+ }
16466
+ }
16467
+ else if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) ===
16468
+ CompanyRole.MINISTRY) {
16469
+ if (ministrySectoralScope.includes(project.sectoralScope)) {
16470
+ return (React.createElement(Select.Option, { key: project.programmeId, value: project.programmeId }, project.title));
16471
+ }
16472
+ }
16473
+ else {
16474
+ return (React.createElement(Select.Option, { key: project.programmeId, value: project.programmeId }, project.title));
16475
+ }
16476
+ })))))), projectData === null || projectData === void 0 ? void 0 :
16477
+ projectData.companyId.map(function (companyId, index) {
16478
+ if (formTwo.getFieldValue("percentage") &&
16479
+ formTwo.getFieldValue("percentage")[index] &&
16480
+ companyId == stepOneData.toCompanyId) {
16481
+ formTwo.getFieldValue("percentage")[index] = 0;
16482
+ }
16483
+ return (React.createElement(Row, { className: "row", gutter: [16, 16] },
16484
+ React.createElement(Col, { xl: 8, md: 15 },
16485
+ React.createElement("div", { className: "label" },
16486
+ companyNames[Number(companyId)],
16487
+ React.createElement("span", { className: "required-mark" }, "*"))),
16488
+ React.createElement(Col, { xl: 8, md: 9 },
16489
+ React.createElement(Form.Item, { className: "inline", name: ["percentage", index], initialValue: 0, rules: [
16490
+ {
16491
+ pattern: new RegExp(/^[+]?([.]\d+|\d+[.]?\d*)$/g),
16492
+ message: "Percentage Should be a positive number",
16493
+ },
16494
+ {
16495
+ required: true,
16496
+ message: "Required field",
16497
+ },
16498
+ function (_a) {
16499
+ var getFieldValue = _a.getFieldValue;
16500
+ return ({
16501
+ validator: function (rule, v) {
16502
+ if (getFieldValue([
16309
16503
  "percentage",
16310
16504
  index,
16311
- ])) >
16312
- projectData
16313
- .proponentPercentage[index]) {
16314
- // eslint-disable-next-line prefer-promise-reject-errors
16315
- return Promise.reject("Amount > Available");
16316
- }
16317
- return Promise.resolve();
16318
- },
16319
- });
16320
- },
16321
- ] },
16322
- React.createElement(InputNumber, { placeholder: "", controls: false, disabled: govData.companyId ==
16323
- companyId ||
16324
- companyId ==
16325
- stepOneData.toCompanyId,
16326
- // defaultValue={0}
16327
- // disabled={userInfoState?.companyId === Number(companyId)}
16328
- onKeyPress: function (event) {
16505
+ ]) &&
16506
+ parseFloat(getFieldValue([
16507
+ "percentage",
16508
+ index,
16509
+ ])) >
16510
+ projectData
16511
+ .proponentPercentage[index]) {
16512
+ // eslint-disable-next-line prefer-promise-reject-errors
16513
+ return Promise.reject("Amount > Available");
16514
+ }
16515
+ return Promise.resolve();
16516
+ },
16517
+ });
16518
+ },
16519
+ ] },
16520
+ React.createElement(InputNumber, { placeholder: "", controls: false, disabled: govData.companyId ==
16521
+ companyId ||
16522
+ companyId ==
16523
+ stepOneData.toCompanyId, value: 0,
16524
+ // disabled={userInfoState?.companyId === Number(companyId)}
16525
+ onKeyPress: function (event) {
16526
+ if (!/[0-9\.]/.test(event.key)) {
16527
+ event.preventDefault();
16528
+ }
16529
+ } })),
16530
+ React.createElement("div", { className: "inline separator" }, "/"),
16531
+ React.createElement(Form.Item, { className: "inline" },
16532
+ React.createElement(InputNumber, { placeholder: String(projectData === null || projectData === void 0 ? void 0 : projectData.proponentPercentage[index]), disabled: true })))));
16533
+ }),
16534
+ React.createElement(Row, { className: "row", gutter: [16, 16] },
16535
+ React.createElement(Col, { xl: 8, md: 15 },
16536
+ React.createElement("div", { className: "label" }, t("programme:total"))),
16537
+ React.createElement(Col, { xl: 8, md: 9 },
16538
+ React.createElement(Form.Item, { className: "inline", name: ["total"] },
16539
+ React.createElement(InputNumber, { placeholder: currentPercTotal + "", controls: false, disabled: true, onKeyPress: function (event) {
16329
16540
  if (!/[0-9\.]/.test(event.key)) {
16330
16541
  event.preventDefault();
16331
16542
  }
16332
16543
  } })),
16333
16544
  React.createElement("div", { className: "inline separator" }, "/"),
16334
16545
  React.createElement(Form.Item, { className: "inline" },
16335
- React.createElement(InputNumber, { placeholder: String(projectData === null || projectData === void 0 ? void 0 : projectData.proponentPercentage[index]), disabled: true })))));
16336
- }),
16337
- React.createElement(Row, { className: "row", gutter: [16, 16] },
16338
- React.createElement(Col, { xl: 8, md: 15 },
16339
- React.createElement("div", { className: "label" }, t("programme:total"))),
16340
- React.createElement(Col, { xl: 8, md: 9 },
16341
- React.createElement(Form.Item, { className: "inline", name: ["total"] },
16342
- React.createElement(InputNumber, { placeholder: currentPercTotal + "", controls: false, disabled: true, onKeyPress: function (event) {
16343
- if (!/[0-9\.]/.test(event.key)) {
16344
- event.preventDefault();
16345
- }
16346
- } })),
16347
- React.createElement("div", { className: "inline separator" }, "/"),
16348
- React.createElement(Form.Item, { className: "inline" },
16349
- React.createElement(InputNumber, { disabled: true, placeholder: "100" })))))),
16350
- React.createElement(Form.Item, null,
16351
- React.createElement("div", { className: "steps-actions" },
16352
- React.createElement(Button, { type: "primary", htmlType: "submit", loading: loading, onSubmit: submitInvestment }, t("programme:submit")),
16353
- React.createElement(Button, { className: "back-btn", onClick: function () { return prevOne(); }, loading: loading }, t("programme:back")))))))))),
16546
+ React.createElement(InputNumber, { disabled: true, placeholder: "100" })))))),
16547
+ React.createElement(Form.Item, null,
16548
+ React.createElement("div", { className: "steps-actions" },
16549
+ React.createElement(Button, { type: "primary", htmlType: "submit", loading: loading, onSubmit: submitInvestment }, t("programme:submit")),
16550
+ React.createElement(Button, { className: "back-btn", onClick: function () { return prevOne(); }, loading: loading }, t("programme:back"))))))))),
16354
16551
  },
16355
16552
  ] })))));
16356
16553
  };
@@ -16799,7 +16996,10 @@ var InvestmentManagementComponent = function (props) {
16799
16996
  sorter: true,
16800
16997
  align: "left",
16801
16998
  render: function (item) {
16802
- return React.createElement("span", { className: "clickable" }, item);
16999
+ if (item) {
17000
+ return React.createElement("span", { className: "clickable" }, item);
17001
+ }
17002
+ return React.createElement("span", null, "-");
16803
17003
  },
16804
17004
  onCell: function (record, rowIndex) {
16805
17005
  return {
@@ -16857,6 +17057,12 @@ var InvestmentManagementComponent = function (props) {
16857
17057
  key: "programmeSector",
16858
17058
  sorter: true,
16859
17059
  align: "left",
17060
+ render: function (item) {
17061
+ if (item) {
17062
+ return React.createElement("span", null, item);
17063
+ }
17064
+ return React.createElement("span", null, "-");
17065
+ },
16860
17066
  },
16861
17067
  {
16862
17068
  title: t("programme:investor"),
@@ -16940,7 +17146,11 @@ var InvestmentManagementComponent = function (props) {
16940
17146
  React.createElement("div", { className: "title-bar" },
16941
17147
  React.createElement("div", { className: "body-title" }, t("programme:investmentTitle")),
16942
17148
  React.createElement("div", { className: "body-sub-title" }, t("programme:investmentDesc"))),
16943
- React.createElement("div", { className: "actions" }, enableAddOwnership && (React.createElement("div", { className: "action-bar" },
17149
+ React.createElement("div", { className: "actions" }, enableAddOwnership &&
17150
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) == CompanyRole.MINISTRY ||
17151
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) == CompanyRole.GOVERNMENT ||
17152
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) == CompanyRole.PROGRAMME_DEVELOPER) &&
17153
+ userInfoState.userRole != Role.ViewOnly && (React.createElement("div", { className: "action-bar" },
16944
17154
  React.createElement(Button, { type: "primary", size: "large", block: true, icon: React.createElement(PlusOutlined, null), onClick: onClickAddOwnership }, t("programme:addOwnership")))))),
16945
17155
  React.createElement("div", { className: "content-card" },
16946
17156
  React.createElement(Row, null,
@@ -16981,7 +17191,7 @@ var InvestmentManagementComponent = function (props) {
16981
17191
  return handleTableChange(val, sorter);
16982
17192
  }, locale: {
16983
17193
  emptyText: (React.createElement(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: tableData.length === 0
16984
- ? t("creditTransfer:noTransfer")
17194
+ ? t("programme:noInvestmentData")
16985
17195
  : null })),
16986
17196
  } }))))),
16987
17197
  popupInfo && selectedReq && (React.createElement(InvestmentActionModel, { investment: selectedReq, onCancel: function () {