From a76df552249e7b934f611f2ebf10d864a124fcf2 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 3 Feb 2024 18:56:09 -0700 Subject: [PATCH] add display of my own offers --- project.task.yaml | 5 + src/libs/endorserServer.ts | 149 ++++++++------- src/libs/util.ts | 19 ++ src/views/ContactsView.vue | 2 +- src/views/DiscoverView.vue | 34 ++-- src/views/ProjectViewView.vue | 23 +-- src/views/ProjectsView.vue | 345 ++++++++++++++++++++++++++++++---- 7 files changed, 431 insertions(+), 146 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index 81e4bd42..bb2def3f 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -1,6 +1,11 @@ tasks: +- change server plan & project endpoints to use jwtId as identifier rather than rowid +- on mobile, don't capitalize first word & don't add spaces of website entry, and don't add spaces in numeric entry +- edit offers & gives, or revoke allowing recreation +- bug (that is hard to reproduce) - offer gave USD (by default?) +- .1 When available in the server, give message for 'nonAmountGiven' on offers on ProjectsView page. - .5 fix timeSafari.org cert renewals - .2 anchor hash into BTC - 04 allow backup of localStorage key diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 3c2fb95d..345dd970 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -80,9 +80,13 @@ export interface GiveServerRecord { export interface OfferServerRecord { amount: number; amountGiven: number; + amountGivenConfirmed: number; fullClaim: OfferVerifiableCredential; fulfillsPlanHandleId: string; handleId: string; + jwtId: string; + nonAmountGivenConfirmed: number; + objectDescription: string; offeredByDid: string; recipientDid: string; requirementsMet: boolean; @@ -145,6 +149,57 @@ export interface PlanVerifiableCredential { }; } +/** + * Represents data about a project + * + * @deprecated + * We should use PlanServerRecord instead. + **/ +export interface PlanData { + /** + * Name of the project + **/ + name: string; + /** + * Description of the project + **/ + description: string; + /** + * URL referencing information about the project + **/ + handleId: string; + /** + * The DID of the issuer + */ + issuerDid: string; + /** + * The Identier of the project -- different from jwtId, needs to be fixed + **/ + rowid?: string; +} + +export interface RateLimits { + doneClaimsThisWeek: string; + doneRegistrationsThisMonth: string; + maxClaimsPerWeek: string; + maxRegistrationsPerMonth: string; + nextMonthBeginDateTime: string; + nextWeekBeginDateTime: string; +} + +export interface VerifiableCredential { + "@context": string; + "@type": string; + name: string; + description: string; + identifier?: string; +} + +export interface WorldProperties { + startTime?: string; + endTime?: string; +} + export interface RegisterVerifiableCredential { "@context": string; "@type": string; @@ -153,11 +208,35 @@ export interface RegisterVerifiableCredential { participant: { identifier: string }; } +// now for some of the error & other wrapper types + +export interface ResultWithType { + type: string; +} + +export interface SuccessResult extends ResultWithType { + type: "success"; + response: AxiosResponse; +} + +export interface ErrorResponse { + error?: { + message?: string; + }; +} + +export interface ErrorResult { + type: "error"; + error: InternalError; +} + export interface InternalError { error: string; // for system logging userMessage?: string; // for user display } +export type CreateAndSubmitClaimResult = SuccessResult | ErrorResult; + // This is used to check for hidden info. // See https://github.com/trentlarson/endorser-ch/blob/0cb626f803028e7d9c67f095858a9fc8542e3dbd/server/api/services/util.js#L6 const HIDDEN_DID = "did:none:HIDDEN"; @@ -294,22 +373,6 @@ export function didInfo( } } -export interface ResultWithType { - type: string; -} - -export interface SuccessResult extends ResultWithType { - type: "success"; - response: AxiosResponse; -} - -export interface ErrorResult { - type: "error"; - error: InternalError; -} - -export type CreateAndSubmitClaimResult = SuccessResult | ErrorResult; - /** * For result, see https://api.endorser.ch/api-docs/#/claims/post_api_v2_claim * @@ -487,57 +550,3 @@ export function isNumeric(str: string): boolean { export function numberOrZero(str: string): number { return isNumeric(str) ? +str : 0; } - -export interface ErrorResponse { - error?: { - message?: string; - }; -} - -export interface RateLimits { - doneClaimsThisWeek: string; - doneRegistrationsThisMonth: string; - maxClaimsPerWeek: string; - maxRegistrationsPerMonth: string; - nextMonthBeginDateTime: string; - nextWeekBeginDateTime: string; -} - -/** - * Represents data about a project - **/ -export interface ProjectData { - /** - * Name of the project - **/ - name: string; - /** - * Description of the project - **/ - description: string; - /** - * URL referencing information about the project - **/ - handleId: string; - /** - * The DID of the issuer - */ - issuerDid: string; - /** - * The Identier of the project - **/ - rowid: string; -} - -export interface VerifiableCredential { - "@context": string; - "@type": string; - name: string; - description: string; - identifier?: string; -} - -export interface WorldProperties { - startTime?: string; - endTime?: string; -} diff --git a/src/libs/util.ts b/src/libs/util.ts index 14b1e757..a751e314 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -36,6 +36,25 @@ export const UNIT_LONG: Record = { }; /* eslint-enable prettier/prettier */ +const UNIT_CODES: Record> = { + BTC: { + name: "Bitcoin", + faIcon: "bitcoin-sign", + }, + HUR: { + name: "hours", + faIcon: "clock", + }, + USD: { + name: "US Dollars", + faIcon: "dollar", + }, +}; + +export function iconForUnitCode(unitCode: string) { + return UNIT_CODES[unitCode]?.faIcon || "question"; +} + export const isGlobalUri = (uri: string) => { return uri && uri.match(new RegExp(/^[A-Za-z][A-Za-z0-9+.-]+:/)); }; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index c7705441..b10781f7 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -75,7 +75,7 @@
(Only most recent hours included. To see more, click diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 92be9dc6..3b0cb44a 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -51,13 +51,13 @@
  • Anywhere = []; apiServer = ""; searchTerms = ""; - projects: ProjectData[] = []; + projects: PlanData[] = []; isLoading = false; isLocalActive = true; isRemoteActive = false; @@ -178,8 +178,8 @@ export default class DiscoverView extends Vue { async mounted() { await db.open(); const settings = await db.settings.get(MASTER_SETTINGS_KEY); - this.activeDid = settings?.activeDid || ""; - this.apiServer = settings?.apiServer || ""; + this.activeDid = (settings?.activeDid as string) || ""; + this.apiServer = (settings?.apiServer as string) || ""; this.searchBox = settings?.searchBoxes?.[0] || null; this.allContacts = await db.contacts.toArray(); @@ -276,7 +276,7 @@ export default class DiscoverView extends Vue { const results = await response.json(); - const plans: ProjectData[] = results.data; + const plans: PlanData[] = results.data; if (plans) { for (const plan of plans) { const { name, description, handleId, issuerDid, rowid } = plan; @@ -360,7 +360,7 @@ export default class DiscoverView extends Vue { if (results.data) { if (beforeId) { - const plans: ProjectData[] = results.data; + const plans: PlanData[] = results.data; for (const plan of plans) { const { name, description, handleId, issuerDid, rowid } = plan; this.projects.push({ @@ -428,13 +428,15 @@ export default class DiscoverView extends Vue { "py-3": true, "rounded-t-lg": true, "border-b-2": true, + active: this.isLocalActive, - "text-blue-600": this.isLocalActive, - "border-blue-600": this.isLocalActive, + "text-black": this.isLocalActive, + "border-black": this.isLocalActive, "font-semibold": this.isLocalActive, + + "text-blue-600": !this.isLocalActive, "border-transparent": !this.isLocalActive, - "hover:text-slate-600": !this.isLocalActive, - "hover:border-slate-300": !this.isLocalActive, + "hover:border-slate-400": !this.isLocalActive, }; } @@ -444,13 +446,15 @@ export default class DiscoverView extends Vue { "py-3": true, "rounded-t-lg": true, "border-b-2": true, + active: this.isRemoteActive, - "text-blue-600": this.isRemoteActive, - "border-blue-600": this.isRemoteActive, + "text-black": this.isRemoteActive, + "border-black": this.isRemoteActive, "font-semibold": this.isRemoteActive, + + "text-blue-600": !this.isRemoteActive, "border-transparent": !this.isRemoteActive, - "hover:text-slate-600": !this.isRemoteActive, - "hover:border-slate-300": !this.isRemoteActive, + "hover:border-slate-400": !this.isRemoteActive, }; } } diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 1609d4a7..c8ae0050 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -216,7 +216,7 @@ {{ offer.amount }} @@ -274,7 +274,7 @@ {{ give.amount }} @@ -755,25 +755,6 @@ export default class ProjectViewView extends Vue { (this.$refs.customGiveDialog as GiftedDialog).open(giver, offer.handleId); } - UNIT_CODES: Record> = { - BTC: { - name: "Bitcoin", - faIcon: "bitcoin-sign", - }, - HUR: { - name: "hours", - faIcon: "clock", - }, - USD: { - name: "US Dollars", - faIcon: "dollar", - }, - }; - - iconForUnitCode(unitCode: string) { - return this.UNIT_CODES[unitCode]?.faIcon || "question"; - } - // return an HTTPS URL if it's not a global URL addScheme(url: string) { if (!libsUtil.isGlobalUri(url)) { diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 23e5d5b4..d75880b1 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -8,8 +8,44 @@ Your Ideas - + + + +