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 { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||||
import { apiUrl } from '@lib/functions/Api';
|
import { apiUrl } from '@lib/functions/Api';
|
||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { Badge } from '@mantine/core';
|
import { ActionIcon, Alert, Badge, Group, HoverCard } from '@mantine/core';
|
||||||
import { IconTestPipe } from '@tabler/icons-react';
|
import { IconExclamationCircle, IconTestPipe } from '@tabler/icons-react';
|
||||||
import { useCallback, useMemo, useState } from 'react';
|
import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
useCreateApiFormModal,
|
useCreateApiFormModal,
|
||||||
useDeleteApiFormModal
|
useDeleteApiFormModal
|
||||||
@@ -15,6 +15,28 @@ import { useUserState } from '../../states/UserState';
|
|||||||
import { DateColumn } from '../ColumnRenderers';
|
import { DateColumn } from '../ColumnRenderers';
|
||||||
import { InvenTreeTable } from '../InvenTreeTable';
|
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() {
|
export function EmailTable() {
|
||||||
const sendTestMail = useCreateApiFormModal({
|
const sendTestMail = useCreateApiFormModal({
|
||||||
url: ApiEndpoints.email_test,
|
url: ApiEndpoints.email_test,
|
||||||
@@ -73,21 +95,25 @@ export function EmailTable() {
|
|||||||
title: t`Status`,
|
title: t`Status`,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: (record: any) => {
|
render: (record: any) => {
|
||||||
switch (record.status) {
|
return (
|
||||||
case 'A':
|
<Group justify='space-between'>
|
||||||
return <Badge color='blue'>{t`Announced`}</Badge>;
|
<EmailStatusBadge status={record.status} />
|
||||||
case 'S':
|
{record.error_message && (
|
||||||
return <Badge color='blue'>{t`Sent`}</Badge>;
|
<HoverCard>
|
||||||
case 'F':
|
<HoverCard.Target>
|
||||||
return <Badge color='red'>{t`Failed`}</Badge>;
|
<ActionIcon color='red' variant='transparent' size='sm'>
|
||||||
case 'D':
|
<IconExclamationCircle />
|
||||||
return <Badge color='green'>{t`Delivered`}</Badge>;
|
</ActionIcon>
|
||||||
case 'R':
|
</HoverCard.Target>
|
||||||
return <Badge color='green'>{t`Read`}</Badge>;
|
<HoverCard.Dropdown>
|
||||||
case 'C':
|
<Alert color='red' title={t`Error`}>
|
||||||
return <Badge color='green'>{t`Confirmed`}</Badge>;
|
{record.error_message}
|
||||||
}
|
</Alert>
|
||||||
return '-';
|
</HoverCard.Dropdown>
|
||||||
|
</HoverCard>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
switchable: true
|
switchable: true
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user