This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
} | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; |