chore: reformat code

This commit is contained in:
Rafael Taranto 2025-05-12 14:49:39 +01:00
parent 3d930aa73b
commit aedabcbdee
509 changed files with 6030 additions and 4266 deletions

View file

@ -65,7 +65,7 @@ const initialState = {
showResetPasswordModal: false,
showReset2FAModal: false,
showRoleModal: false,
showEnableUserModal: false
showEnableUserModal: false,
}
const reducer = (_, action) => {
@ -82,7 +82,7 @@ const reducer = (_, action) => {
const roleMapper = {
user: 'Regular',
superuser: 'Superuser'
superuser: 'Superuser',
}
const Users = () => {
@ -94,9 +94,9 @@ const Users = () => {
const [userInfo, setUserInfo] = useState(null)
const [validateAttestation] = useMutation(VALIDATE_ATTESTATION, {
onCompleted: res => {
onCompleted: () => {
// TODO: show a brief popup to have UX feedback?
}
},
})
const [generateAttestationOptions] = useLazyQuery(GENERATE_ATTESTATION, {
@ -106,11 +106,11 @@ const Users = () => {
variables: {
userID: userInfo.id,
attestationResponse: res,
domain: window.location.hostname
}
domain: window.location.hostname,
},
})
})
}
},
})
const elements = [
@ -128,7 +128,7 @@ const Users = () => {
</div>
)
return <span className={classes.username}>{u.username}</span>
}
},
},
{
header: 'Role',
@ -146,13 +146,13 @@ const Users = () => {
setUserInfo(u)
dispatch({
type: 'open',
payload: 'showRoleModal'
payload: 'showRoleModal',
})
}}
value={u.role === 'superuser'}
/>
</div>
)
),
},
{
header: 'Actions',
@ -170,7 +170,7 @@ const Users = () => {
setUserInfo(u)
dispatch({
type: 'open',
payload: 'showResetPasswordModal'
payload: 'showResetPasswordModal',
})
}}>
Reset password
@ -183,7 +183,7 @@ const Users = () => {
setUserInfo(u)
dispatch({
type: 'open',
payload: 'showReset2FAModal'
payload: 'showReset2FAModal',
})
}}>
Reset 2FA
@ -196,15 +196,15 @@ const Users = () => {
if (IP_CHECK_REGEX.test(window.location.hostname)) {
dispatch({
type: 'open',
payload: 'showFIDOModal'
payload: 'showFIDOModal',
})
} else {
setUserInfo(u)
generateAttestationOptions({
variables: {
userID: u.id,
domain: window.location.hostname
}
domain: window.location.hostname,
},
})
}
}}>
@ -212,7 +212,7 @@ const Users = () => {
</ActionButton>
</div>
)
}
},
},
{
header: 'Enabled',
@ -227,13 +227,13 @@ const Users = () => {
setUserInfo(u)
dispatch({
type: 'open',
payload: 'showEnableUserModal'
payload: 'showEnableUserModal',
})
}}
value={u.enabled}
/>
)
}
),
},
]
return (
@ -246,7 +246,7 @@ const Users = () => {
onClick={() => {
dispatch({
type: 'open',
payload: 'showCreateUserModal'
payload: 'showCreateUserModal',
})
}}>
Add new user

View file

@ -28,7 +28,7 @@ const CHANGE_USER_ROLE = gql`
const ChangeRoleModal = ({ state, dispatch, user, requiresConfirmation }) => {
const [changeUserRole, { error }] = useMutation(CHANGE_USER_ROLE, {
onCompleted: () => handleClose(),
refetchQueries: () => ['users']
refetchQueries: () => ['users'],
})
const [confirmation, setConfirmation] = useState(null)
@ -38,8 +38,8 @@ const ChangeRoleModal = ({ state, dispatch, user, requiresConfirmation }) => {
variables: {
confirmationCode: confirmation,
id: user.id,
newRole: user.role === 'superuser' ? 'user' : 'superuser'
}
newRole: user.role === 'superuser' ? 'user' : 'superuser',
},
})
}
@ -47,7 +47,7 @@ const ChangeRoleModal = ({ state, dispatch, user, requiresConfirmation }) => {
setConfirmation(null)
dispatch({
type: 'close',
payload: 'showRoleModal'
payload: 'showRoleModal',
})
}

View file

@ -27,23 +27,23 @@ const validationSchema = Yup.object().shape({
username: Yup.string()
.email('Username field should be in an email format!')
.required('Username field is required!'),
role: Yup.string().required('Role field is required!')
role: Yup.string().required('Role field is required!'),
})
const initialValues = {
username: '',
role: ''
role: '',
}
const radioOptions = [
{
code: 'user',
display: 'Regular user'
display: 'Regular user',
},
{
code: 'superuser',
display: 'Superuser'
}
display: 'Superuser',
},
]
const getErrorMsg = (formikErrors, formikTouched, mutationError) => {
@ -62,18 +62,18 @@ const CreateUserModal = ({ state, dispatch }) => {
setCreateUserURL(null)
dispatch({
type: 'close',
payload: 'showCreateUserModal'
payload: 'showCreateUserModal',
})
}
const [createUser, { error }] = useMutation(CREATE_USER, {
onCompleted: ({ createRegisterToken: token }) => {
setCreateUserURL(urlResolver(`/register?t=${token.token}`))
}
},
})
const roleClass = (formikErrors, formikTouched) => ({
[classes.error]: formikErrors.role && formikTouched.role
[classes.error]: formikErrors.role && formikTouched.role,
})
return (
@ -91,7 +91,7 @@ const CreateUserModal = ({ state, dispatch }) => {
onSubmit={values => {
setUsernameField(values.username)
createUser({
variables: { username: values.username, role: values.role }
variables: { username: values.username, role: values.role },
})
}}>
{({ errors, touched }) => (
@ -107,7 +107,7 @@ const CreateUserModal = ({ state, dispatch }) => {
<H3
className={classnames(
roleClass(errors, touched),
classes.modalLabel2
classes.modalLabel2,
)}>
Role
</H3>

View file

@ -28,12 +28,12 @@ const DISABLE_USER = gql`
const EnableUserModal = ({ state, dispatch, user, requiresConfirmation }) => {
const [enableUser, { error: enableError }] = useMutation(ENABLE_USER, {
onCompleted: () => handleClose(),
refetchQueries: () => ['users']
refetchQueries: () => ['users'],
})
const [disableUser, { error: disableError }] = useMutation(DISABLE_USER, {
onCompleted: () => handleClose(),
refetchQueries: () => ['users']
refetchQueries: () => ['users'],
})
const [confirmation, setConfirmation] = useState(null)
@ -42,8 +42,8 @@ const EnableUserModal = ({ state, dispatch, user, requiresConfirmation }) => {
disableUser({
variables: {
confirmationCode: confirmation,
id: user.id
}
id: user.id,
},
})
}
@ -51,8 +51,8 @@ const EnableUserModal = ({ state, dispatch, user, requiresConfirmation }) => {
enableUser({
variables: {
confirmationCode: confirmation,
id: user.id
}
id: user.id,
},
})
}
@ -64,7 +64,7 @@ const EnableUserModal = ({ state, dispatch, user, requiresConfirmation }) => {
setConfirmation(null)
dispatch({
type: 'close',
payload: 'showEnableUserModal'
payload: 'showEnableUserModal',
})
}

View file

@ -10,7 +10,7 @@ const ChangeRoleModal = ({ state, dispatch }) => {
const handleClose = () => {
dispatch({
type: 'close',
payload: 'showFIDOModal'
payload: 'showFIDOModal',
})
}

View file

@ -32,7 +32,7 @@ const Input2FAModal = ({ showModal, handleClose, setConfirmation }) => {
const [confirm2FA, { error: queryError }] = useLazyQuery(CONFIRM_2FA, {
onCompleted: ({ confirm2FA: success }) =>
!success ? setInvalidCode(true) : onContinue()
!success ? setInvalidCode(true) : onContinue(),
})
const getErrorMsg = () => {

View file

@ -28,8 +28,8 @@ const Reset2FAModal = ({ state, dispatch, user, requiresConfirmation }) => {
{
onCompleted: ({ createReset2FAToken: token }) => {
setReset2FAUrl(urlResolver(`/reset2fa?t=${token.token}`))
}
}
},
},
)
const [confirmation, setConfirmation] = useState(null)
@ -40,22 +40,22 @@ const Reset2FAModal = ({ state, dispatch, user, requiresConfirmation }) => {
createReset2FAToken({
variables: {
confirmationCode: confirmation,
userID: user?.id
}
userID: user?.id,
},
})
}, [
confirmation,
createReset2FAToken,
requiresConfirmation,
state.showReset2FAModal,
user?.id
user?.id,
])
const handleClose = () => {
setConfirmation(null)
dispatch({
type: 'close',
payload: 'showReset2FAModal'
payload: 'showReset2FAModal',
})
}

View file

@ -27,7 +27,7 @@ const ResetPasswordModal = ({
state,
dispatch,
user,
requiresConfirmation
requiresConfirmation,
}) => {
const [resetPasswordUrl, setResetPasswordUrl] = useState('')
@ -36,8 +36,8 @@ const ResetPasswordModal = ({
{
onCompleted: ({ createResetPasswordToken: token }) => {
setResetPasswordUrl(urlResolver(`/resetpassword?t=${token.token}`))
}
}
},
},
)
const [confirmation, setConfirmation] = useState(null)
@ -48,22 +48,22 @@ const ResetPasswordModal = ({
createResetPasswordToken({
variables: {
confirmationCode: confirmation,
userID: user?.id
}
userID: user?.id,
},
})
}, [
confirmation,
createResetPasswordToken,
requiresConfirmation,
state.showResetPasswordModal,
user?.id
user?.id,
])
const handleClose = () => {
setConfirmation(null)
dispatch({
type: 'close',
payload: 'showResetPasswordModal'
payload: 'showResetPasswordModal',
})
}