The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix bug tag colors
Charles Bochetccac7ec07be7
diff --git a/front/src/modules/ui/tag/components/Tag.tsx b/front/src/modules/ui/tag/components/Tag.tsxindex 1bc1fc28de9..95c508cbf75 100644--- a/front/src/modules/ui/tag/components/Tag.tsx+++ b/front/src/modules/ui/tag/components/Tag.tsx@@ -1,16 +1,23 @@import styled from '@emotion/styled';-export type TagColor =- | 'green'- | 'turquoise'- | 'sky'- | 'blue'- | 'purple'- | 'pink'- | 'red'- | 'orange'- | 'yellow'- | 'gray';+const tagColors = [+ 'green',+ 'turquoise',+ 'sky',+ 'blue',+ 'purple',+ 'pink',+ 'red',+ 'orange',+ 'yellow',+ 'gray',+];++export type TagColor = (typeof tagColors)[number];++export function castToTagColor(color: string): TagColor {+ return tagColors.find((tagColor) => tagColor === color) ?? 'gray';+}const StyledTag = styled.h3<{color: TagColor;@@ -33,14 +40,14 @@ const StyledTag = styled.h3<{`;export type TagProps = {- color: TagColor;+ color: string;text: string;onClick?: () => void;};export function Tag({ color, text, onClick }: TagProps) {return (- <StyledTag color={color} onClick={onClick}>+ <StyledTag color={castToTagColor(color)} onClick={onClick}>{text}</StyledTag>);