Skip to content

Commit 0119f44

Browse files
committed
fix: refactored to newOrg_id convention
1 parent 08dfba3 commit 0119f44

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/index.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const CoCreateUser = {
2222
detail: data
2323
}))
2424
})
25+
crud.listen('createUserNew', function(data) {
26+
document.dispatchEvent(new CustomEvent('createdUser', {
27+
detail: data
28+
}))
29+
})
2530
crud.listen('fetchedUser', this.checkPermissions)
2631
crud.listen('login', (instance)=> self.loginResult(instance))
2732
crud.listen('changedUserStatus', this.changedUserStatus)
@@ -222,6 +227,24 @@ const CoCreateUser = {
222227
}
223228
},
224229

230+
createUserNew: function(btn) {
231+
let form = btn.closest("form");
232+
if (!form) return;
233+
let newOrg_id = form.querySelector("input[data-collection='organizations'][name='_id']");
234+
let user_id = form.querySelector("input[data-collection='users'][name='_id']");
235+
236+
const room = config.organization_Id;
237+
238+
crud.socket.send('createUserNew', {
239+
apiKey: config.apiKey,
240+
organization_id: config.organization_Id,
241+
collection: 'users',
242+
newOrg_id: org_id,
243+
user_id: user_id,
244+
}, room);
245+
246+
},
247+
225248
createUser: function(btn) {
226249
let form = btn.closest("form");
227250
if (!form) return;
@@ -253,7 +276,7 @@ const CoCreateUser = {
253276
crud.socket.send('createUser', {
254277
apiKey: config.apiKey,
255278
organization_id: config.organization_Id,
256-
// db: this.masterDB,
279+
// mdb: this.masterDB,
257280
collection: 'users',
258281
data: data,
259282
orgDB: org_id
@@ -265,6 +288,14 @@ CoCreateUser.init();
265288

266289
export default CoCreateUser;
267290

291+
action.init({
292+
action: "createUserNew",
293+
endEvent: "createdUser",
294+
callback: (btn, data) => {
295+
CoCreateUser.createUser(btn)
296+
},
297+
})
298+
268299
action.init({
269300
action: "createUser",
270301
endEvent: "createdUser",

0 commit comments

Comments
 (0)