12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import {useEffect, useState} from 'react';
- import type {RouteComponentProps} from 'react-router';
- import DetailedError from 'sentry/components/errors/detailedError';
- import * as Layout from 'sentry/components/layouts/thirds';
- import {t} from 'sentry/locale';
- import {useParams} from 'sentry/utils/useParams';
- type Props = RouteComponentProps<{}, {}>;
- function ProjectEventRedirect({router}: Props) {
- const [error, setError] = useState<string | null>(null);
- const params = useParams();
- useEffect(() => {
-
-
-
- const endpoint = `/organizations/${params.orgId}/projects/${params.projectId}/events/${params.eventId}/`;
-
-
-
-
-
- const xhr = new XMLHttpRequest();
-
-
-
- xhr.open('HEAD', endpoint);
- xhr.send();
- xhr.onload = () => {
- if (xhr.status === 404) {
- setError(t('Could not find an issue for the provided event id'));
- return;
- }
-
-
-
-
-
- router.replace(xhr.responseURL);
- };
- xhr.onerror = () => {
- setError(t('Could not load the requested event'));
- };
- }, [params, router]);
- return error ? (
- <DetailedError heading={t('Not found')} message={error} hideSupportLinks />
- ) : (
- <Layout.Page withPadding />
- );
- }
- export default ProjectEventRedirect;
|