2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

add error message

This commit is contained in:
Matthias Mair
2025-01-20 22:06:14 +01:00
parent 001ddf2cee
commit 0c86f2705f

View File

@ -81,11 +81,14 @@ function EmailSection() {
data?: any data?: any
) { ) {
const vals: any = data || { email: value }; const vals: any = data || { email: value };
authApi(apiUrl(ApiEndpoints.auth_email), undefined, action, vals) return authApi(
.then(() => { apiUrl(ApiEndpoints.auth_email),
undefined,
action,
vals
).then(() => {
refetch(); refetch();
}) });
.catch((res: any) => console.log(res.data));
} }
if (isLoading) return <Loader />; if (isLoading) return <Loader />;
@ -171,7 +174,20 @@ function EmailSection() {
</Grid.Col> </Grid.Col>
<Grid.Col span={6}> <Grid.Col span={6}>
<Button <Button
onClick={() => runServerAction('post', { email: newEmailValue })} onClick={() =>
runServerAction('post', { email: newEmailValue }).catch((err) => {
if (err.status == 400) {
showNotification({
title: t`Error while adding email`,
message: err.response.data.errors
.map((error: any) => error.message)
.join('\n'),
color: 'red',
icon: <IconX />
});
}
})
}
> >
<Trans>Add Email</Trans> <Trans>Add Email</Trans>
</Button> </Button>