debian-image-builder-frontend/src/Components/ImagesTable/Target.tsx
regexowl 388069ec11 V2Wizard: Move targets to a constant
This moves mapping between target short and full names to the const to make it reusable.
2024-06-18 09:19:45 +02:00

32 lines
833 B
TypeScript

import React from 'react';
import { Skeleton } from '@patternfly/react-core';
import { targetOptions } from '../../constants';
import { useGetComposeClonesQuery } from '../../store/imageBuilderApi';
import { ComposesResponseItem } from '../../store/imageBuilderApi';
type TargetPropTypes = {
compose: ComposesResponseItem;
};
export const Target = ({ compose }: TargetPropTypes) => {
return <p>{targetOptions[compose.request.image_requests[0].image_type]}</p>;
};
type AwsTargetPropTypes = {
compose: ComposesResponseItem;
};
export const AwsTarget = ({ compose }: AwsTargetPropTypes) => {
const { data, isSuccess } = useGetComposeClonesQuery({
composeId: compose.id,
});
if (!isSuccess) {
return <Skeleton />;
}
const text = `${targetOptions.aws} (${data.data.length + 1})`;
return <>{text}</>;
};