1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-19 17:52:45 +02:00
unleash.unleash/frontend/src/component/feature/FeatureView/FeatureNotFound/FeatureNotFound.tsx
Mateusz Kwasniewski 674e36b40b
Styled components batch4.1 (#2812)
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
2023-01-05 09:45:39 +01:00

50 lines
1.5 KiB
TypeScript

import React from 'react';
import { Link } from 'react-router-dom';
import { getCreateTogglePath } from 'utils/routePathHelpers';
import { useFeaturesArchive } from 'hooks/api/getters/useFeaturesArchive/useFeaturesArchive';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { styled } from '@mui/material';
const StyledFeatureId = styled('strong')({
wordBreak: 'break-all',
});
export const FeatureNotFound = () => {
const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId');
const { archivedFeatures } = useFeaturesArchive();
const createFeatureTogglePath = getCreateTogglePath(projectId, {
name: featureId,
});
if (!archivedFeatures) {
return null;
}
const isArchived = archivedFeatures.some(archivedFeature => {
return archivedFeature.name === featureId;
});
if (isArchived) {
return (
<p>
The feature <StyledFeatureId>{featureId}</StyledFeatureId> has
been archived. You can find it on the{' '}
<Link to={`/projects/${projectId}/archive`}>
project archive page
</Link>
.
</p>
);
}
return (
<p>
The feature <StyledFeatureId>{featureId}</StyledFeatureId> does not
exist. Would you like to{' '}
<Link to={createFeatureTogglePath}>create it</Link>?
</p>
);
};