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

Function SquadStack

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected