|
| 1 | +import { CButton, CSpinner } from '@coreui/react' |
| 2 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' |
1 | 3 | import React from 'react'
|
2 | 4 | import { CippCallout, CippPageList } from 'src/components/layout'
|
3 | 5 | import { cellBooleanFormatter, cellDateFormatter } from 'src/components/tables'
|
4 | 6 | import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
|
5 | 7 | import { useGenericGetRequestQuery } from 'src/store/api/app'
|
6 | 8 |
|
7 | 9 | const MailTest = () => {
|
8 |
| - const { data: config, isSuccess } = useGenericGetRequestQuery({ |
| 10 | + const configQuery = useGenericGetRequestQuery({ |
9 | 11 | path: '/api/ExecMailTest',
|
10 | 12 | params: { Action: 'CheckConfig' },
|
11 | 13 | })
|
12 | 14 |
|
| 15 | + function handleConfigRetry() { |
| 16 | + configQuery.refetch() |
| 17 | + } |
| 18 | + |
13 | 19 | const columns = [
|
14 | 20 | {
|
15 | 21 | name: 'Received',
|
@@ -73,14 +79,33 @@ const MailTest = () => {
|
73 | 79 | ]
|
74 | 80 | return (
|
75 | 81 | <div>
|
76 |
| - {isSuccess && ( |
77 |
| - <CippCallout color={config?.HasMailRead ? 'info' : 'warning'} dismissible={true}> |
78 |
| - {config?.HasMailRead && |
79 |
| - 'Mail Test Email: ' + config?.MailAddresses.filter((x) => x?.IsPrimary)[0]?.Address} |
80 |
| - {config?.HasMailRead == false && 'Permission Check: ' + config?.Message} |
| 82 | + {configQuery.isSuccess && ( |
| 83 | + <CippCallout color={configQuery.data?.HasMailRead ? 'info' : 'warning'} dismissible={true}> |
| 84 | + {configQuery.data?.HasMailRead && ( |
| 85 | + <> |
| 86 | + <b>Mail test email: </b> |
| 87 | + <a |
| 88 | + href={ |
| 89 | + 'mailto:' + |
| 90 | + configQuery.data?.MailAddresses.filter((x) => x?.IsPrimary)[0]?.Address |
| 91 | + } |
| 92 | + > |
| 93 | + {configQuery.data?.MailAddresses.filter((x) => x?.IsPrimary)[0]?.Address} |
| 94 | + </a> |
| 95 | + </> |
| 96 | + )} |
| 97 | + {configQuery.data?.HasMailRead == false && ( |
| 98 | + <> |
| 99 | + Permission Check: {configQuery.data?.Message}{' '} |
| 100 | + <CButton size="sm" className="ms-2" onClick={() => handleConfigRetry()}> |
| 101 | + {configQuery.isLoading ? <CSpinner /> : <FontAwesomeIcon icon="sync" />} Retry |
| 102 | + </CButton> |
| 103 | + </> |
| 104 | + )} |
81 | 105 | </CippCallout>
|
82 | 106 | )}
|
83 |
| - {isSuccess && config?.HasMailRead === true && ( |
| 107 | + {configQuery.isLoading && <CSpinner />} |
| 108 | + {configQuery.isSuccess && configQuery.data?.HasMailRead === true && ( |
84 | 109 | <CippPageList
|
85 | 110 | capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
|
86 | 111 | title="Mail Test"
|
|
0 commit comments