Browse Source

add nostr Trustroots partner as an option when submitting a project

Trent Larson 2 months ago
parent
commit
f2446b0b83
  1. 46
      src/views/NewEditProjectView.vue

46
src/views/NewEditProjectView.vue

@ -145,6 +145,16 @@
</l-map>
</div>
<div v-if="showGeneralAdvanced" class="flex items-center mb-4">
<input
type="checkbox"
class="mr-2"
v-model="sendToTrustroots"
@click="sendToTrustroots = !sendToTrustroots"
/>
<label for="sendToTrustroots">Send to Trustroots</label>
</div>
<div class="mt-8">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
<button
@ -224,6 +234,8 @@ export default class NewEditProjectView extends Vue {
numAccounts = 0;
projectId = "";
projectIssuerDid = "";
sendToTrustroots = false;
showGeneralAdvanced = false;
startDateInput?: string;
startTimeInput?: string;
zoneName = DateTime.local().zoneName;
@ -236,6 +248,7 @@ export default class NewEditProjectView extends Vue {
const settings = await retrieveSettingsForActiveAccount();
this.activeDid = settings.activeDid || "";
this.apiServer = settings.apiServer || "";
this.showGeneralAdvanced = !!settings.showGeneralAdvanced;
this.projectId = (this.$route as Router).query["projectId"] || "";
@ -418,9 +431,42 @@ export default class NewEditProjectView extends Vue {
try {
const resp = await this.axios.post(url, payload, { headers });
if (resp.data?.success?.handleId) {
console.log("Saved project with data", resp.data.success);
this.errorMessage = "";
const projectPath = encodeURIComponent(resp.data.success.handleId);
if (this.sendToTrustroots) {
const trustrootsUrl = "http://localhost:3000/api/partner/link";
const trustrootsParams = new URLSearchParams({
jwtId: resp.data.success.claimId,
linkCode: "NOSTR-EVENT-TRUSTROOTS",
inputJson: JSON.stringify("localhost " + resp.data.success.claimId),
});
const fullTrustrootsUrl =
trustrootsUrl + "?" + trustrootsParams.toString();
const headers = await getHeaders(issuerDid);
try {
const linkResp = await this.axios.post(
fullTrustrootsUrl,
{},
{ headers },
);
console.log("Sent to Trustroots with data!!!!", linkResp.data);
} catch (error) {
console.error("Error sending to Trustroots", error);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error Sending to Trustroots",
text: "There was an error sending to Trustroots.",
},
5000,
);
}
}
(this.$router as Router).push({ path: "/project/" + projectPath });
} else {
console.error(

Loading…
Cancel
Save