MCPcopy
hub / github.com/supermemoryai/supermemory / AddSpaceModal

Function AddSpaceModal

apps/web/components/add-space-modal.tsx:85–356  ·  view source on GitHub ↗
({
	isOpen,
	onClose,
	onCreated,
}: {
	isOpen: boolean
	onClose: () => void
	onCreated?: (containerTag: string) => void
})

Source from the content-addressed store, hash-verified

83]
84
85export function AddSpaceModal({
86 isOpen,
87 onClose,
88 onCreated,
89}: {
90 isOpen: boolean
91 onClose: () => void
92 onCreated?: (containerTag: string) => void
93}) {
94 const [spaceName, setSpaceName] = useState("")
95 const [spaceContext, setSpaceContext] = useState("")
96 const [showContext, setShowContext] = useState(false)
97 const [emoji, setEmoji] = useState("📁")
98 const [isEmojiOpen, setIsEmojiOpen] = useState(false)
99 const { createProjectMutation } = useProjectMutations()
100
101 const handleClose = () => {
102 onClose()
103 setSpaceName("")
104 setSpaceContext("")
105 setShowContext(false)
106 setEmoji("📁")
107 }
108
109 const handleCreate = () => {
110 const trimmedName = spaceName.trim()
111 if (!trimmedName) return
112
113 createProjectMutation.mutate(
114 { name: trimmedName, emoji: emoji || undefined },
115 {
116 onSuccess: async (data) => {
117 analytics.spaceCreated()
118 const tag = data?.containerTag
119 const context = showContext ? spaceContext.trim() : ""
120 if (tag && context) {
121 try {
122 await $fetch(`@patch/container-tags/${tag}`, {
123 body: { entityContext: context },
124 })
125 } catch {}
126 }
127 if (tag) onCreated?.(tag)
128 handleClose()
129 },
130 },
131 )
132 }
133
134 const handleKeyDown = (e: React.KeyboardEvent) => {
135 if (
136 e.key === "Enter" &&
137 spaceName.trim() &&
138 !createProjectMutation.isPending
139 ) {
140 e.preventDefault()
141 handleCreate()
142 }

Callers

nothing calls this directly

Calls 6

useProjectMutationsFunction · 0.90
cnFunction · 0.90
dmSansClassNameFunction · 0.90
dmSans125ClassNameFunction · 0.90
handleEmojiSelectFunction · 0.85
handleCloseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…