MCPcopy Index your code
hub / github.com/simstudioai/sim / useCreateFolder

Function useCreateFolder

apps/sim/hooks/queries/folders.ts:158–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156}
157
158export function useCreateFolder() {
159 const queryClient = useQueryClient()
160
161 const handlers = createFolderMutationHandlers<CreateFolderVariables>(
162 queryClient,
163 'CreateFolder',
164 (variables, tempId, previousFolders) => {
165 const currentWorkflows = Object.fromEntries(
166 getWorkflows(variables.workspaceId).map((w) => [w.id, w])
167 )
168
169 return {
170 id: tempId,
171 name: variables.name,
172 userId: '',
173 workspaceId: variables.workspaceId,
174 parentId: variables.parentId || null,
175 color: variables.color || '#808080',
176 isExpanded: false,
177 locked: false,
178 sortOrder:
179 variables.sortOrder ??
180 getTopInsertionSortOrder(
181 currentWorkflows,
182 previousFolders,
183 variables.workspaceId,
184 variables.parentId
185 ),
186 createdAt: new Date(),
187 updatedAt: new Date(),
188 archivedAt: null,
189 }
190 },
191 (variables) => variables.id ?? generateId()
192 )
193
194 return useMutation({
195 mutationFn: async ({ workspaceId, sortOrder, ...payload }: CreateFolderVariables) => {
196 const { folder } = await requestJson(createFolderContract, {
197 body: { ...payload, workspaceId, sortOrder },
198 })
199 return mapFolder(folder)
200 },
201 ...handlers,
202 })
203}
204
205export function useUpdateFolder() {
206 const queryClient = useQueryClient()

Callers 4

FolderItemFunction · 0.90
useFolderOperationsFunction · 0.90
useImportWorkflowFunction · 0.90
folders.test.tsFile · 0.90

Calls 6

getWorkflowsFunction · 0.90
getTopInsertionSortOrderFunction · 0.90
generateIdFunction · 0.90
requestJsonFunction · 0.90
mapFolderFunction · 0.70

Tested by

no test coverage detected