atp-authorization-aiqoe 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atp-authorization-aiqoe",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "IAM",
5
5
  "scripts": {
6
6
  "build": "rollup -c",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@reduxjs/toolkit": "^1.8.2",
40
- "atp-authorization-aiqoe-binder": "^1.0.1",
40
+ "atp-authorization-aiqoe-binder": "^1.0.7",
41
41
  "atp-iam-binder": "^1.0.5",
42
42
  "atp-multilingual": "^1.0.12",
43
43
  "axios": "^0.27.2",
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable */
2
2
 
3
- import React, { useState, useEffect } from "react";
3
+ import React, { useState, useEffect, useContext, act } from "react";
4
4
  import {
5
5
  Typography,
6
6
  Button,
@@ -28,6 +28,8 @@ import { v4 as uuidV4 } from "uuid";
28
28
  import DeleteComponent from "./deleteComp";
29
29
  import { withAllContexts } from "../../../HOCs";
30
30
  import { messageCatalogGetter } from "../../../utils/common/function";
31
+ import { AlertContext } from "../../../contexts";
32
+ import axios from 'axios';
31
33
 
32
34
  const IOSSwitch = withStyles((theme) => ({
33
35
  root: {
@@ -91,6 +93,12 @@ function RolesMapping(props) {
91
93
  (state) => state?.permissionSlice?.permission_read_as_options?.data
92
94
  ); // PERMISSION_LIST_AS_OPTIONS
93
95
 
96
+ const startUpList = useSelector(
97
+ (state) => state?.rolesSlice?.get_Start_up_List?.data
98
+ );
99
+
100
+ // const alert = useContext(AlertContext);
101
+
94
102
  // Component State ----------------------------------------------------------
95
103
  const [roleList, setRoleList] = useState(cloneroleList); // State for Full Role List to maintain search further
96
104
  const [loader, setLoader] = useState(true); // Toggling loading state
@@ -100,6 +108,7 @@ function RolesMapping(props) {
100
108
  const [isAdd, setIsAdd] = useState(false);
101
109
  const [roles, setRoles] = useState({
102
110
  roleName: "",
111
+ startUp: {},
103
112
  permissions: [],
104
113
  errorMsg: "",
105
114
  });
@@ -107,6 +116,7 @@ function RolesMapping(props) {
107
116
  // State for currently selected role
108
117
  selectedRole: {},
109
118
  roleName: "",
119
+ startUp: {},
110
120
  permissions: [],
111
121
  id: "",
112
122
  activestatus: true,
@@ -126,6 +136,7 @@ function RolesMapping(props) {
126
136
 
127
137
  const getPermissionOptions = async () => {
128
138
  await dispatch(actions.PERMISSION_READ_AS_OPTIONS());
139
+ await dispatch(actions.GET_STARTUP_LIST());
129
140
  };
130
141
 
131
142
  useEffect(() => {
@@ -134,10 +145,10 @@ function RolesMapping(props) {
134
145
  }, []);
135
146
 
136
147
  // Set Permission
137
- const handlePermissionChange = (value) => {
148
+ const handlePermissionChange = (name,value) => {
138
149
  setRoleDetails((prev) => ({
139
150
  ...prev,
140
- permissions: value,
151
+ [name]: value,
141
152
  }));
142
153
  };
143
154
 
@@ -172,10 +183,10 @@ function RolesMapping(props) {
172
183
 
173
184
  // ------------------- UPSERT HANDLER --------------------------------------
174
185
  const handleSave = async (rolevalue) => {
175
-
176
186
  if (
177
187
  rolevalue.roleName.length !== 0 &&
178
- rolevalue.permissions.length !== 0
188
+ rolevalue.permissions.length !== 0 &&
189
+ rolevalue?.startUp?._id
179
190
  ) {
180
191
 
181
192
  if (editMode) {
@@ -185,7 +196,7 @@ function RolesMapping(props) {
185
196
  }
186
197
  showBackdrop();
187
198
 
188
- const { roleName, permissions, id, activestatus, _key } =
199
+ const { roleName, permissions, id, activestatus, _key,startUp } =
189
200
  roleDetails;
190
201
  var payload = {};
191
202
  if (isAdd) {
@@ -197,6 +208,7 @@ function RolesMapping(props) {
197
208
  metadataid: "",
198
209
  clientid: "",
199
210
  projectid: "",
211
+ startupid: rolevalue.startUp._id ?? ""
200
212
  // _key: _key ? _key : "",
201
213
  };
202
214
  } else {
@@ -209,6 +221,7 @@ function RolesMapping(props) {
209
221
  metadataid: "",
210
222
  clientid: "",
211
223
  projectid: "",
224
+ startupid: startUp._id ?? ""
212
225
  };
213
226
  }
214
227
  console.log("payload" , payload);
@@ -415,10 +428,10 @@ function RolesMapping(props) {
415
428
  // );
416
429
 
417
430
  const roleById = await dispatch(
418
- actions.GET_ROLE_BY_ID({ roleid: _role?.roleid })
431
+ actions.GET_PER_ROLE_BY_ID({ perroleid: _role?._id })
419
432
  );
420
433
 
421
- const data = roleById?.payload?.data?.result?.[0];
434
+ const data = roleById?.payload?.data?.[0];
422
435
 
423
436
  const preloadOptions = data?.perrolepermsnid?.map((item) => ({
424
437
  ...item,
@@ -431,6 +444,7 @@ function RolesMapping(props) {
431
444
  permissions: preloadOptions,
432
445
  selectedRole: _role,
433
446
  roleName: _role?.rolename ?? "",
447
+ startUp: data?.startupid,
434
448
  roleId: _role?.roleid ?? "",
435
449
  id: data?.id,
436
450
  activestatus: data?.activestatus,
@@ -449,6 +463,7 @@ function RolesMapping(props) {
449
463
  ...roleDetails,
450
464
  selectedRole: _role,
451
465
  roleName: "",
466
+ startUp: {},
452
467
  roleId: "",
453
468
  permissions: [],
454
469
  id: "",
@@ -662,71 +677,144 @@ function RolesMapping(props) {
662
677
  <Divider />
663
678
  <div className={classes.RightSideStyle}>
664
679
  <Grid container>
665
- {/* Title */}
666
- <Grid item xs={12}>
667
- <div>
668
- <Typography className={classes.TypoStyle}
669
- color="textSecondary"
670
- variant="body2"
671
- >
672
- Permission List
673
- </Typography>
674
- </div>
675
- </Grid>
676
680
 
677
681
  {/* Permission list Fields / Chips */}
678
682
  <Grid item xs={12}>
679
683
  {editMode ? (
680
- <div style={{ padding: "6px 20px 6px" }}>
681
- <Typography className={classes.TypoStylepermission}
682
- id={`permission-list-typography`}
683
-
684
- >
685
- Select Permission List
686
- <span style={{ color: "red" }}>*</span>
687
- </Typography>
688
- <Autocomplete
689
- multiple
690
- fullWidth
691
- size="small"
692
- getOptionLabel={(option) => option["label"]}
693
- value={roleDetails?.permissions ?? []}
694
- options={
695
- Array.isArray(permissionList) ? permissionList : []
696
- }
697
- onChange={(e, value) => handlePermissionChange(value)}
698
- renderInput={(params) => (
699
- <TextField
700
- {...params}
701
- label={false}
702
- variant="outlined"
703
- placeholder="Type Here"
684
+ <div>
685
+ <div style={{ padding: "6px 20px 6px" }}>
686
+ <Grid>
687
+ <Typography className={classes.TypoStylepermission}
688
+ id={`permission-list-typography`}
689
+
690
+ >
691
+ Select Permission List
692
+ <span style={{ color: "red" }}>*</span>
693
+ </Typography>
694
+ <Autocomplete
695
+ multiple
696
+ fullWidth
704
697
  size="small"
705
- error={
706
- roleDetails?.error?.permissions ? true : false
698
+ getOptionLabel={(option) => option["label"]}
699
+ value={roleDetails?.permissions ?? []}
700
+ options={
701
+ Array.isArray(permissionList) ? permissionList : []
707
702
  }
708
- helperText={
709
- roleDetails?.error?.permissions
710
- ? roleDetails?.errorMsg?.permissions
711
- : ""
703
+ onChange={(e, value) => handlePermissionChange("permissions",value)}
704
+ renderInput={(params) => (
705
+ <TextField
706
+ {...params}
707
+ label={false}
708
+ variant="outlined"
709
+ placeholder="Type Here"
710
+ size="small"
711
+ error={
712
+ roleDetails?.error?.permissions ? true : false
713
+ }
714
+ helperText={
715
+ roleDetails?.error?.permissions
716
+ ? roleDetails?.errorMsg?.permissions
717
+ : ""
718
+ }
719
+ />
720
+ )}
721
+ classes={{
722
+ tag: classes.autocompleteTag,
723
+ paper: classes.dropDownPaper,
724
+ }}
725
+ />
726
+ </Grid>
727
+ </div>
728
+ <div style={{ padding: "6px 20px 6px" }}>
729
+ <Grid>
730
+ <Typography className={classes.TypoStylepermission}
731
+ id={`permission-list-typography`}
732
+
733
+ >
734
+ Startup
735
+ <span style={{ color: "red" }}>*</span>
736
+ </Typography>
737
+ <Autocomplete
738
+ fullWidth
739
+ size="small"
740
+ getOptionLabel={(option) => option["label"]}
741
+ value={roleDetails?.startUp ?? {}}
742
+ options={
743
+ Array.isArray(startUpList) ? startUpList : []
712
744
  }
745
+ onChange={(e, value) => handlePermissionChange("startUp",value)}
746
+ renderInput={(params) => (
747
+ <TextField
748
+ {...params}
749
+ label={false}
750
+ variant="outlined"
751
+ placeholder="Type Here"
752
+ size="small"
753
+ error={
754
+ roleDetails?.error?.permissions ? true : false
755
+ }
756
+ helperText={
757
+ roleDetails?.error?.permissions
758
+ ? roleDetails?.errorMsg?.permissions
759
+ : ""
760
+ }
761
+ />
762
+ )}
763
+ classes={{
764
+ tag: classes.autocompleteTag,
765
+ paper: classes.dropDownPaper,
766
+ }}
713
767
  />
714
- )}
715
- classes={{
716
- tag: classes.autocompleteTag,
717
- paper: classes.dropDownPaper,
718
- }}
719
- />
768
+ </Grid>
769
+ </div>
720
770
  </div>
771
+
721
772
  ) : (
722
- <div className={classes.chipStyle}>
723
- {roleDetails?.permissions?.map((permission) => (
724
- <Chip
725
- label={permission?.permsnname}
726
- classes={{ root: classes.rolesChipRoot }}
727
- />
728
- ))}
773
+ <div>
774
+ <Grid>
775
+ <Grid item xs={12}>
776
+ <div>
777
+ {!editMode && (
778
+ <Typography className={classes.TypoStyle}
779
+ color="textSecondary"
780
+ variant="body2"
781
+ >
782
+ Permission List
783
+ </Typography>
784
+ )}
785
+ </div>
786
+ </Grid>
787
+ <div className={classes.chipStyle}>
788
+ {roleDetails?.permissions?.map((permission) => (
789
+ <Chip
790
+ label={permission?.permsnname}
791
+ classes={{ root: classes.rolesChipRoot }}
792
+ />
793
+ ))}
794
+ </div>
795
+ </Grid>
796
+ <Grid>
797
+ <Grid item xs={12}>
798
+ <div>
799
+ {!editMode && (
800
+ <Typography className={classes.TypoStyle}
801
+ color="textSecondary"
802
+ variant="body2"
803
+ >
804
+ Start Up
805
+ </Typography>
806
+ )}
807
+ </div>
808
+ </Grid>
809
+ <div className={classes.chipStyle}>
810
+ <Chip
811
+ label={roleDetails.startUp?.value}
812
+ classes={{ root: classes.rolesChipRoot }}
813
+ />
814
+ </div>
815
+ </Grid>
729
816
  </div>
817
+
730
818
  )}
731
819
  </Grid>
732
820
  </Grid>
@@ -824,6 +912,52 @@ function RolesMapping(props) {
824
912
  </div>
825
913
  </Grid>
826
914
  </Grid>
915
+ <Grid container>
916
+ {/* Permission list Fields / Chips */}
917
+ <Grid item xs={12}>
918
+ <div className={classes.InsideFormStyle} >
919
+ <Typography
920
+ id={`permission-list-typography`}
921
+ className={classes.InsideFormHeadStyle}>
922
+ Startup
923
+ <span className={classes.spanStyle} style={{ color: "red" }}>*</span>
924
+ </Typography>
925
+ <Autocomplete
926
+ fullWidth
927
+ size="small"
928
+ getOptionLabel={(option) => option["label"]}
929
+ value={roles?.startUp ?? {}}
930
+ options={
931
+ Array.isArray(startUpList) ? startUpList : []
932
+ }
933
+ onChange={(e, value) =>
934
+ setRoles({ ...roles, startUp: value })
935
+ }
936
+ renderInput={(params) => (
937
+ <TextField
938
+ {...params}
939
+ label={false}
940
+ variant="outlined"
941
+ placeholder="Type Here"
942
+ size="small"
943
+ error={
944
+ roleDetails?.error?.permissions ? true : false
945
+ }
946
+ helperText={
947
+ roleDetails?.error?.permissions
948
+ ? roleDetails?.errorMsg?.permissions
949
+ : ""
950
+ }
951
+ />
952
+ )}
953
+ classes={{
954
+ tag: classes.autocompleteTag,
955
+ paper: classes.dropDownPaper,
956
+ }}
957
+ />
958
+ </div>
959
+ </Grid>
960
+ </Grid>
827
961
  </div>
828
962
 
829
963
  {/* Crud action buttons */}