Many fixes -- especially and endorserServer

This commit is contained in:
Matthew Raymer
2023-09-03 21:08:30 +08:00
parent b514d64068
commit 5501ac1a2f
17 changed files with 315 additions and 285 deletions

View File

@@ -200,10 +200,6 @@
message="Received from"
>
</GiftedDialog>
<AlertMessage
:alertTitle="alertTitle"
:alertMessage="alertMessage"
></AlertMessage>
</section>
</template>
@@ -226,10 +222,19 @@ import {
import QuickNav from "@/components/QuickNav";
import EntityIcon from "@/components/EntityIcon";
interface Notification {
group: string;
type: string;
title: string;
text: string;
}
@Component({
components: { GiftedDialog, QuickNav, EntityIcon },
})
export default class ProjectViewView extends Vue {
$notify!: (notification: Notification, timeout?: number) => void;
activeDid = "";
allMyDids: Array<string> = [];
allContacts: Array<Contact> = [];
@@ -339,7 +344,7 @@ export default class ProjectViewView extends Vue {
this.longitude = resp.data.claim?.location?.geo?.longitude || 0;
} else if (resp.status === 404) {
// actually, axios throws an error so we never get here
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -352,7 +357,7 @@ export default class ProjectViewView extends Vue {
} catch (error: unknown) {
const serverError = error as AxiosError;
if (serverError.response?.status === 404) {
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -362,7 +367,7 @@ export default class ProjectViewView extends Vue {
-1,
);
} else {
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -384,7 +389,7 @@ export default class ProjectViewView extends Vue {
if (resp.status === 200 && resp.data.data) {
this.givesToThis = resp.data.data;
} else {
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -396,7 +401,7 @@ export default class ProjectViewView extends Vue {
}
} catch (error: unknown) {
const serverError = error as AxiosError;
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -420,7 +425,7 @@ export default class ProjectViewView extends Vue {
if (resp.status === 200 && resp.data.data) {
this.givesByThis = resp.data.data;
} else {
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -432,7 +437,7 @@ export default class ProjectViewView extends Vue {
}
} catch (error: unknown) {
const serverError = error as AxiosError;
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -485,7 +490,7 @@ export default class ProjectViewView extends Vue {
*/
async recordGive(giverDid, description: string, hours: number) {
if (!this.activeDid) {
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -498,7 +503,7 @@ export default class ProjectViewView extends Vue {
}
if (!description && !hours) {
(this as any).$notify(
this.$notify(
{
group: "alert",
type: "danger",
@@ -507,10 +512,7 @@ export default class ProjectViewView extends Vue {
},
-1,
);
return;
}
try {
} else {
const identity = await this.getIdentity(this.activeDid);
const result = await createAndSubmitGive(
this.axios,
@@ -522,22 +524,23 @@ export default class ProjectViewView extends Vue {
hours,
this.projectId,
);
if (result.status !== 201 || result.data?.error) {
if (result.type == "success") {
console.log("Error with give result:", result);
(this as any).$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
result.data?.error?.message ||
"There was an error recording the give.",
},
-1,
);
} else {
(this as any).$notify(
if ("data" in result) {
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
result.data?.error?.message ||
"There was an error recording the give.",
},
-1,
);
}
} else if (result.type == "error") {
this.$notify(
{
group: "alert",
type: "success",
@@ -547,20 +550,6 @@ export default class ProjectViewView extends Vue {
-1,
);
}
} catch (e) {
console.log("Error with give caught:", e);
(this as any).$notify(
{
group: "alert",
type: "danger",
title: "Error",
text:
e?.userMessage ||
e?.response?.data?.error?.message ||
"There was an error recording the give.",
},
-1,
);
}
}
}