[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
added create user http method
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeepee committed Dec 8, 2019
1 parent de9ced3 commit 1adf041
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
2 changes: 2 additions & 0 deletions ui-src/src/components/User/Register/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
</template>

<script>
import { registerUser } from "./RegisterHttp.js";
export default {
name: "Register",
components: {}
Expand Down
36 changes: 36 additions & 0 deletions ui-src/src/components/User/Register/RegisterHttp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { makeHolochainCall, isSuccess } from "../../../utils.js";

function registerUser(
template,
username,
first_name,
last_name,
profile_picture,
bio
) {
makeHolochainCall(
template.$store.getters.getHolochainConnection,
"user",
"create_user",
{
username: username,
first_name: first_name,
last_name: last_name,
profile_picture: profile_picture,
bio: bio
},
result => {
if (isSuccess(result) == true) {
console.log("User has registered here is the result: ", result);
result;
} else {
template.$notify({
type: "error",
group: "main",
title: "There was an error creating the account. Error is: " + result,
duration: 1000
});
}
}
);
}
2 changes: 1 addition & 1 deletion ui-src/src/components/User/User.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Nav from "./../Nav/Nav.vue";
export default {
name: "User",
components: {
JuntoNav: Nav,
JuntoNav: Nav
}
};
</script>
30 changes: 20 additions & 10 deletions ui-src/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Settings } from "./settings.js";

export const makeHolochainCall = function makeHolochainCall(connection, zome, func, params, callback) {
connection.then(({ callZome }) => {
callZome(Settings.InstanceId, zome, func)(params).then((result) => callback(JSON.parse(result)))
})
export const makeHolochainCall = function makeHolochainCall(
connection,
zome,
func,
params,
callback
) {
connection.then(({ callZome }) => {
callZome(
Settings.InstanceId,
zome,
func
)(params).then(result => callback(JSON.parse(result)));
});
};

export const isSuccess = function isSuccess(data) {
if (typeof data.Ok != undefined) {
true
} else {
false
}
}
if (typeof data.Ok != undefined) {
true;
} else {
false;
}
};

0 comments on commit 1adf041

Please sign in to comment.