@jsb188/app-settings-web 1.1.11 → 1.1.12
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 +9 -5
- package/src/assets.d.ts +1 -0
- package/src/main.ts +3 -2
- package/src/modules/AppSettingsLayout.tsx +331 -0
- package/src/modules/AppSettingsTable.tsx +70 -0
- package/src/modules/ChangeCredentialsLayout.tsx +347 -0
- package/src/ui/AppSettingsTableUI.tsx +124 -0
- package/src/ui/AppSettingsUI.tsx +223 -0
- package/tsconfig.json +13 -0
- package/src/AppSettingsLayout.tsx +0 -213
- package/src/ChangeCredentialsLayout.tsx +0 -350
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { getErrorMessageContent } from '@jsb188/react-web/modules/layout/MainLayout';
|
|
2
|
-
import { Icon } from '@jsb188/react-web/svgs/Icon';
|
|
3
|
-
import Markdown from '@jsb188/react-web/ui/Markdown';
|
|
4
|
-
import {
|
|
5
|
-
ModalContentContainer,
|
|
6
|
-
ModalFloatingSaveButton,
|
|
7
|
-
ModalSideNav,
|
|
8
|
-
ModalSideNavIface,
|
|
9
|
-
} from '@jsb188/react-web/ui/ModalUI';
|
|
10
|
-
import { TableListMockClient } from '@jsb188/react-web/ui/TableListUI';
|
|
11
|
-
import type { ModalHandlerProps, OpenModalPopUpFn } from '@jsb188/react/states';
|
|
12
|
-
import { useClosePopOver, useKeyDown } from '@jsb188/react/states';
|
|
13
|
-
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Types
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
interface ControllerState {
|
|
20
|
-
switchCase: string;
|
|
21
|
-
hasChanges: boolean;
|
|
22
|
-
saving: boolean;
|
|
23
|
-
saveCounter: number;
|
|
24
|
-
resetCounter: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AppSettingsSwitchCaseProps extends ControllerState {
|
|
28
|
-
onSave: () => void;
|
|
29
|
-
onChangeDiff: (hasChanges?: boolean, saving?: boolean) => void;
|
|
30
|
-
openModalPopUp: OpenModalPopUpFn;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface AppSettingsTableContentProps {
|
|
34
|
-
notReady?: boolean;
|
|
35
|
-
gridLayoutStyle: string;
|
|
36
|
-
children?: ReactNode;
|
|
37
|
-
error?: any;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* App settings table content helper with a built-in loading table state
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
export function AppSettingsTableContent(p: AppSettingsTableContentProps) {
|
|
45
|
-
const { notReady, gridLayoutStyle, children, error } = p;
|
|
46
|
-
|
|
47
|
-
if (notReady) {
|
|
48
|
-
if (error) {
|
|
49
|
-
const errObj = getErrorMessageContent(error);
|
|
50
|
-
return (
|
|
51
|
-
<div className="h_item gap_df">
|
|
52
|
-
<div className="bd_2 bd_lt w_80 h_80 v_center r_df ic_lg ft_md rel pattern_texture medium_bf of">
|
|
53
|
-
<span className="rel">
|
|
54
|
-
<Icon
|
|
55
|
-
tryColor
|
|
56
|
-
name={errObj.titleIconName}
|
|
57
|
-
backupName="alert-circle"
|
|
58
|
-
/>
|
|
59
|
-
</span>
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
<div className="lh_2">
|
|
63
|
-
<div className="ft_medium ft_df mt_1 mb_4">{errObj.title}</div>
|
|
64
|
-
<Markdown as="p" preset="article" className="ft_sm cl_lt">
|
|
65
|
-
{errObj.message}
|
|
66
|
-
</Markdown>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<TableListMockClient
|
|
74
|
-
removeHorizontalPadding
|
|
75
|
-
removeAvatarElement
|
|
76
|
-
isSmallerRows
|
|
77
|
-
removeBorderLine
|
|
78
|
-
gridLayoutStyle={gridLayoutStyle}
|
|
79
|
-
/>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return children;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* App settings layout
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
export function AppSettingsLayout(
|
|
91
|
-
p: ModalHandlerProps & {
|
|
92
|
-
switchCase: string;
|
|
93
|
-
SwitchCaseComponent: React.ComponentType<AppSettingsSwitchCaseProps>;
|
|
94
|
-
options: ModalSideNavIface[][];
|
|
95
|
-
onClickNavItem?: (value: string) => boolean | void; // If "false" is returned, it denies the switchCase change
|
|
96
|
-
},
|
|
97
|
-
) {
|
|
98
|
-
const { SwitchCaseComponent, openModalPopUp, options } = p;
|
|
99
|
-
const [keyDown, setKeyDown] = useKeyDown();
|
|
100
|
-
const closePopOver = useClosePopOver();
|
|
101
|
-
const scrollAreaRef = useRef<HTMLDivElement | null>(null);
|
|
102
|
-
|
|
103
|
-
// const setKeyDown = (value: any) => {
|
|
104
|
-
// dispatchApp({
|
|
105
|
-
// pressed: null,
|
|
106
|
-
// alert: keyDown.alert,
|
|
107
|
-
// modal: keyDown.modal,
|
|
108
|
-
// ...value,
|
|
109
|
-
// });
|
|
110
|
-
// };
|
|
111
|
-
|
|
112
|
-
const [controller, setController] = useState<ControllerState>({
|
|
113
|
-
switchCase: p.switchCase,
|
|
114
|
-
hasChanges: false,
|
|
115
|
-
saving: false,
|
|
116
|
-
saveCounter: 0,
|
|
117
|
-
resetCounter: 0,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const onClickNavItem = (value: any) => {
|
|
121
|
-
const handlerValue = p.onClickNavItem?.(value);
|
|
122
|
-
if (handlerValue !== false) {
|
|
123
|
-
setController({
|
|
124
|
-
switchCase: value,
|
|
125
|
-
hasChanges: false,
|
|
126
|
-
saving: false,
|
|
127
|
-
saveCounter: 0,
|
|
128
|
-
resetCounter: 0,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const onSave = () => {
|
|
134
|
-
setController({
|
|
135
|
-
...controller,
|
|
136
|
-
saveCounter: controller.saveCounter + 1,
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const onReset = () => {
|
|
141
|
-
setController({
|
|
142
|
-
...controller,
|
|
143
|
-
resetCounter: controller.resetCounter + 1,
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const onChangeDiff = (hasChanges?: boolean, saving?: boolean) => {
|
|
148
|
-
setController({
|
|
149
|
-
...controller,
|
|
150
|
-
hasChanges:
|
|
151
|
-
typeof hasChanges === 'boolean' ? hasChanges : controller.hasChanges,
|
|
152
|
-
saving: typeof saving === 'boolean' ? saving : controller.saving,
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
if (!keyDown.alert && keyDown.pressed === 's') {
|
|
158
|
-
setKeyDown({
|
|
159
|
-
pressed: null,
|
|
160
|
-
});
|
|
161
|
-
onSave();
|
|
162
|
-
}
|
|
163
|
-
}, [keyDown.pressed]);
|
|
164
|
-
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
// Listen to scroll events inside scrollAreaRef
|
|
167
|
-
|
|
168
|
-
const scrollArea = scrollAreaRef.current;
|
|
169
|
-
if (!scrollArea) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const onScroll = () => {
|
|
174
|
-
// Close pop over on scroll
|
|
175
|
-
closePopOver();
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
scrollArea.addEventListener('scroll', onScroll);
|
|
179
|
-
|
|
180
|
-
return () => {
|
|
181
|
-
scrollArea.removeEventListener('scroll', onScroll);
|
|
182
|
-
};
|
|
183
|
-
}, [closePopOver]);
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<div className="cw md h_top f rel of">
|
|
187
|
-
<ModalSideNav
|
|
188
|
-
selectedValue={controller.switchCase}
|
|
189
|
-
options={options}
|
|
190
|
-
onClickItem={onClickNavItem}
|
|
191
|
-
/>
|
|
192
|
-
|
|
193
|
-
<ModalContentContainer ref={scrollAreaRef} addFooterPadding addYOverflow>
|
|
194
|
-
<div className="f py_md px_lg">
|
|
195
|
-
<SwitchCaseComponent
|
|
196
|
-
key={`switch_case_${controller.resetCounter}`}
|
|
197
|
-
onSave={onSave}
|
|
198
|
-
onChangeDiff={onChangeDiff}
|
|
199
|
-
openModalPopUp={openModalPopUp}
|
|
200
|
-
{...controller}
|
|
201
|
-
/>
|
|
202
|
-
</div>
|
|
203
|
-
</ModalContentContainer>
|
|
204
|
-
|
|
205
|
-
<ModalFloatingSaveButton
|
|
206
|
-
hasChanges={controller.hasChanges}
|
|
207
|
-
saving={controller.saving}
|
|
208
|
-
onSave={onSave}
|
|
209
|
-
onReset={onReset}
|
|
210
|
-
/>
|
|
211
|
-
</div>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
-
import { useConfirmPassword } from '@jsb188/graphql/hooks/use-auth-mtn';
|
|
3
|
-
import {
|
|
4
|
-
FormOptions,
|
|
5
|
-
Input,
|
|
6
|
-
SMSCodeInput,
|
|
7
|
-
} from '@jsb188/react-web/modules/Form';
|
|
8
|
-
import { AlertPopUp, ModalErrorMessage } from '@jsb188/react-web/ui/ModalUI';
|
|
9
|
-
import type { ModalPopUpComponentProps } from '@jsb188/react/states';
|
|
10
|
-
import { useState } from 'react';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Types
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
export interface ConfirmPasswordProps extends ModalPopUpComponentProps {
|
|
17
|
-
confirmPasswordTitle?: string;
|
|
18
|
-
confirmPasswordMessage?: string;
|
|
19
|
-
onPasswordVerified?: (password: string) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ChangeCredentialsFinishedProps
|
|
23
|
-
extends ModalPopUpComponentProps {
|
|
24
|
-
finishedIconName?: string;
|
|
25
|
-
finishedTitle?: string;
|
|
26
|
-
finishedMessage?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ChangeCredentialsProps extends ConfirmPasswordProps {
|
|
30
|
-
iconName: string;
|
|
31
|
-
skipPassword?: boolean;
|
|
32
|
-
title: string;
|
|
33
|
-
message: string;
|
|
34
|
-
|
|
35
|
-
finishedIconName?: string;
|
|
36
|
-
finishedTitle?: string;
|
|
37
|
-
finishedMessage?: string;
|
|
38
|
-
|
|
39
|
-
verifyIconName?: string;
|
|
40
|
-
verifyTitle?: string;
|
|
41
|
-
verifyMessage?: string;
|
|
42
|
-
|
|
43
|
-
confirmText?: string;
|
|
44
|
-
confirmSMSCodeText?: string;
|
|
45
|
-
status:
|
|
46
|
-
| 'WAITING_FOR_INPUT'
|
|
47
|
-
| 'WAITING_FOR_VERIFICATION'
|
|
48
|
-
| 'WAITING_FOR_SMS_CODE'
|
|
49
|
-
| 'FINISHED';
|
|
50
|
-
onSubmit: (values: string[], confirmedPassword?: string) => void;
|
|
51
|
-
onSubmitSMSCode?: (
|
|
52
|
-
smsCode: string,
|
|
53
|
-
values: string[],
|
|
54
|
-
confirmedPassword?: string,
|
|
55
|
-
) => void;
|
|
56
|
-
|
|
57
|
-
loading?: boolean;
|
|
58
|
-
error: any;
|
|
59
|
-
resetErrors: () => void;
|
|
60
|
-
inputs: (
|
|
61
|
-
| {
|
|
62
|
-
__type: 'TEXT_INPUT';
|
|
63
|
-
type?: 'text' | 'password';
|
|
64
|
-
label: string;
|
|
65
|
-
placeholder?: string;
|
|
66
|
-
}
|
|
67
|
-
| {
|
|
68
|
-
__type: 'OPTIONS_LIST';
|
|
69
|
-
label: string;
|
|
70
|
-
defaultValue?: string;
|
|
71
|
-
options: {
|
|
72
|
-
text: string;
|
|
73
|
-
value: string;
|
|
74
|
-
disabled?: boolean;
|
|
75
|
-
}[];
|
|
76
|
-
}
|
|
77
|
-
)[];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Confirm password before changinge sensitive account settings
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
function ConfirmPasswordForm(
|
|
85
|
-
p: ConfirmPasswordProps & {
|
|
86
|
-
setPasswordVerified: (verified: boolean) => void;
|
|
87
|
-
},
|
|
88
|
-
) {
|
|
89
|
-
const {
|
|
90
|
-
setPasswordVerified,
|
|
91
|
-
onCloseModal,
|
|
92
|
-
confirmPasswordTitle,
|
|
93
|
-
confirmPasswordMessage,
|
|
94
|
-
onPasswordVerified,
|
|
95
|
-
} = p;
|
|
96
|
-
const [password, setPassword] = useState('');
|
|
97
|
-
|
|
98
|
-
const { confirmPassword, error, resetErrors, saving } = useConfirmPassword({
|
|
99
|
-
onCompleted: (data: any) => {
|
|
100
|
-
if (data.confirmPassword) {
|
|
101
|
-
onPasswordVerified?.(password);
|
|
102
|
-
setPasswordVerified(true);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
onError: () => {
|
|
106
|
-
setPassword('');
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const onConfirmPassword = () => {
|
|
111
|
-
confirmPassword({
|
|
112
|
-
variables: {
|
|
113
|
-
password,
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const onPressEnter = (e: React.KeyboardEvent) => {
|
|
119
|
-
if (e.key === 'Enter' && password) {
|
|
120
|
-
onConfirmPassword();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<AlertPopUp
|
|
126
|
-
loading={saving}
|
|
127
|
-
iconName="password-lock-2"
|
|
128
|
-
confirmText={i18n.t('form.authenticate')}
|
|
129
|
-
cancelText={i18n.t('form.cancel')}
|
|
130
|
-
onConfirm={onConfirmPassword}
|
|
131
|
-
onCancel={onCloseModal}
|
|
132
|
-
disabledConfirm={!password}
|
|
133
|
-
title={confirmPasswordTitle ?? i18n.t('account.enter_password')}
|
|
134
|
-
message={confirmPasswordMessage ?? i18n.t('account.enter_password_msg')}
|
|
135
|
-
>
|
|
136
|
-
{error && (
|
|
137
|
-
<div className="px_md mt_md -mb_df">
|
|
138
|
-
<ModalErrorMessage error={error} resetErrors={resetErrors} />
|
|
139
|
-
</div>
|
|
140
|
-
)}
|
|
141
|
-
|
|
142
|
-
<div className="mt_df mx_md">
|
|
143
|
-
<Input
|
|
144
|
-
type="password"
|
|
145
|
-
label={i18n.t('account.password')}
|
|
146
|
-
placeholder="••••"
|
|
147
|
-
value={password}
|
|
148
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
149
|
-
onKeyDown={onPressEnter}
|
|
150
|
-
autoFocus
|
|
151
|
-
/>
|
|
152
|
-
</div>
|
|
153
|
-
</AlertPopUp>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Change account settings that require confirmations (such as credentials)
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
export function ChangeCredentialsLayout(p: ChangeCredentialsProps) {
|
|
162
|
-
const {
|
|
163
|
-
iconName,
|
|
164
|
-
skipPassword,
|
|
165
|
-
title,
|
|
166
|
-
message,
|
|
167
|
-
confirmText,
|
|
168
|
-
confirmSMSCodeText,
|
|
169
|
-
loading,
|
|
170
|
-
error,
|
|
171
|
-
resetErrors,
|
|
172
|
-
inputs,
|
|
173
|
-
onSubmit,
|
|
174
|
-
onSubmitSMSCode,
|
|
175
|
-
status,
|
|
176
|
-
finishedIconName,
|
|
177
|
-
finishedTitle,
|
|
178
|
-
finishedMessage,
|
|
179
|
-
verifyIconName,
|
|
180
|
-
verifyTitle,
|
|
181
|
-
verifyMessage,
|
|
182
|
-
...rest
|
|
183
|
-
} = p;
|
|
184
|
-
const { onCloseModal } = rest;
|
|
185
|
-
const [passwordVerified, setPasswordVerified] = useState(false);
|
|
186
|
-
const [confirmedPassword, setConfirmedPassword] = useState('');
|
|
187
|
-
const [smsCode, setSMSCode] = useState('');
|
|
188
|
-
const [values, setValues] = useState(() =>
|
|
189
|
-
inputs.map((input) =>
|
|
190
|
-
input.__type === 'OPTIONS_LIST' ? input.defaultValue || '' : '',
|
|
191
|
-
),
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
switch (status) {
|
|
195
|
-
case 'FINISHED':
|
|
196
|
-
return (
|
|
197
|
-
<AlertPopUp
|
|
198
|
-
onCloseModal={onCloseModal}
|
|
199
|
-
iconName={finishedIconName || 'circle-check'}
|
|
200
|
-
onCancel={onCloseModal}
|
|
201
|
-
title={finishedTitle || i18n.t('form.success_')}
|
|
202
|
-
message={
|
|
203
|
-
finishedMessage || i18n.t('form.your_request_is_completed_msg')
|
|
204
|
-
}
|
|
205
|
-
/>
|
|
206
|
-
);
|
|
207
|
-
case 'WAITING_FOR_VERIFICATION':
|
|
208
|
-
return (
|
|
209
|
-
<AlertPopUp
|
|
210
|
-
onCloseModal={onCloseModal}
|
|
211
|
-
iconName={verifyIconName || iconName}
|
|
212
|
-
onCancel={onCloseModal}
|
|
213
|
-
title={verifyTitle || i18n.t('form.please_verify')}
|
|
214
|
-
message={
|
|
215
|
-
verifyMessage ||
|
|
216
|
-
i18n.t('form.request_will_complete_once_verified_msg')
|
|
217
|
-
}
|
|
218
|
-
/>
|
|
219
|
-
);
|
|
220
|
-
case 'WAITING_FOR_SMS_CODE': {
|
|
221
|
-
const hasSMSCode = !!smsCode.trim();
|
|
222
|
-
|
|
223
|
-
return (
|
|
224
|
-
<AlertPopUp
|
|
225
|
-
iconName={verifyIconName || iconName}
|
|
226
|
-
loading={loading}
|
|
227
|
-
onCloseModal={onCloseModal}
|
|
228
|
-
onCancel={onCloseModal}
|
|
229
|
-
doNotExitOnConfirm
|
|
230
|
-
onConfirm={() => {
|
|
231
|
-
onSubmitSMSCode?.(smsCode.trim(), values, confirmedPassword);
|
|
232
|
-
}}
|
|
233
|
-
title={verifyTitle || i18n.t('form.please_verify')}
|
|
234
|
-
message={
|
|
235
|
-
verifyMessage ||
|
|
236
|
-
i18n.t('form.request_will_complete_once_verified_msg')
|
|
237
|
-
}
|
|
238
|
-
confirmText={confirmSMSCodeText || i18n.t('form.ok')}
|
|
239
|
-
cancelText={i18n.t('form.cancel')}
|
|
240
|
-
disabledConfirm={!hasSMSCode}
|
|
241
|
-
>
|
|
242
|
-
{error && (
|
|
243
|
-
<div className="px_md mt_md -mb_df">
|
|
244
|
-
<ModalErrorMessage error={error} resetErrors={resetErrors} />
|
|
245
|
-
</div>
|
|
246
|
-
)}
|
|
247
|
-
|
|
248
|
-
<div className="mt_md mx_md">
|
|
249
|
-
<SMSCodeInput
|
|
250
|
-
saving={loading}
|
|
251
|
-
error={error}
|
|
252
|
-
onChangeCode={setSMSCode}
|
|
253
|
-
onSubmit={(smsCode) => {
|
|
254
|
-
onSubmitSMSCode?.(smsCode.trim(), values, confirmedPassword);
|
|
255
|
-
}}
|
|
256
|
-
/>
|
|
257
|
-
</div>
|
|
258
|
-
</AlertPopUp>
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
case 'WAITING_FOR_INPUT':
|
|
262
|
-
default:
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (!passwordVerified && !skipPassword) {
|
|
266
|
-
return (
|
|
267
|
-
<ConfirmPasswordForm
|
|
268
|
-
{...rest}
|
|
269
|
-
setPasswordVerified={setPasswordVerified}
|
|
270
|
-
onPasswordVerified={setConfirmedPassword}
|
|
271
|
-
/>
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const hasTwoInputs = inputs.length >= 2;
|
|
276
|
-
const hasValidInputs = !!(hasTwoInputs
|
|
277
|
-
? values[0]?.trim() && values[1]?.trim()
|
|
278
|
-
: values[0]?.trim());
|
|
279
|
-
|
|
280
|
-
const onPressEnter = (e: React.KeyboardEvent) => {
|
|
281
|
-
if (e.key === 'Enter' && hasValidInputs) {
|
|
282
|
-
onSubmit(values, confirmedPassword);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<AlertPopUp
|
|
288
|
-
iconName={iconName}
|
|
289
|
-
doNotExitOnConfirm
|
|
290
|
-
loading={loading}
|
|
291
|
-
onCloseModal={onCloseModal}
|
|
292
|
-
onConfirm={() => onSubmit(values, confirmedPassword)}
|
|
293
|
-
title={title}
|
|
294
|
-
message={message}
|
|
295
|
-
confirmText={confirmText}
|
|
296
|
-
cancelText={i18n.t('form.cancel')}
|
|
297
|
-
disabledConfirm={!hasValidInputs}
|
|
298
|
-
>
|
|
299
|
-
{error && (
|
|
300
|
-
<div className="px_md mt_md -mb_df">
|
|
301
|
-
<ModalErrorMessage error={error} resetErrors={resetErrors} />
|
|
302
|
-
</div>
|
|
303
|
-
)}
|
|
304
|
-
|
|
305
|
-
<div className="mt_df mx_md">
|
|
306
|
-
{inputs.map((obj, i) => {
|
|
307
|
-
switch (obj.__type) {
|
|
308
|
-
case 'OPTIONS_LIST':
|
|
309
|
-
return (
|
|
310
|
-
<FormOptions
|
|
311
|
-
key={i}
|
|
312
|
-
name={obj.label}
|
|
313
|
-
label={obj.label}
|
|
314
|
-
value={values[i]}
|
|
315
|
-
options={obj.options}
|
|
316
|
-
onChange={(
|
|
317
|
-
_e: React.MouseEvent,
|
|
318
|
-
_name: string,
|
|
319
|
-
value: string | number | null,
|
|
320
|
-
) => {
|
|
321
|
-
const newValues = [...values];
|
|
322
|
-
newValues[i] = value === null ? '' : String(value);
|
|
323
|
-
setValues(newValues);
|
|
324
|
-
}}
|
|
325
|
-
/>
|
|
326
|
-
);
|
|
327
|
-
case 'TEXT_INPUT':
|
|
328
|
-
default:
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return (
|
|
332
|
-
<Input
|
|
333
|
-
key={i}
|
|
334
|
-
type={obj.type || 'text'}
|
|
335
|
-
{...obj}
|
|
336
|
-
value={values[i]}
|
|
337
|
-
onChange={(e) => {
|
|
338
|
-
const newValues = [...values];
|
|
339
|
-
newValues[i] = e.target.value;
|
|
340
|
-
setValues(newValues);
|
|
341
|
-
}}
|
|
342
|
-
onKeyDown={onPressEnter}
|
|
343
|
-
autoFocus={!i}
|
|
344
|
-
/>
|
|
345
|
-
);
|
|
346
|
-
})}
|
|
347
|
-
</div>
|
|
348
|
-
</AlertPopUp>
|
|
349
|
-
);
|
|
350
|
-
}
|