Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | 3x 3x | import React, { ReactElement } from 'react';
import { Form } from 'antd';
import { Store, TableMetaProps } from '@props/RecordProps';
import { callSaveDomainWithCallback } from '@utils/SaveDomainUtils';
import { getName, getUserId, getUsername } from '@utils/TokenUtils';
import { DataCollectForm } from '../form';
import { emptyMethod } from '@utils/Constants';
import { UserDomainName } from '@config/domain';
export interface UserProfileUpdateComponentProps {
onFinish: (values: Store) => void;
onFinishFailed: (values: Store) => void;
zIndex: number;
}
const columns = [
{
"blank": false,
"dataIndex": "id",
"display": true,
"displaySequence": -2147483648,
"editable": false,
"key": "id",
"title": "id",
"type": "integer",
}, {
"blank": false,
"dataIndex": "username",
"display": true,
"editable": false,
"email": true,
"key": "username",
"nullable": false,
"title": "Email",
"type": "string",
"unique": ["tenant"],
"updatable": false,
}, {
"blank": true,
"dataIndex": "password",
"display": true,
"editable": true,
"key": "password",
"nullable": true,
"title": "Password",
"type": "password",
"updatable": true,
}, {
"blank": true,
"dataIndex": "name",
"display": true,
"editable": true,
"key": "name",
"nullable": true,
"title": "Name",
"type": "string",
"updatable": true,
}, {
"backReferenceField": "",
"dataIndex": "avatar",
"display": true,
"editable": true,
"key": "avatar",
"labelField": "description",
"nullable": true,
"title": "Avatar",
"type": "image",
"updatable": true,
}
];
const UserProfileUpdateComponent = (props: UserProfileUpdateComponentProps): ReactElement => {
const { zIndex, onFinish, onFinishFailed } = props;
const [form] = Form.useForm();
const userId = getUserId();
if (userId == null) {
return (<></>);
}
return (
<div style={{ padding: "1rem" }}>
<DataCollectForm
page="user-profile-edit"
labelAlign="left"
onChange={emptyMethod}
onFinishFailed={onFinishFailed}
onFinish={() => {
const values = form.getFieldsValue();
callSaveDomainWithCallback({
emptyMethod,
values,
continueOperate: false,
domainName: UserDomainName,
}).then(() => console.info(
`Domain ${UserDomainName} has been saved with parameters ${JSON.stringify(values)}`
));
onFinish(values);
}}
operation="update"
columns={columns as Array<TableMetaProps>}
domainName={UserDomainName}
hideDetailPanel={true}
groups={[]}
form={form}
readonly={false}
hideFields={[]}
record={{
id: parseInt(userId),
password: "",
username: getUsername(),
name: getName(),
}}
zIndex={zIndex}
showBottomSaveButton={true}
/>
</div>
);
};
export default UserProfileUpdateComponent;
|