diff --git a/packages/client/components/ActivityLibrary/CreateNewActivity/CreateNewActivity.tsx b/packages/client/components/ActivityLibrary/CreateNewActivity/CreateNewActivity.tsx index dc9d236279e..a7087dd4cb2 100644 --- a/packages/client/components/ActivityLibrary/CreateNewActivity/CreateNewActivity.tsx +++ b/packages/client/components/ActivityLibrary/CreateNewActivity/CreateNewActivity.tsx @@ -114,6 +114,7 @@ const query = graphql` availableTemplates(first: 2000) @connection(key: "ActivityLibrary_availableTemplates") { edges { node { + id name teamId type @@ -155,21 +156,23 @@ export const CreateNewActivity = (props: Props) => { const {submitting, error, submitMutation, onError, onCompleted} = useMutationProps() const history = useHistory() + const teamTemplates = availableTemplates.edges.filter( + (template) => + template.node.teamId === selectedTeam.id && template.node.type === selectedActivity.type + ) + + const newTemplate = teamTemplates.find((template) => template.node.name === '*New Template') + const handleCreateRetroTemplate = () => { if (submitting) { return } - const teamTemplates = availableTemplates.edges.filter( - (template) => - template.node.teamId === selectedTeam.id && template.node.type === 'retrospective' - ) - if (teamTemplates.length >= Threshold.MAX_RETRO_TEAM_TEMPLATES) { onError(new Error('You may only have 20 templates per team. Please remove one first.')) return } - if (teamTemplates.find((template) => template.node.name === '*New Template')) { + if (newTemplate) { onError(new Error('You already have a new template. Try renaming that one first.')) return } @@ -322,6 +325,12 @@ export const CreateNewActivity = (props: Props) => { /> + {newTemplate && ( +
+ You already have a new {selectedActivity.type} template. You can edit or rename this + existing template. +
+ )} {error &&
{error.message}
}
{selectedTeam.tier === 'starter' && !featureFlags.noTemplateLimit ? ( @@ -339,6 +348,18 @@ export const CreateNewActivity = (props: Props) => { Upgrade to Team Plan
+ ) : newTemplate ? ( + + + Edit Existing New Template + + ) : (