@arbidocs/react 0.5.12 → 0.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6692,8 +6692,36 @@ function useCreateProject() {
6692
6692
  const arbi = chunkQQ7SCJRY_cjs.useArbi();
6693
6693
  const qc = reactQuery.useQueryClient();
6694
6694
  return reactQuery.useMutation({
6695
- mutationFn: ({ name, plan, ...details }) => arbi.projects.create(name, plan, details),
6696
- onSuccess: () => refreshProjects(qc, true)
6695
+ mutationFn: async ({ name, plan, workspace, ...details }) => {
6696
+ const project = await arbi.projects.create(name, plan, details);
6697
+ if (workspace) {
6698
+ project.workspace = await arbi.workspaces.create(
6699
+ name,
6700
+ project.external_id,
6701
+ workspace.description ?? null
6702
+ );
6703
+ }
6704
+ return project;
6705
+ },
6706
+ onSuccess: async ({ workspace, ...project }) => {
6707
+ await Promise.all([
6708
+ qc.cancelQueries({ queryKey: chunkH4FGDXYB_cjs.arbiQueryKeys.projects() }),
6709
+ qc.cancelQueries({ queryKey: chunkH4FGDXYB_cjs.arbiQueryKeys.workspaces() })
6710
+ ]);
6711
+ const id = (item) => item.external_id;
6712
+ qc.setQueryData(
6713
+ chunkH4FGDXYB_cjs.arbiQueryKeys.projects(),
6714
+ (old) => Array.isArray(old) ? [project, ...old.filter((p) => id(p) !== project.external_id)] : old
6715
+ );
6716
+ if (workspace) {
6717
+ const listed = { ...workspace, project_ext_id: project.external_id };
6718
+ qc.setQueryData(
6719
+ chunkH4FGDXYB_cjs.arbiQueryKeys.workspaces(),
6720
+ (old) => Array.isArray(old) ? [listed, ...old.filter((w) => id(w) !== workspace.external_id)] : old
6721
+ );
6722
+ }
6723
+ refreshProjects(qc, true);
6724
+ }
6697
6725
  });
6698
6726
  }
6699
6727
  function useDeleteProject() {