snowballtools-base/packages/frontend/src/components/shared/CustomIcon/templates/TemplateIcon.tsx
nabarun b61682dd20 Fix fetching build logs for redeployments (#39)
Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: cerc-io/snowballtools-base#39
2024-11-12 15:18:07 +00:00

28 lines
793 B
TypeScript

import { useMemo } from 'react';
import { CustomIconProps } from '../CustomIcon';
import { cloneIcon } from 'utils/cloneIcon';
import { PWAIcon } from './PWAIcon';
import { WebAppIcon } from './WebAppIcon';
const TEMPLATE_ICONS = ['pwa', 'web'] as const;
export type TemplateIconType = (typeof TEMPLATE_ICONS)[number];
export interface TemplateIconProps extends CustomIconProps {
type: TemplateIconType;
}
export const TemplateIcon = ({ type, ...props }: TemplateIconProps) => {
const renderIcon = useMemo(() => {
switch (type) {
case 'pwa':
return <PWAIcon />;
case 'web':
return <WebAppIcon />;
default:
throw new Error(`Invalid template icon type: ${type}`);
}
}, [type]);
return cloneIcon(renderIcon, props) as JSX.Element;
};