MCPcopy Create free account
hub / github.com/dailydotdev/apps / SquadStack

Function SquadStack

packages/shared/src/components/squads/stack/SquadStack.tsx:28–197  ·  view source on GitHub ↗
({ squad }: SquadStackProps)

Source from the content-addressed store, hash-verified

26}
27
28export function SquadStack({ squad }: SquadStackProps): ReactElement | null {
29 const { stackItems, canEdit, canAddMore, add, update, remove } =
30 useSourceStack(squad);
31 const { displayToast } = useToastNotification();
32 const { showPrompt } = usePrompt();
33
34 const [isModalOpen, setIsModalOpen] = useState(false);
35 const [editingItem, setEditingItem] = useState<SourceStack | null>(null);
36 const [isExpanded, setIsExpanded] = useState(false);
37
38 const handleAdd = useCallback(
39 async (input: AddSourceStackInput) => {
40 try {
41 await add(input);
42 displayToast('Added to squad stack');
43 } catch (error) {
44 displayToast('Failed to add item');
45 throw error;
46 }
47 },
48 [add, displayToast],
49 );
50
51 const handleEdit = useCallback((item: SourceStack) => {
52 setEditingItem(item);
53 setIsModalOpen(true);
54 }, []);
55
56 const handleUpdate = useCallback(
57 async (input: AddSourceStackInput) => {
58 if (!editingItem) {
59 return;
60 }
61 try {
62 await update({
63 id: editingItem.id,
64 input: {
65 title: input.title,
66 },
67 });
68 displayToast('Stack item updated');
69 } catch (error) {
70 displayToast('Failed to update item');
71 throw error;
72 }
73 },
74 [editingItem, update, displayToast],
75 );
76
77 const handleDelete = useCallback(
78 async (item: SourceStack) => {
79 const displayTitle = item.title ?? item.tool.title;
80 const confirmed = await showPrompt({
81 title: 'Remove from stack?',
82 description: `Are you sure you want to remove "${displayTitle}" from the squad stack?`,
83 okButton: { title: 'Remove', variant: ButtonVariant.Primary },
84 });
85 if (!confirmed) {

Callers

nothing calls this directly

Calls 5

useSourceStackFunction · 0.90
useToastNotificationFunction · 0.90
usePromptFunction · 0.90
displayToastFunction · 0.85
updateFunction · 0.50

Tested by

no test coverage detected