Skip to content

Commit

Permalink
fix(admin-ui): birthdate edit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mjatin-dev committed Jun 24, 2022
1 parent 14a90b2 commit b484db6
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { useTranslation } from 'react-i18next'
import { useFormik } from 'formik'
import { updateExistingUser } from '../../redux/actions/UserActions'
import { useDispatch, useSelector } from 'react-redux'
import moment from 'moment'
import { getPersistenceType } from '../../../services/redux/actions/PersistenceActions'

function UserEditPage() {
const dispatch = useDispatch()
const userAction = {}
Expand All @@ -17,6 +20,15 @@ function UserEditPage() {
const redirectToUserListPage = useSelector(
(state) => state.userReducer.redirectToUserListPage,
)

useEffect(() => {
dispatch(getPersistenceType())
}, [])

const persistenceType = useSelector(
(state) => state.persistenceTypeReducer.type,
)

useEffect(() => {
if (redirectToUserListPage) {
history.push('/user/usersmanagement')
Expand Down Expand Up @@ -80,8 +92,15 @@ function UserEditPage() {
givenName: values.givenName || '',
customAttributes: customAttributes,
dn: userDetails.dn,
customObjectClasses: ['top', 'jansPerson', 'jansCustomPerson'],
}
if (persistenceType == 'ldap') {
submitableValues['customObjectClasses'] = [
'top',
'jansPerson',
'jansCustomPerson',
]
}

dispatch(updateExistingUser(submitableValues))
}

Expand All @@ -96,12 +115,18 @@ function UserEditPage() {
let customAttribute = personAttributes.filter(
(e) => e.name == userDetails.customAttributes[i].name,
)
if (customAttribute[0].oxMultiValuedAttribute) {
initialValues[userDetails.customAttributes[i].name] =
userDetails.customAttributes[i].values
if (userDetails.customAttributes[i].name == 'birthdate') {
initialValues[userDetails.customAttributes[i].name] = moment(
userDetails.customAttributes[i].values[0],
).format('YYYY-MM-DD')
} else {
initialValues[userDetails.customAttributes[i].name] =
userDetails.customAttributes[i].values[0]
if (customAttribute[0].oxMultiValuedAttribute) {
initialValues[userDetails.customAttributes[i].name] =
userDetails.customAttributes[i].values
} else {
initialValues[userDetails.customAttributes[i].name] =
userDetails.customAttributes[i].values[0]
}
}
}
const formik = useFormik({
Expand Down

0 comments on commit b484db6

Please sign in to comment.