✨ Add webhook blocks API public endpoints
This commit is contained in:
2
apps/builder/src/features/workspace/utils/index.ts
Normal file
2
apps/builder/src/features/workspace/utils/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './parseNewName'
|
||||
export * from './setWorkspaceIdInLocalStorage'
|
||||
17
apps/builder/src/features/workspace/utils/parseNewName.ts
Normal file
17
apps/builder/src/features/workspace/utils/parseNewName.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Workspace } from 'models'
|
||||
|
||||
export const parseNewName = (
|
||||
userFullName: string | undefined,
|
||||
existingWorkspaces: Pick<Workspace, 'name'>[]
|
||||
) => {
|
||||
const workspaceName = userFullName
|
||||
? `${userFullName}'s workspace`
|
||||
: 'My workspace'
|
||||
let newName = workspaceName
|
||||
let i = 1
|
||||
while (existingWorkspaces.find((w) => w.name === newName)) {
|
||||
newName = `${workspaceName} (${i})`
|
||||
i++
|
||||
}
|
||||
return newName
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export const setWorkspaceIdInLocalStorage = (workspaceId: string) => {
|
||||
localStorage.setItem('workspaceId', workspaceId)
|
||||
}
|
||||
Reference in New Issue
Block a user