Skip to content

Commit

Permalink
Add useEffect hooks to set selected space and type from EmptyViewObject
Browse files Browse the repository at this point in the history
  • Loading branch information
jmetrikat committed Feb 14, 2025
1 parent 886394b commit 058b926
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/components/EmptyViewObject.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Action, ActionPanel, Icon, List } from "@raycast/api";
import { useEffect } from "react";
import { CreateObjectFormValues } from "../create-object";
import { useCreateObjectData } from "../hooks/useCreateObjectData";
import CreateObjectForm from "./CreateObjectForm";
Expand Down Expand Up @@ -33,6 +34,18 @@ export default function EmptyViewObject({ title, contextValues }: EmptyViewObjec
isLoading,
} = useCreateObjectData(draftValues);

useEffect(() => {
if (spaces.length > 0 && !selectedSpace) {
setSelectedSpace(spaces[0].id);
}
}, [spaces]);

useEffect(() => {
if (objectTypes.length > 0 && !selectedType) {
setSelectedType(objectTypes[0].id);
}
}, [objectTypes]);

return (
<List.EmptyView
title={title}
Expand All @@ -54,6 +67,7 @@ export default function EmptyViewObject({ title, contextValues }: EmptyViewObjec
setSelectedList={setSelectedList}
isLoading={isLoading}
draftValues={draftValues}
enableDrafts={false}
/>
}
icon={Icon.Plus}
Expand Down

0 comments on commit 058b926

Please sign in to comment.