🛠️ Minor changes in frontend (#715)

This commit is contained in:
Alejandra
2024-03-13 22:59:28 +01:00
committed by GitHub
parent 10ef99cb68
commit 21232c0f9f
9 changed files with 13 additions and 12 deletions

View File

@@ -64,7 +64,7 @@ const AddUser: React.FC<AddUserProps> = ({ isOpen, onClose }) => {
onClose() onClose()
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
onSettled: () => { onSettled: () => {

View File

@@ -57,7 +57,7 @@ const EditUser: React.FC<EditUserProps> = ({ user, isOpen, onClose }) => {
onClose() onClose()
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
onSettled: () => { onSettled: () => {
@@ -67,7 +67,7 @@ const EditUser: React.FC<EditUserProps> = ({ user, isOpen, onClose }) => {
const onSubmit: SubmitHandler<UserUpdateForm> = async (data) => { const onSubmit: SubmitHandler<UserUpdateForm> = async (data) => {
if (data.password === '') { if (data.password === '') {
delete data.password data.password = undefined
} }
mutation.mutate(data) mutation.mutate(data)
} }

View File

@@ -33,7 +33,7 @@ const ActionsMenu: React.FC<ActionsMenuProps> = ({ type, value, disabled }) => {
as={Button} as={Button}
rightIcon={<BsThreeDotsVertical />} rightIcon={<BsThreeDotsVertical />}
variant="unstyled" variant="unstyled"
></MenuButton> />
<MenuList> <MenuList>
<MenuItem <MenuItem
onClick={editUserModal.onOpen} onClick={editUserModal.onOpen}

View File

@@ -52,7 +52,7 @@ const AddItem: React.FC<AddItemProps> = ({ isOpen, onClose }) => {
onClose() onClose()
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
onSettled: () => { onSettled: () => {

View File

@@ -49,7 +49,7 @@ const EditItem: React.FC<EditItemProps> = ({ item, isOpen, onClose }) => {
onClose() onClose()
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
onSettled: () => { onSettled: () => {

View File

@@ -44,7 +44,7 @@ const ChangePassword: React.FC = () => {
reset() reset()
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
}) })

View File

@@ -46,7 +46,7 @@ const DeleteConfirmation: React.FC<DeleteProps> = ({ isOpen, onClose }) => {
onClose() onClose()
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
onSettled: () => { onSettled: () => {

View File

@@ -53,7 +53,7 @@ const UserInformation: React.FC = () => {
showToast('Success!', 'User updated successfully.', 'success') showToast('Success!', 'User updated successfully.', 'success')
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
onSettled: () => { onSettled: () => {
@@ -118,7 +118,7 @@ const UserInformation: React.FC = () => {
/> />
) : ( ) : (
<Text size="md" py={2}> <Text size="md" py={2}>
{currentUser!.email} {currentUser?.email}
</Text> </Text>
)} )}
{errors.email && ( {errors.email && (

View File

@@ -50,8 +50,9 @@ function ResetPassword() {
const resetPassword = async (data: NewPassword) => { const resetPassword = async (data: NewPassword) => {
const token = new URLSearchParams(window.location.search).get('token') const token = new URLSearchParams(window.location.search).get('token')
if (!token) return
await LoginService.resetPassword({ await LoginService.resetPassword({
requestBody: { new_password: data.new_password, token: token! }, requestBody: { new_password: data.new_password, token: token },
}) })
} }
@@ -62,7 +63,7 @@ function ResetPassword() {
navigate({ to: '/login' }) navigate({ to: '/login' })
}, },
onError: (err: ApiError) => { onError: (err: ApiError) => {
const errDetail = err.body.detail const errDetail = err.body?.detail
showToast('Something went wrong.', `${errDetail}`, 'error') showToast('Something went wrong.', `${errDetail}`, 'error')
}, },
}) })