@thecb/components 4.3.3 → 4.3.6

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/index.cjs.js CHANGED
@@ -18770,6 +18770,7 @@ var Checkbox = function Checkbox(_ref4) {
18770
18770
  hidden = _ref4$hidden === void 0 ? false : _ref4$hidden,
18771
18771
  _ref4$error = _ref4.error,
18772
18772
  error = _ref4$error === void 0 ? false : _ref4$error,
18773
+ extraStyles = _ref4.extraStyles,
18773
18774
  textExtraStyles = _ref4.textExtraStyles;
18774
18775
 
18775
18776
  var _useState = React.useState(false),
@@ -18797,7 +18798,7 @@ var Checkbox = function Checkbox(_ref4) {
18797
18798
  },
18798
18799
  hiddenStyles: hidden,
18799
18800
  background: themeValues.backgroundColor,
18800
- extraStyles: "outline: none;"
18801
+ extraStyles: "outline: none; ".concat(extraStyles)
18801
18802
  }, /*#__PURE__*/React__default.createElement(CheckboxLabelContainer, null, /*#__PURE__*/React__default.createElement(CheckboxContainer, {
18802
18803
  "data-qa": "Checkbox"
18803
18804
  }, /*#__PURE__*/React__default.createElement(HiddenCheckbox, {
@@ -21817,17 +21818,17 @@ var PasswordRequirements = function PasswordRequirements(_ref) {
21817
21818
  isMobile = _ref.isMobile;
21818
21819
  var iconMap = (_iconMap = {}, _defineProperty(_iconMap, INPUT_STATE_NEUTRAL, {
21819
21820
  icon: /*#__PURE__*/React__default.createElement(IconNeutral, {
21820
- margin: "0.125rem 0.5rem 0 0"
21821
+ margin: "0 0.5rem 0 0"
21821
21822
  }),
21822
21823
  color: MINESHAFT_GREY
21823
21824
  }), _defineProperty(_iconMap, INPUT_STATE_INVALID, {
21824
21825
  icon: /*#__PURE__*/React__default.createElement(IconInvalid, {
21825
- margin: "0.125rem 0.5rem 0 0"
21826
+ margin: "0 0.5rem 0 0"
21826
21827
  }),
21827
21828
  color: RAZZMATAZZ_RED
21828
21829
  }), _defineProperty(_iconMap, INPUT_STATE_VALID, {
21829
21830
  icon: /*#__PURE__*/React__default.createElement(IconValid, {
21830
- margin: "0.125rem 0.5rem 0 0"
21831
+ margin: "0 0.5rem 0 0"
21831
21832
  }),
21832
21833
  color: FOREST_GREEN
21833
21834
  }), _iconMap);
@@ -21877,7 +21878,7 @@ var PasswordRequirements = function PasswordRequirements(_ref) {
21877
21878
  onRight: true,
21878
21879
  childGap: "0rem"
21879
21880
  }, /*#__PURE__*/React__default.createElement(Box, {
21880
- padding: "0rem"
21881
+ padding: "0.15rem 0 0 0"
21881
21882
  }, /*#__PURE__*/React__default.createElement(Cluster, {
21882
21883
  justify: "flex-start",
21883
21884
  align: "center"
@@ -22180,7 +22181,7 @@ var SearchableSelect = function SearchableSelect(_ref) {
22180
22181
  errorMessages: {},
22181
22182
  field: fields.searchTerm,
22182
22183
  fieldActions: actions.fields.searchTerm,
22183
- placeholder: "Search departments",
22184
+ placeholder: "Search agencies",
22184
22185
  disabled: disabled
22185
22186
  }), /*#__PURE__*/React__default.createElement(Box, {
22186
22187
  padding: "0.5rem 0",
@@ -22197,7 +22198,8 @@ var SearchableSelect = function SearchableSelect(_ref) {
22197
22198
  return handleSelect(value);
22198
22199
  },
22199
22200
  textExtraStyles: "margin: 0;",
22200
- disabled: disabled
22201
+ disabled: disabled,
22202
+ extraStyles: "margin: 0 0.5rem;"
22201
22203
  });
22202
22204
  })))));
22203
22205
  };
@@ -34849,7 +34851,11 @@ var ChangePasswordForm = function ChangePasswordForm(_ref) {
34849
34851
  _ref$handleSubmit = _ref.handleSubmit,
34850
34852
  handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
34851
34853
  showErrors = _ref.showErrors,
34852
- isMobile = _ref.isMobile;
34854
+ isMobile = _ref.isMobile,
34855
+ revenueManagement = _ref.revenueManagement,
34856
+ closeForm = _ref.closeForm,
34857
+ firstName = _ref.firstName,
34858
+ lastName = _ref.lastName;
34853
34859
 
34854
34860
  if (clearOnDismount) {
34855
34861
  React.useEffect(function () {
@@ -34867,7 +34873,29 @@ var ChangePasswordForm = function ChangePasswordForm(_ref) {
34867
34873
 
34868
34874
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
34869
34875
  role: "form",
34870
- "aria-label": "Change password"
34876
+ "aria-label": "Change password",
34877
+ extraStyles: "padding: 0;"
34878
+ }, revenueManagement && /*#__PURE__*/React__default.createElement(Box, {
34879
+ padding: "1.5rem",
34880
+ borderColor: GHOST_GREY,
34881
+ borderSize: "1px",
34882
+ borderWidthOverride: "0 0 1px 0"
34883
+ }, /*#__PURE__*/React__default.createElement(Cluster, {
34884
+ justify: "flex-start",
34885
+ align: "center"
34886
+ }, /*#__PURE__*/React__default.createElement(Box, {
34887
+ padding: "1.25rem",
34888
+ borderRadius: "50%",
34889
+ background: "#CACED8"
34890
+ }, /*#__PURE__*/React__default.createElement(Heading$1, {
34891
+ variant: "h4",
34892
+ weight: "700"
34893
+ }, firstName.charAt(0).toUpperCase(), lastName.charAt(0).toUpperCase())), /*#__PURE__*/React__default.createElement(Text$1, {
34894
+ variant: "p",
34895
+ weight: "700",
34896
+ extraStyles: "padding-left: 1rem;"
34897
+ }, firstName, " ", lastName))), /*#__PURE__*/React__default.createElement(Box, {
34898
+ padding: "1.5rem"
34871
34899
  }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(FormInput$1, {
34872
34900
  labelTextWhenNoError: "Current password",
34873
34901
  errorMessages: currentPasswordErrorMessages,
@@ -34906,7 +34934,25 @@ var ChangePasswordForm = function ChangePasswordForm(_ref) {
34906
34934
  }, /*#__PURE__*/React__default.createElement(PasswordRequirements, {
34907
34935
  password: fields.newPassword,
34908
34936
  isMobile: isMobile
34909
- }))));
34937
+ }))), revenueManagement && /*#__PURE__*/React__default.createElement(Box, {
34938
+ padding: "1.5rem 0 0"
34939
+ }, /*#__PURE__*/React__default.createElement(Stack, {
34940
+ childGap: "1rem",
34941
+ direction: "row",
34942
+ justify: "flex-end"
34943
+ }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
34944
+ text: "Cancel",
34945
+ action: closeForm,
34946
+ variant: "secondary",
34947
+ dataQa: "Cancel",
34948
+ extraStyles: "margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;"
34949
+ }), /*#__PURE__*/React__default.createElement(ButtonWithAction, {
34950
+ text: "Save",
34951
+ action: handleSubmit,
34952
+ variant: "primary",
34953
+ dataQa: "Save",
34954
+ extraStyles: "margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;"
34955
+ })))));
34910
34956
  };
34911
34957
 
34912
34958
  var formConfig$1 = {
@@ -37062,6 +37108,9 @@ var CLIENT_ADMIN = "CLIENT_ADMIN";
37062
37108
  var SUPERVISOR = "SUPERVISOR";
37063
37109
  var CB_ADMIN = "CITYBASE_ADMIN";
37064
37110
  var CREATE_CLIENT_ADMIN = "CREATE_CLIENT_ADMIN";
37111
+ var PROFILE = "PROFILE";
37112
+ var ADD = "ADD";
37113
+ var EDIT = "EDIT";
37065
37114
  var roleDescriptions = (_roleDescriptions = {}, _defineProperty(_roleDescriptions, RESEARCHER, "Researcher"), _defineProperty(_roleDescriptions, AGENCY_ADMIN, "Agency admin"), _defineProperty(_roleDescriptions, CLIENT_ADMIN, "Client admin"), _defineProperty(_roleDescriptions, SUPERVISOR, "Supervisor"), _defineProperty(_roleDescriptions, CB_ADMIN, "Citybase admin"), _roleDescriptions);
37066
37115
 
37067
37116
  var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
@@ -37073,21 +37122,32 @@ var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
37073
37122
  showErrors = _ref.showErrors,
37074
37123
  _ref$handleSubmit = _ref.handleSubmit,
37075
37124
  handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
37125
+ closeForm = _ref.closeForm,
37076
37126
  allAgencyOptions = _ref.allAgencyOptions,
37077
37127
  selectedAgencies = _ref.selectedAgencies,
37078
37128
  allSelected = _ref.allSelected,
37079
- toggleSelectAllAgencies = _ref.toggleSelectAllAgencies,
37129
+ _ref$toggleSelectAllA = _ref.toggleSelectAllAgencies,
37130
+ toggleSelectAllAgencies = _ref$toggleSelectAllA === void 0 ? noop : _ref$toggleSelectAllA,
37080
37131
  selectAgency = _ref.selectAgency,
37081
37132
  roleOptions = _ref.roleOptions,
37082
37133
  clientOptions = _ref.clientOptions,
37083
- disabled = _ref.disabled,
37084
37134
  emailDisabled = _ref.emailDisabled,
37085
37135
  roleDisabled = _ref.roleDisabled,
37086
- formType = _ref.formType;
37136
+ selectionDisabled = _ref.selectionDisabled,
37137
+ formType = _ref.formType,
37138
+ isOktaUser = _ref.isOktaUser,
37139
+ openChangePasswordForm = _ref.openChangePasswordForm,
37140
+ firstName = _ref.firstName,
37141
+ lastName = _ref.lastName;
37087
37142
  React.useEffect(function () {
37088
37143
  if (formType === CREATE_CLIENT_ADMIN) {
37089
37144
  actions.fields.client.addValidator(required());
37090
37145
  }
37146
+
37147
+ if (formType !== PROFILE) {
37148
+ actions.fields.email.addValidator(required());
37149
+ actions.fields.role.addValidator(required());
37150
+ }
37091
37151
  }, []);
37092
37152
 
37093
37153
  if (clearOnDismount) {
@@ -37111,8 +37171,30 @@ var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
37111
37171
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
37112
37172
  variant: variant,
37113
37173
  role: "form",
37114
- "aria-label": "user-info-form"
37115
- }, /*#__PURE__*/React__default.createElement(Stack, null, formType === CREATE_CLIENT_ADMIN && /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37174
+ "aria-label": "user-info-form",
37175
+ extraStyles: "padding: 0;"
37176
+ }, formType === PROFILE && /*#__PURE__*/React__default.createElement(Box, {
37177
+ padding: "1.5rem"
37178
+ }, /*#__PURE__*/React__default.createElement(Cluster, {
37179
+ justify: "flex-start",
37180
+ align: "center"
37181
+ }, /*#__PURE__*/React__default.createElement(Box, {
37182
+ padding: "1.25rem",
37183
+ borderRadius: "50%",
37184
+ background: "#CACED8"
37185
+ }, /*#__PURE__*/React__default.createElement(Heading$1, {
37186
+ variant: "h4",
37187
+ weight: "700"
37188
+ }, firstName.charAt(0).toUpperCase(), lastName.charAt(0).toUpperCase())), /*#__PURE__*/React__default.createElement(Text$1, {
37189
+ variant: "p",
37190
+ weight: "700",
37191
+ extraStyles: "padding-left: 1rem;"
37192
+ }, firstName, " ", lastName))), formType === CREATE_CLIENT_ADMIN && /*#__PURE__*/React__default.createElement(Box, {
37193
+ padding: "1.5rem 1.5rem 0.5rem",
37194
+ borderColor: GHOST_GREY,
37195
+ borderSize: "1px",
37196
+ borderWidthOverride: "0 0 1px 0"
37197
+ }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37116
37198
  variant: "h6",
37117
37199
  weight: "700",
37118
37200
  margin: "0 0 1rem"
@@ -37132,7 +37214,12 @@ var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
37132
37214
  onKeyDown: function onKeyDown(e) {
37133
37215
  return e.key === "Enter" && handleSubmit(e);
37134
37216
  }
37135
- })), /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37217
+ }))), /*#__PURE__*/React__default.createElement(Box, {
37218
+ padding: formType === PROFILE ? "1.5rem 1.5rem 0" : "1.5rem 1.5rem 0.5rem",
37219
+ borderColor: GHOST_GREY,
37220
+ borderSize: "1px",
37221
+ borderWidthOverride: formType === PROFILE ? "1px 0 0" : "0 0 1px 0"
37222
+ }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37136
37223
  variant: "h6",
37137
37224
  weight: "700",
37138
37225
  margin: "0 0 1rem"
@@ -37163,13 +37250,30 @@ var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
37163
37250
  onKeyDown: function onKeyDown(e) {
37164
37251
  return e.key === "Enter" && handleSubmit(e);
37165
37252
  },
37166
- disabled: disabled || emailDisabled
37167
- })), /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37253
+ disabled: emailDisabled
37254
+ }), formType === PROFILE && !isOktaUser && /*#__PURE__*/React__default.createElement(FormInput$1, {
37255
+ labelTextWhenNoError: "Password",
37256
+ errorMessages: {},
37257
+ field: {
37258
+ rawValue: "•••••••••••••"
37259
+ },
37260
+ disabled: true,
37261
+ decorator: /*#__PURE__*/React__default.createElement(Text$1, {
37262
+ variant: "pS",
37263
+ color: "#15749D",
37264
+ onClick: openChangePasswordForm,
37265
+ extraStyles: "cursor: pointer;"
37266
+ }, "Change Password")
37267
+ }))), /*#__PURE__*/React__default.createElement(Box, {
37268
+ padding: "1.5rem"
37269
+ }, formType !== PROFILE && /*#__PURE__*/React__default.createElement(Box, {
37270
+ padding: "0 0 0.5rem"
37271
+ }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37168
37272
  variant: "h6",
37169
37273
  weight: "700",
37170
37274
  margin: "0 0 1rem"
37171
- }, "Dashboard Settings"), /*#__PURE__*/React__default.createElement(FormSelect$1, {
37172
- labelTextWhenNoError: "Role",
37275
+ }, "User Settings"), /*#__PURE__*/React__default.createElement(FormSelect$1, {
37276
+ labelTextWhenNoError: "User Role",
37173
37277
  errorMessages: roleErrorMessages,
37174
37278
  options: roleOptions.map(function (role) {
37175
37279
  return {
@@ -37184,12 +37288,12 @@ var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
37184
37288
  onKeyDown: function onKeyDown(e) {
37185
37289
  return e.key === "Enter" && handleSubmit(e);
37186
37290
  },
37187
- disabled: disabled || roleDisabled
37188
- })), formType !== CREATE_CLIENT_ADMIN && /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Heading$1, {
37189
- variant: "h6",
37190
- weight: "700",
37191
- margin: "0 0 1rem"
37192
- }, "Select Agencies"), /*#__PURE__*/React__default.createElement(SearchableSelect$1, {
37291
+ disabled: roleDisabled
37292
+ }))), (formType === ADD || formType === EDIT) && /*#__PURE__*/React__default.createElement(Box, {
37293
+ padding: "0.5rem 0 1.5rem"
37294
+ }, /*#__PURE__*/React__default.createElement(FormInputColumn, null, /*#__PURE__*/React__default.createElement(Text$1, {
37295
+ variant: "p"
37296
+ }, "Select which agencies the user can view"), /*#__PURE__*/React__default.createElement(SearchableSelect$1, {
37193
37297
  actions: actions,
37194
37298
  fields: fields,
37195
37299
  items: allAgencyOptions,
@@ -37197,8 +37301,32 @@ var InternalUserInfoForm = function InternalUserInfoForm(_ref) {
37197
37301
  allSelected: allSelected,
37198
37302
  toggleSelectAllItems: toggleSelectAllAgencies,
37199
37303
  selectItem: selectAgency,
37200
- disabled: disabled
37201
- }))));
37304
+ disabled: selectionDisabled
37305
+ }))), /*#__PURE__*/React__default.createElement(Box, {
37306
+ padding: "0"
37307
+ }, /*#__PURE__*/React__default.createElement(Stack, {
37308
+ childGap: "1rem",
37309
+ direction: "row",
37310
+ justify: "flex-end"
37311
+ }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
37312
+ text: "Cancel",
37313
+ action: function action() {
37314
+ if (formType !== CREATE_CLIENT_ADMIN) {
37315
+ toggleSelectAllAgencies(false);
37316
+ }
37317
+
37318
+ closeForm();
37319
+ },
37320
+ variant: "secondary",
37321
+ dataQa: "Cancel",
37322
+ extraStyles: "margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;"
37323
+ }), /*#__PURE__*/React__default.createElement(ButtonWithAction, {
37324
+ text: "Save",
37325
+ action: handleSubmit,
37326
+ variant: "primary",
37327
+ dataQa: "Save",
37328
+ extraStyles: "margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;"
37329
+ })))));
37202
37330
  };
37203
37331
 
37204
37332
  var formConfig$5 = {
@@ -37212,10 +37340,10 @@ var formConfig$5 = {
37212
37340
  validators: [required()]
37213
37341
  },
37214
37342
  email: {
37215
- validators: [required(), isProbablyEmail()]
37343
+ validators: [isProbablyEmail()]
37216
37344
  },
37217
37345
  role: {
37218
- validators: [required()]
37346
+ validators: []
37219
37347
  },
37220
37348
  searchTerm: {
37221
37349
  validators: []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "4.3.3",
3
+ "version": "4.3.6",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -92,6 +92,7 @@ const Checkbox = ({
92
92
  themeValues,
93
93
  hidden = false,
94
94
  error = false,
95
+ extraStyles,
95
96
  textExtraStyles
96
97
  }) => {
97
98
  const [focused, setFocused] = useState(false);
@@ -111,7 +112,7 @@ const Checkbox = ({
111
112
  onKeyDown={e => handleClick(e, onChange)}
112
113
  hiddenStyles={hidden}
113
114
  background={themeValues.backgroundColor}
114
- extraStyles="outline: none;"
115
+ extraStyles={`outline: none; ${extraStyles}`}
115
116
  >
116
117
  <CheckboxLabelContainer>
117
118
  <CheckboxContainer data-qa="Checkbox">
@@ -23,15 +23,15 @@ import {
23
23
  const PasswordRequirements = ({ password, isMobile }) => {
24
24
  const iconMap = {
25
25
  [INPUT_STATE_NEUTRAL]: {
26
- icon: <IconNeutral margin="0.125rem 0.5rem 0 0" />,
26
+ icon: <IconNeutral margin="0 0.5rem 0 0" />,
27
27
  color: MINESHAFT_GREY
28
28
  },
29
29
  [INPUT_STATE_INVALID]: {
30
- icon: <IconInvalid margin="0.125rem 0.5rem 0 0" />,
30
+ icon: <IconInvalid margin="0 0.5rem 0 0" />,
31
31
  color: RAZZMATAZZ_RED
32
32
  },
33
33
  [INPUT_STATE_VALID]: {
34
- icon: <IconValid margin="0.125rem 0.5rem 0 0" />,
34
+ icon: <IconValid margin="0 0.5rem 0 0" />,
35
35
  color: FOREST_GREEN
36
36
  }
37
37
  };
@@ -83,7 +83,7 @@ const PasswordRequirements = ({ password, isMobile }) => {
83
83
  </Box>
84
84
  <Box padding="0">
85
85
  <Sidebar onRight childGap="0rem">
86
- <Box padding="0rem">
86
+ <Box padding="0.15rem 0 0 0">
87
87
  <Cluster justify="flex-start" align="center">
88
88
  <Stack fullHeight childGap="0.25rem">
89
89
  <Paragraph
@@ -50,7 +50,7 @@ const SearchableSelect = ({
50
50
  errorMessages={{}}
51
51
  field={fields.searchTerm}
52
52
  fieldActions={actions.fields.searchTerm}
53
- placeholder="Search departments"
53
+ placeholder="Search agencies"
54
54
  disabled={disabled}
55
55
  />
56
56
  <Box
@@ -67,6 +67,7 @@ const SearchableSelect = ({
67
67
  onChange={() => handleSelect(value)}
68
68
  textExtraStyles={`margin: 0;`}
69
69
  disabled={disabled}
70
+ extraStyles={`margin: 0 0.5rem;`}
70
71
  />
71
72
  ))}
72
73
  </Stack>
@@ -13,9 +13,13 @@ import {
13
13
  FormContainer,
14
14
  FormInputColumn
15
15
  } from "../../atoms/form-layouts";
16
- import { Box, Cluster } from "../../atoms/layouts";
16
+ import { Box, Cluster, Stack } from "../../atoms/layouts";
17
+ import ButtonWithAction from "../../atoms/button-with-action";
18
+ import Heading from "../../atoms/heading";
19
+ import Text from "../../atoms/text";
17
20
  import PasswordRequirements from "../../atoms/password-requirements";
18
21
  import { noop } from "../../../util/general";
22
+ import { GHOST_GREY } from "../../../constants/colors";
19
23
 
20
24
  const ChangePasswordForm = ({
21
25
  clearOnDismount,
@@ -23,7 +27,11 @@ const ChangePasswordForm = ({
23
27
  actions,
24
28
  handleSubmit = noop,
25
29
  showErrors,
26
- isMobile
30
+ isMobile,
31
+ revenueManagement,
32
+ closeForm,
33
+ firstName,
34
+ lastName
27
35
  }) => {
28
36
  if (clearOnDismount) {
29
37
  useEffect(() => () => actions.form.clear(), []);
@@ -48,43 +56,89 @@ const ChangePasswordForm = ({
48
56
  };
49
57
 
50
58
  return (
51
- <FormContainer role="form" aria-label="Change password">
52
- <FormInputColumn>
53
- <FormInput
54
- labelTextWhenNoError="Current password"
55
- errorMessages={currentPasswordErrorMessages}
56
- field={fields.currentPassword}
57
- fieldActions={actions.fields.currentPassword}
58
- showErrors={showErrors}
59
- onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
60
- type="password"
61
- />
62
- <FormInput
63
- labelTextWhenNoError="New password"
64
- errorMessages={newPasswordErrorMessages}
65
- field={fields.newPassword}
66
- fieldActions={actions.fields.newPassword}
67
- showErrors={showErrors}
68
- onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
69
- type="password"
70
- />
71
- <FormInput
72
- labelTextWhenNoError="Confirm password"
73
- errorMessages={confirmNewPasswordErrorMessages}
74
- field={fields.confirmNewPassword}
75
- fieldActions={actions.fields.confirmNewPassword}
76
- showErrors={showErrors}
77
- onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
78
- type="password"
79
- />
80
- </FormInputColumn>
81
- <Box padding={isMobile ? "1rem 0 0" : "1.5rem 0 0"}>
82
- <Cluster justify="center" align="center">
83
- <PasswordRequirements
84
- password={fields.newPassword}
85
- isMobile={isMobile}
59
+ <FormContainer
60
+ role="form"
61
+ aria-label="Change password"
62
+ extraStyles={`padding: 0;`}
63
+ >
64
+ {revenueManagement && (
65
+ <Box
66
+ padding="1.5rem"
67
+ borderColor={GHOST_GREY}
68
+ borderSize="1px"
69
+ borderWidthOverride={"0 0 1px 0"}
70
+ >
71
+ <Cluster justify="flex-start" align="center">
72
+ <Box padding="1.25rem" borderRadius="50%" background="#CACED8">
73
+ <Heading variant="h4" weight="700">
74
+ {firstName.charAt(0).toUpperCase()}
75
+ {lastName.charAt(0).toUpperCase()}
76
+ </Heading>
77
+ </Box>
78
+ <Text variant="p" weight="700" extraStyles={`padding-left: 1rem;`}>
79
+ {firstName} {lastName}
80
+ </Text>
81
+ </Cluster>
82
+ </Box>
83
+ )}
84
+ <Box padding="1.5rem">
85
+ <FormInputColumn>
86
+ <FormInput
87
+ labelTextWhenNoError="Current password"
88
+ errorMessages={currentPasswordErrorMessages}
89
+ field={fields.currentPassword}
90
+ fieldActions={actions.fields.currentPassword}
91
+ showErrors={showErrors}
92
+ onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
93
+ type="password"
86
94
  />
87
- </Cluster>
95
+ <FormInput
96
+ labelTextWhenNoError="New password"
97
+ errorMessages={newPasswordErrorMessages}
98
+ field={fields.newPassword}
99
+ fieldActions={actions.fields.newPassword}
100
+ showErrors={showErrors}
101
+ onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
102
+ type="password"
103
+ />
104
+ <FormInput
105
+ labelTextWhenNoError="Confirm password"
106
+ errorMessages={confirmNewPasswordErrorMessages}
107
+ field={fields.confirmNewPassword}
108
+ fieldActions={actions.fields.confirmNewPassword}
109
+ showErrors={showErrors}
110
+ onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
111
+ type="password"
112
+ />
113
+ </FormInputColumn>
114
+ <Box padding={isMobile ? "1rem 0 0" : "1.5rem 0 0"}>
115
+ <Cluster justify="center" align="center">
116
+ <PasswordRequirements
117
+ password={fields.newPassword}
118
+ isMobile={isMobile}
119
+ />
120
+ </Cluster>
121
+ </Box>
122
+ {revenueManagement && (
123
+ <Box padding="1.5rem 0 0">
124
+ <Stack childGap="1rem" direction="row" justify="flex-end">
125
+ <ButtonWithAction
126
+ text="Cancel"
127
+ action={closeForm}
128
+ variant={"secondary"}
129
+ dataQa="Cancel"
130
+ extraStyles={`margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;`}
131
+ />
132
+ <ButtonWithAction
133
+ text="Save"
134
+ action={handleSubmit}
135
+ variant="primary"
136
+ dataQa="Save"
137
+ extraStyles={`margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;`}
138
+ />
139
+ </Stack>
140
+ </Box>
141
+ )}
88
142
  </Box>
89
143
  </FormContainer>
90
144
  );
@@ -1,7 +1,9 @@
1
1
  import React, { useEffect } from "react";
2
2
  import { required } from "redux-freeform";
3
- import { Stack } from "../../atoms/layouts";
3
+ import { Stack, Box, Cluster } from "../../atoms/layouts";
4
+ import ButtonWithAction from "../../atoms/button-with-action";
4
5
  import Heading from "../../atoms/heading";
6
+ import Text from "../../atoms/text";
5
7
  import { noop } from "../../../util/general";
6
8
  import {
7
9
  FormInput,
@@ -10,6 +12,7 @@ import {
10
12
  } from "../../atoms/form-layouts";
11
13
  import FormSelect from "../../atoms/form-select";
12
14
  import SearchableSelect from "../../atoms/searchable-select";
15
+ import { GHOST_GREY } from "../../../constants/colors";
13
16
 
14
17
  const RESEARCHER = "RESEARCHER";
15
18
  const AGENCY_ADMIN = "AGENCY_ADMIN";
@@ -17,6 +20,9 @@ const CLIENT_ADMIN = "CLIENT_ADMIN";
17
20
  const SUPERVISOR = "SUPERVISOR";
18
21
  const CB_ADMIN = "CITYBASE_ADMIN";
19
22
  const CREATE_CLIENT_ADMIN = "CREATE_CLIENT_ADMIN";
23
+ const PROFILE = "PROFILE";
24
+ const ADD = "ADD";
25
+ const EDIT = "EDIT";
20
26
 
21
27
  const roleDescriptions = {
22
28
  [RESEARCHER]: "Researcher",
@@ -33,22 +39,31 @@ const InternalUserInfoForm = ({
33
39
  clearOnDismount,
34
40
  showErrors,
35
41
  handleSubmit = noop,
42
+ closeForm,
36
43
  allAgencyOptions,
37
44
  selectedAgencies,
38
45
  allSelected,
39
- toggleSelectAllAgencies,
46
+ toggleSelectAllAgencies = noop,
40
47
  selectAgency,
41
48
  roleOptions,
42
49
  clientOptions,
43
- disabled,
44
50
  emailDisabled,
45
51
  roleDisabled,
46
- formType
52
+ selectionDisabled,
53
+ formType,
54
+ isOktaUser,
55
+ openChangePasswordForm,
56
+ firstName,
57
+ lastName
47
58
  }) => {
48
59
  useEffect(() => {
49
60
  if (formType === CREATE_CLIENT_ADMIN) {
50
61
  actions.fields.client.addValidator(required());
51
62
  }
63
+ if (formType !== PROFILE) {
64
+ actions.fields.email.addValidator(required());
65
+ actions.fields.role.addValidator(required());
66
+ }
52
67
  }, []);
53
68
  if (clearOnDismount) {
54
69
  useEffect(() => () => actions.form.clear(), []);
@@ -69,9 +84,34 @@ const InternalUserInfoForm = ({
69
84
  [required.error]: "Role is required"
70
85
  };
71
86
  return (
72
- <FormContainer variant={variant} role="form" aria-label="user-info-form">
73
- <Stack>
74
- {formType === CREATE_CLIENT_ADMIN && (
87
+ <FormContainer
88
+ variant={variant}
89
+ role="form"
90
+ aria-label="user-info-form"
91
+ extraStyles={`padding: 0;`}
92
+ >
93
+ {formType === PROFILE && (
94
+ <Box padding="1.5rem">
95
+ <Cluster justify="flex-start" align="center">
96
+ <Box padding="1.25rem" borderRadius="50%" background="#CACED8">
97
+ <Heading variant="h4" weight="700">
98
+ {firstName.charAt(0).toUpperCase()}
99
+ {lastName.charAt(0).toUpperCase()}
100
+ </Heading>
101
+ </Box>
102
+ <Text variant="p" weight="700" extraStyles={`padding-left: 1rem;`}>
103
+ {firstName} {lastName}
104
+ </Text>
105
+ </Cluster>
106
+ </Box>
107
+ )}
108
+ {formType === CREATE_CLIENT_ADMIN && (
109
+ <Box
110
+ padding="1.5rem 1.5rem 0.5rem"
111
+ borderColor={GHOST_GREY}
112
+ borderSize="1px"
113
+ borderWidthOverride="0 0 1px 0"
114
+ >
75
115
  <FormInputColumn>
76
116
  <Heading variant="h6" weight="700" margin="0 0 1rem">
77
117
  Select Client
@@ -90,7 +130,16 @@ const InternalUserInfoForm = ({
90
130
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
91
131
  />
92
132
  </FormInputColumn>
93
- )}
133
+ </Box>
134
+ )}
135
+ <Box
136
+ padding={
137
+ formType === PROFILE ? "1.5rem 1.5rem 0" : "1.5rem 1.5rem 0.5rem"
138
+ }
139
+ borderColor={GHOST_GREY}
140
+ borderSize="1px"
141
+ borderWidthOverride={formType === PROFILE ? "1px 0 0" : "0 0 1px 0"}
142
+ >
94
143
  <FormInputColumn>
95
144
  <Heading variant="h6" weight="700" margin="0 0 1rem">
96
145
  Personal Information
@@ -118,46 +167,93 @@ const InternalUserInfoForm = ({
118
167
  fieldActions={actions.fields.email}
119
168
  showErrors={showErrors}
120
169
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
121
- disabled={disabled || emailDisabled}
122
- />
123
- </FormInputColumn>
124
- <FormInputColumn>
125
- <Heading variant="h6" weight="700" margin="0 0 1rem">
126
- Dashboard Settings
127
- </Heading>
128
- <FormSelect
129
- labelTextWhenNoError="Role"
130
- errorMessages={roleErrorMessages}
131
- options={roleOptions.map(role => ({
132
- text: roleDescriptions[role],
133
- value: role,
134
- id: role
135
- }))}
136
- field={fields.role}
137
- fieldActions={actions.fields.role}
138
- showErrors={showErrors}
139
- onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
140
- disabled={disabled || roleDisabled}
170
+ disabled={emailDisabled}
141
171
  />
142
- </FormInputColumn>
143
- {formType !== CREATE_CLIENT_ADMIN && (
144
- <FormInputColumn>
145
- <Heading variant="h6" weight="700" margin="0 0 1rem">
146
- Select Agencies
147
- </Heading>
148
- <SearchableSelect
149
- actions={actions}
150
- fields={fields}
151
- items={allAgencyOptions}
152
- selectedItems={selectedAgencies}
153
- allSelected={allSelected}
154
- toggleSelectAllItems={toggleSelectAllAgencies}
155
- selectItem={selectAgency}
156
- disabled={disabled}
172
+ {formType === PROFILE && !isOktaUser && (
173
+ <FormInput
174
+ labelTextWhenNoError="Password"
175
+ errorMessages={{}}
176
+ field={{ rawValue: "•••••••••••••" }}
177
+ disabled={true}
178
+ decorator={
179
+ <Text
180
+ variant="pS"
181
+ color={`#15749D`}
182
+ onClick={openChangePasswordForm}
183
+ extraStyles={`cursor: pointer;`}
184
+ >
185
+ Change Password
186
+ </Text>
187
+ }
157
188
  />
158
- </FormInputColumn>
189
+ )}
190
+ </FormInputColumn>
191
+ </Box>
192
+ <Box padding="1.5rem">
193
+ {formType !== PROFILE && (
194
+ <Box padding="0 0 0.5rem">
195
+ <FormInputColumn>
196
+ <Heading variant="h6" weight="700" margin="0 0 1rem">
197
+ User Settings
198
+ </Heading>
199
+ <FormSelect
200
+ labelTextWhenNoError="User Role"
201
+ errorMessages={roleErrorMessages}
202
+ options={roleOptions.map(role => ({
203
+ text: roleDescriptions[role],
204
+ value: role,
205
+ id: role
206
+ }))}
207
+ field={fields.role}
208
+ fieldActions={actions.fields.role}
209
+ showErrors={showErrors}
210
+ onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
211
+ disabled={roleDisabled}
212
+ />
213
+ </FormInputColumn>
214
+ </Box>
215
+ )}
216
+ {(formType === ADD || formType === EDIT) && (
217
+ <Box padding="0.5rem 0 1.5rem">
218
+ <FormInputColumn>
219
+ <Text variant="p">Select which agencies the user can view</Text>
220
+ <SearchableSelect
221
+ actions={actions}
222
+ fields={fields}
223
+ items={allAgencyOptions}
224
+ selectedItems={selectedAgencies}
225
+ allSelected={allSelected}
226
+ toggleSelectAllItems={toggleSelectAllAgencies}
227
+ selectItem={selectAgency}
228
+ disabled={selectionDisabled}
229
+ />
230
+ </FormInputColumn>
231
+ </Box>
159
232
  )}
160
- </Stack>
233
+ <Box padding="0">
234
+ <Stack childGap="1rem" direction="row" justify="flex-end">
235
+ <ButtonWithAction
236
+ text="Cancel"
237
+ action={() => {
238
+ if (formType !== CREATE_CLIENT_ADMIN) {
239
+ toggleSelectAllAgencies(false);
240
+ }
241
+ closeForm();
242
+ }}
243
+ variant={"secondary"}
244
+ dataQa="Cancel"
245
+ extraStyles={`margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;`}
246
+ />
247
+ <ButtonWithAction
248
+ text="Save"
249
+ action={handleSubmit}
250
+ variant="primary"
251
+ dataQa="Save"
252
+ extraStyles={`margin: 0rem; padding: 0.75rem 1.5rem; border-radius: 4px;`}
253
+ />
254
+ </Stack>
255
+ </Box>
256
+ </Box>
161
257
  </FormContainer>
162
258
  );
163
259
  };
@@ -11,10 +11,10 @@ const formConfig = {
11
11
  validators: [required()]
12
12
  },
13
13
  email: {
14
- validators: [required(), isProbablyEmail()]
14
+ validators: [isProbablyEmail()]
15
15
  },
16
16
  role: {
17
- validators: [required()]
17
+ validators: []
18
18
  },
19
19
  searchTerm: {
20
20
  validators: []