mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 13:02:50 +00:00
Minor
This commit is contained in:
@@ -30,7 +30,12 @@ import {
|
|||||||
IconShieldCheck,
|
IconShieldCheck,
|
||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import { authStorage, useCurrentProfile } from '@ema-platform/auth';
|
import { authStorage, useCurrentProfile } from '@ema-platform/auth';
|
||||||
import { useApiQuery } from '@ema-platform/api';
|
import {
|
||||||
|
extractErrorMessage,
|
||||||
|
useApiQuery,
|
||||||
|
useBypassPaymentMutation,
|
||||||
|
useGetPaymentCapabilitiesQuery,
|
||||||
|
} from '@ema-platform/api';
|
||||||
import {
|
import {
|
||||||
useGetMySeaServiceRecordsQuery,
|
useGetMySeaServiceRecordsQuery,
|
||||||
useGetMyMedicalCertificatesQuery,
|
useGetMyMedicalCertificatesQuery,
|
||||||
@@ -146,11 +151,32 @@ export function CertificatesPage() {
|
|||||||
const [previewTitle, setPreviewTitle] = useState('');
|
const [previewTitle, setPreviewTitle] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { pay, isPaying } = useApplicationPayment();
|
const { pay, isPaying } = useApplicationPayment();
|
||||||
|
// Dev/test only — the API reports false in production and the button is
|
||||||
|
// never rendered. Same shortcut My Applications offers.
|
||||||
|
const { data: capabilities } = useGetPaymentCapabilitiesQuery();
|
||||||
|
const [bypassPayment, { isLoading: bypassing }] = useBypassPaymentMutation();
|
||||||
|
|
||||||
const { data } = useApiQuery<CertificatesOverview>({
|
const { data, refetch } = useApiQuery<CertificatesOverview>({
|
||||||
url: '/certificates/my',
|
url: '/certificates/my',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleBypass = async (applicationId: string) => {
|
||||||
|
try {
|
||||||
|
const result = await bypassPayment(applicationId).unwrap();
|
||||||
|
notifications.show({
|
||||||
|
color: 'teal',
|
||||||
|
title: 'Payment bypassed',
|
||||||
|
message: result.certificateIssued
|
||||||
|
? 'The certificate has been issued.'
|
||||||
|
: `Application is now ${humanStatus(result.status)}.`,
|
||||||
|
});
|
||||||
|
// Generic query, not tag-driven: refresh it by hand.
|
||||||
|
refetch();
|
||||||
|
} catch (err) {
|
||||||
|
notifications.show({ color: 'red', title: 'Bypass failed', message: extractErrorMessage(err) });
|
||||||
|
}
|
||||||
|
};
|
||||||
const certificates = data?.certificates ?? [];
|
const certificates = data?.certificates ?? [];
|
||||||
const applications = data?.applications ?? [];
|
const applications = data?.applications ?? [];
|
||||||
|
|
||||||
@@ -331,6 +357,17 @@ export function CertificatesPage() {
|
|||||||
Pay {app.feeAmount.toLocaleString()} {app.feeCurrency}
|
Pay {app.feeAmount.toLocaleString()} {app.feeCurrency}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{app.feeAmount !== null && capabilities?.bypassEnabled && (
|
||||||
|
<Button
|
||||||
|
size="xs"
|
||||||
|
variant="default"
|
||||||
|
loading={bypassing}
|
||||||
|
onClick={() => handleBypass(app.applicationId)}
|
||||||
|
title="Testing only — marks the fee paid without a provider"
|
||||||
|
>
|
||||||
|
Bypass payment
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Text
|
<Text
|
||||||
fz="xs"
|
fz="xs"
|
||||||
c="blue"
|
c="blue"
|
||||||
|
|||||||
Reference in New Issue
Block a user