Skip to content

Commit

Permalink
feat: Flow Name Duplicate Validation (#3445)
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Jul 19, 2024
1 parent 0095f16 commit 5382dbd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions editor.planx.uk/src/pages/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,20 @@ const Team: React.FC = () => {
const newFlowName = prompt("Service name");
if (newFlowName) {
const newFlowSlug = slugify(newFlowName);
useStore
.getState()
.createFlow(teamId, newFlowSlug, newFlowName)
.then((newId: string) => {
navigation.navigate(`/${slug}/${newId}`);
});
const duplicateFlowName = flows?.find(
(flow) => flow.slug === newFlowSlug,
);

!duplicateFlowName
? useStore
.getState()
.createFlow(teamId, newFlowSlug, newFlowName)
.then((newId: string) => {
navigation.navigate(`/${slug}/${newId}`);
})
: alert(
`The flow "${newFlowName}" already exists. Enter a unique flow name to continue`,
);
}
}}
>
Expand Down

0 comments on commit 5382dbd

Please sign in to comment.