MCPcopy Create free account
hub / github.com/EsperoTech/yaade / handleCreateCollectionClick

Function handleCreateCollectionClick

client/src/components/sidebar/Sidebar.tsx:109–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107 }
108
109 async function handleCreateCollectionClick() {
110 try {
111 let response;
112 if (state.uploadFile) {
113 const data = new FormData();
114 data.append('File', state.uploadFile, 'file');
115
116 if (state.selectedImport === 'openapi') {
117 response = await api.importOpenApi(state.basePath, state.groups, data);
118 } else {
119 response = await api.importPostman(state.groups, data);
120 }
121 } else {
122 response = await api.createCollection(state.name, state.groups);
123 }
124
125 if (response.status !== 200) throw new Error();
126 const newCollection = (await response.json()) as Collection;
127
128 dispatchCollections({
129 type: CollectionsActionType.ADD_COLLECTION,
130 collection: newCollection,
131 });
132
133 saveSelectedEnv(newCollection.id, 'default');
134
135 successToast('A new collection was created and saved', toast);
136 onCloseClear();
137 } catch (e) {
138 errorToast('The collection could be not created', toast);
139 }
140 }
141
142 return (
143 <Box className={styles.box} bg="panelBg" h="100%" w="100%">

Callers

nothing calls this directly

Calls 5

saveSelectedEnvFunction · 0.90
successToastFunction · 0.90
errorToastFunction · 0.90
onCloseClearFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected