mirror of
https://github.com/inventree/InvenTree.git
synced 2025-09-13 06:01:35 +00:00
Display error message in email table (#10231)
This commit is contained in:
@@ -3,9 +3,9 @@ import { RowDeleteAction } from '@lib/components/RowActions';
|
||||
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { Badge } from '@mantine/core';
|
||||
import { IconTestPipe } from '@tabler/icons-react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { ActionIcon, Alert, Badge, Group, HoverCard } from '@mantine/core';
|
||||
import { IconExclamationCircle, IconTestPipe } from '@tabler/icons-react';
|
||||
import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
||||
import {
|
||||
useCreateApiFormModal,
|
||||
useDeleteApiFormModal
|
||||
@@ -15,6 +15,28 @@ import { useUserState } from '../../states/UserState';
|
||||
import { DateColumn } from '../ColumnRenderers';
|
||||
import { InvenTreeTable } from '../InvenTreeTable';
|
||||
|
||||
function EmailStatusBadge({
|
||||
status
|
||||
}: {
|
||||
status: any;
|
||||
}): ReactNode {
|
||||
switch (status) {
|
||||
case 'A':
|
||||
return <Badge color='blue'>{t`Announced`}</Badge>;
|
||||
case 'S':
|
||||
return <Badge color='blue'>{t`Sent`}</Badge>;
|
||||
case 'F':
|
||||
return <Badge color='red'>{t`Failed`}</Badge>;
|
||||
case 'D':
|
||||
return <Badge color='green'>{t`Delivered`}</Badge>;
|
||||
case 'R':
|
||||
return <Badge color='green'>{t`Read`}</Badge>;
|
||||
case 'C':
|
||||
return <Badge color='green'>{t`Confirmed`}</Badge>;
|
||||
}
|
||||
return '-';
|
||||
}
|
||||
|
||||
export function EmailTable() {
|
||||
const sendTestMail = useCreateApiFormModal({
|
||||
url: ApiEndpoints.email_test,
|
||||
@@ -73,21 +95,25 @@ export function EmailTable() {
|
||||
title: t`Status`,
|
||||
sortable: true,
|
||||
render: (record: any) => {
|
||||
switch (record.status) {
|
||||
case 'A':
|
||||
return <Badge color='blue'>{t`Announced`}</Badge>;
|
||||
case 'S':
|
||||
return <Badge color='blue'>{t`Sent`}</Badge>;
|
||||
case 'F':
|
||||
return <Badge color='red'>{t`Failed`}</Badge>;
|
||||
case 'D':
|
||||
return <Badge color='green'>{t`Delivered`}</Badge>;
|
||||
case 'R':
|
||||
return <Badge color='green'>{t`Read`}</Badge>;
|
||||
case 'C':
|
||||
return <Badge color='green'>{t`Confirmed`}</Badge>;
|
||||
}
|
||||
return '-';
|
||||
return (
|
||||
<Group justify='space-between'>
|
||||
<EmailStatusBadge status={record.status} />
|
||||
{record.error_message && (
|
||||
<HoverCard>
|
||||
<HoverCard.Target>
|
||||
<ActionIcon color='red' variant='transparent' size='sm'>
|
||||
<IconExclamationCircle />
|
||||
</ActionIcon>
|
||||
</HoverCard.Target>
|
||||
<HoverCard.Dropdown>
|
||||
<Alert color='red' title={t`Error`}>
|
||||
{record.error_message}
|
||||
</Alert>
|
||||
</HoverCard.Dropdown>
|
||||
</HoverCard>
|
||||
)}
|
||||
</Group>
|
||||
);
|
||||
},
|
||||
switchable: true
|
||||
},
|
||||
|
Reference in New Issue
Block a user