-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): user edit page gentle push
- Loading branch information
1 parent
5fe8fe1
commit bd60e6c
Showing
6 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
admin-ui/plugins/admin/components/UserManagement/UserEditPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React from 'react' | ||
import { useHistory } from 'react-router-dom' | ||
import { Container, CardBody, Card } from '../../../../app/components' | ||
import UserForm from './UserForm' | ||
import GluuAlert from '../../../../app/routes/Apps/Gluu/GluuAlert' | ||
import { useTranslation } from 'react-i18next' | ||
import { useFormik } from 'formik' | ||
import { initialClaims } from './constLists' | ||
import { createNewUser } from '../../redux/actions/UserActions' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
function UserEditPage() { | ||
const dispatch = useDispatch() | ||
const userAction = {} | ||
const history = useHistory() | ||
const { t } = useTranslation() | ||
const userDetails = useSelector((state) => state.userReducer.selectedUserData) | ||
const createCustomAttributes = (values) => { | ||
let customAttributes = [] | ||
if (values) { | ||
for (let key in values) { | ||
if (initialClaims.some((e) => e.id == key)) { | ||
let val = [] | ||
val.push(values[key]) | ||
let obj = { | ||
name: key, | ||
multiValued: false, | ||
values: val, | ||
value: values[key], | ||
displayValue: values[key], | ||
} | ||
customAttributes.push(obj) | ||
} | ||
} | ||
// console.log(values); | ||
return customAttributes | ||
} | ||
} | ||
|
||
const submitData = (values) => { | ||
let customAttributes = createCustomAttributes(values) | ||
let submitableValues = { | ||
userId: values.userId || '', | ||
mail: values.mail, | ||
displayName: values.displayName || '', | ||
jansStatus: values.jansStatus || '', | ||
userPassword: values.userPassword || '', | ||
givenName: values.givenName || '', | ||
customAttributes: customAttributes, | ||
} | ||
dispatch(createNewUser(submitableValues)) | ||
// console.log(submitableValues) | ||
} | ||
|
||
const initialValues = { | ||
displayName: userDetails.displayName, | ||
givenName: userDetails.givenName, | ||
mail: userDetails.mail, | ||
userId: userDetails.userId, | ||
} | ||
|
||
const formik = useFormik({ | ||
initialValues: initialValues, | ||
onSubmit: (values) => { | ||
// submitData(values) | ||
alert(JSON.stringify(values, null, 2)) | ||
}, | ||
}) | ||
return ( | ||
<React.Fragment> | ||
{/* <GluuRibbon title={t('titles.user_management')} fromLeft /> */} | ||
<GluuAlert | ||
severity={t('titles.error')} | ||
message={t('messages.error_in_saving')} | ||
show={false} | ||
/> | ||
<Container> | ||
<Card className="mb-3"> | ||
<CardBody> | ||
<UserForm formik={formik} /> | ||
</CardBody> | ||
</Card> | ||
</Container> | ||
</React.Fragment> | ||
) | ||
} | ||
export default UserEditPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters