mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-30 06:28:13 +00:00
feat(ApplicationRedirectPage): add page to resolve deep links for applications
fix(LicenseQueuePage): correct sorting logic for "mine" view
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { Center, Loader } from '@mantine/core';
|
||||
import { Navigate, useParams } from 'react-router-dom';
|
||||
import { useGetApplicationQuery } from '@ema-platform/api';
|
||||
|
||||
/**
|
||||
* Resolves `/applications/:applicationId` deep links (notification
|
||||
* callbackUrl, emails) to the canonical `/licensing/:typeCode/applications/:id`
|
||||
* route, which needs the licence type key to load its config.
|
||||
*/
|
||||
export function ApplicationRedirectPage() {
|
||||
const { applicationId } = useParams();
|
||||
const { data, isLoading, isError } = useGetApplicationQuery(applicationId!, {
|
||||
skip: !applicationId,
|
||||
});
|
||||
|
||||
if (!applicationId || isError) {
|
||||
return <Navigate replace to="/licensing/applications" />;
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Center h={300}>
|
||||
<Loader />
|
||||
</Center>
|
||||
);
|
||||
}
|
||||
|
||||
const typeCode = data?.application.licenseType?.key ?? 'FREIGHT_FORWARDER';
|
||||
return <Navigate replace to={`/licensing/${typeCode}/applications/${applicationId}`} />;
|
||||
}
|
||||
|
||||
export default ApplicationRedirectPage;
|
||||
Reference in New Issue
Block a user