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

Function SquadStack

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

useSourceStackFunction · 0.90
isCompanyPageFunction · 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