@undp/carbon-library 1.0.34 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +50 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +50 -11
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4589,7 +4589,7 @@ antd.Select.Option;
|
|
|
4589
4589
|
var AddNewUserComponent = function (props) {
|
|
4590
4590
|
var _a, _b, _c, _d, _e, _f;
|
|
4591
4591
|
var t = props.t, onNavigateToUserManagement = props.onNavigateToUserManagement, onNavigateLogin = props.onNavigateLogin, useConnection = props.useConnection, useUserContext = props.useUserContext, useLocation = props.useLocation, useAbilityContext = props.useAbilityContext;
|
|
4592
|
-
var _g = useConnection(), post = _g.post, put = _g.put, del = _g.delete;
|
|
4592
|
+
var _g = useConnection(), post = _g.post, put = _g.put, del = _g.delete, get = _g.get;
|
|
4593
4593
|
var formOne = antd.Form.useForm()[0];
|
|
4594
4594
|
var state = useLocation().state;
|
|
4595
4595
|
var updateToken = useConnection().updateToken;
|
|
@@ -4603,8 +4603,46 @@ var AddNewUserComponent = function (props) {
|
|
|
4603
4603
|
var _p = React.useState(""), errorMsg = _p[0], setErrorMsg = _p[1];
|
|
4604
4604
|
var userInfoState = useUserContext().userInfoState;
|
|
4605
4605
|
var ability = useAbilityContext();
|
|
4606
|
+
var _q = React.useState([]), countries = _q[0], setCountries = _q[1];
|
|
4607
|
+
var _r = React.useState(false), isCountryListLoading = _r[0], setIsCountryListLoading = _r[1];
|
|
4608
|
+
var getCountryList = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4609
|
+
var response, alpha2Names, error_1;
|
|
4610
|
+
return __generator(this, function (_a) {
|
|
4611
|
+
switch (_a.label) {
|
|
4612
|
+
case 0:
|
|
4613
|
+
setIsCountryListLoading(true);
|
|
4614
|
+
_a.label = 1;
|
|
4615
|
+
case 1:
|
|
4616
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
4617
|
+
return [4 /*yield*/, get("national/organisation/countries")];
|
|
4618
|
+
case 2:
|
|
4619
|
+
response = _a.sent();
|
|
4620
|
+
if (response.data) {
|
|
4621
|
+
alpha2Names = response.data.map(function (item) {
|
|
4622
|
+
return item.alpha2;
|
|
4623
|
+
});
|
|
4624
|
+
setCountries(alpha2Names);
|
|
4625
|
+
}
|
|
4626
|
+
return [3 /*break*/, 5];
|
|
4627
|
+
case 3:
|
|
4628
|
+
error_1 = _a.sent();
|
|
4629
|
+
console.log("Error in getCountryList", error_1);
|
|
4630
|
+
antd.message.open({
|
|
4631
|
+
type: "error",
|
|
4632
|
+
content: "".concat(error_1.message),
|
|
4633
|
+
duration: 3,
|
|
4634
|
+
style: { textAlign: "right", marginRight: 15, marginTop: 10 },
|
|
4635
|
+
});
|
|
4636
|
+
return [3 /*break*/, 5];
|
|
4637
|
+
case 4:
|
|
4638
|
+
setIsCountryListLoading(false);
|
|
4639
|
+
return [7 /*endfinally*/];
|
|
4640
|
+
case 5: return [2 /*return*/];
|
|
4641
|
+
}
|
|
4642
|
+
});
|
|
4643
|
+
}); };
|
|
4606
4644
|
var onAddUser = function (values) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4607
|
-
var response,
|
|
4645
|
+
var response, error_2;
|
|
4608
4646
|
return __generator(this, function (_a) {
|
|
4609
4647
|
switch (_a.label) {
|
|
4610
4648
|
case 0:
|
|
@@ -4633,11 +4671,11 @@ var AddNewUserComponent = function (props) {
|
|
|
4633
4671
|
}
|
|
4634
4672
|
return [3 /*break*/, 5];
|
|
4635
4673
|
case 3:
|
|
4636
|
-
|
|
4637
|
-
console.log("Error in user creation",
|
|
4674
|
+
error_2 = _a.sent();
|
|
4675
|
+
console.log("Error in user creation", error_2);
|
|
4638
4676
|
antd.message.open({
|
|
4639
4677
|
type: "error",
|
|
4640
|
-
content: "".concat(
|
|
4678
|
+
content: "".concat(error_2.message),
|
|
4641
4679
|
duration: 3,
|
|
4642
4680
|
style: { textAlign: "right", marginRight: 15, marginTop: 10 },
|
|
4643
4681
|
});
|
|
@@ -4650,7 +4688,7 @@ var AddNewUserComponent = function (props) {
|
|
|
4650
4688
|
});
|
|
4651
4689
|
}); };
|
|
4652
4690
|
var onUpdateUser = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4653
|
-
var formOneValues, values, response,
|
|
4691
|
+
var formOneValues, values, response, error_3;
|
|
4654
4692
|
var _a;
|
|
4655
4693
|
return __generator(this, function (_b) {
|
|
4656
4694
|
switch (_b.label) {
|
|
@@ -4687,11 +4725,11 @@ var AddNewUserComponent = function (props) {
|
|
|
4687
4725
|
}
|
|
4688
4726
|
return [3 /*break*/, 4];
|
|
4689
4727
|
case 3:
|
|
4690
|
-
|
|
4691
|
-
console.log("Error in user update",
|
|
4728
|
+
error_3 = _b.sent();
|
|
4729
|
+
console.log("Error in user update", error_3);
|
|
4692
4730
|
antd.message.open({
|
|
4693
4731
|
type: "error",
|
|
4694
|
-
content: "".concat(t("updateUserError"), " ").concat(
|
|
4732
|
+
content: "".concat(t("updateUserError"), " ").concat(error_3.message),
|
|
4695
4733
|
duration: 3,
|
|
4696
4734
|
style: { textAlign: "right", marginRight: 15, marginTop: 10 },
|
|
4697
4735
|
});
|
|
@@ -4814,6 +4852,7 @@ var AddNewUserComponent = function (props) {
|
|
|
4814
4852
|
}); };
|
|
4815
4853
|
React.useEffect(function () {
|
|
4816
4854
|
console.log("state -- val --- ", __assign({}, state));
|
|
4855
|
+
getCountryList();
|
|
4817
4856
|
setIsUpdate((state === null || state === void 0 ? void 0 : state.record) ? true : false);
|
|
4818
4857
|
}, []);
|
|
4819
4858
|
return (React.createElement("div", { className: "add-user-main-container" },
|
|
@@ -4907,14 +4946,14 @@ var AddNewUserComponent = function (props) {
|
|
|
4907
4946
|
React.createElement(antd.Radio.Button, { className: "view-only", value: "ViewOnly" },
|
|
4908
4947
|
React.createElement(icons.EyeOutlined, { className: "role-icons" }),
|
|
4909
4948
|
t("addUser:viewer")))))),
|
|
4910
|
-
React.createElement(antd.Form.Item, { name: "phoneNo", label: t("addUser:phoneNo"), initialValue: (_f = state === null || state === void 0 ? void 0 : state.record) === null || _f === void 0 ? void 0 : _f.phoneNo, rules: [
|
|
4949
|
+
React.createElement(antd.Skeleton, { loading: isCountryListLoading, active: true }, countries.length > 0 && (React.createElement(antd.Form.Item, { name: "phoneNo", label: t("addUser:phoneNo"), initialValue: (_f = state === null || state === void 0 ? void 0 : state.record) === null || _f === void 0 ? void 0 : _f.phoneNo, rules: [
|
|
4911
4950
|
{
|
|
4912
4951
|
required: false,
|
|
4913
4952
|
},
|
|
4914
4953
|
] },
|
|
4915
4954
|
React.createElement(PhoneInput, { placeholder: t("addUser:phoneNo"), international: true,
|
|
4916
4955
|
// value={contactNoInput}
|
|
4917
|
-
defaultCountry: "LK", countryCallingCodeEditable: false, onChange: function (v) { } }))))),
|
|
4956
|
+
defaultCountry: "LK", countryCallingCodeEditable: false, onChange: function (v) { }, countries: countries }))))))),
|
|
4918
4957
|
React.createElement("div", { className: "actions" },
|
|
4919
4958
|
React.createElement(antd.Form.Item, null,
|
|
4920
4959
|
React.createElement("div", { className: "create-user-btn-container" },
|