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:
@ -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),
|
||||||
refetch();
|
undefined,
|
||||||
})
|
action,
|
||||||
.catch((res: any) => console.log(res.data));
|
vals
|
||||||
|
).then(() => {
|
||||||
|
refetch();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
|
Reference in New Issue
Block a user