Browse Source

add "+" to numbers if hit limit (>50), fix linting

Trent Larson 3 weeks ago
parent
commit
64bc47e13e
  1. 15
      src/libs/endorserServer.ts
  2. 39
      src/views/HomeView.vue
  3. 24
      src/views/NewActivityView.vue
  4. 2
      test-playwright/50-record-offer.spec.ts

15
src/libs/endorserServer.ts

@ -591,6 +591,10 @@ export async function setPlanInCache(
planCache.set(handleId, planSummary); planCache.set(handleId, planSummary);
} }
/**
*
* @returns { data: Array<OfferSummaryRecord>, hitLimit: boolean }
*/
export async function getNewOffersToUser( export async function getNewOffersToUser(
axios: Axios, axios: Axios,
apiServer: string, apiServer: string,
@ -603,10 +607,12 @@ export async function getNewOffersToUser(
} }
const headers = await getHeaders(activeDid); const headers = await getHeaders(activeDid);
const response = await axios.get(url, { headers }); const response = await axios.get(url, { headers });
const offers = response.data.data; return response.data;
return offers;
} }
/**
*
* @returns { data: Array<OfferToPlanSummaryRecord>, hitLimit: boolean }
*/
export async function getNewOffersToUserProjects( export async function getNewOffersToUserProjects(
axios: Axios, axios: Axios,
apiServer: string, apiServer: string,
@ -619,8 +625,7 @@ export async function getNewOffersToUserProjects(
} }
const headers = await getHeaders(activeDid); const headers = await getHeaders(activeDid);
const response = await axios.get(url, { headers }); const response = await axios.get(url, { headers });
const offers = response.data.data; return response.data;
return offers;
} }
/** /**

39
src/views/HomeView.vue

@ -210,7 +210,7 @@
class="block text-center text-6xl" class="block text-center text-6xl"
data-testId="newDirectOffersActivityNumber" data-testId="newDirectOffersActivityNumber"
> >
{{ numNewOffersToUser }} {{ numNewOffersToUser }}{{ newOffersToUserHitLimit ? "+" : "" }}
</span> </span>
<p>new offer{{ numNewOffersToUser === 1 ? "" : "s" }} to you</p> <p>new offer{{ numNewOffersToUser === 1 ? "" : "s" }} to you</p>
</div> </div>
@ -222,7 +222,8 @@
class="block text-center text-6xl" class="block text-center text-6xl"
data-testId="newOffersToUserProjectsActivityNumber" data-testId="newOffersToUserProjectsActivityNumber"
> >
{{ numNewOffersToUserProjects }} {{ numNewOffersToUserProjects
}}{{ newOffersToUserProjectsHitLimit ? "+" : "" }}
</span> </span>
<p> <p>
new offer{{ numNewOffersToUserProjects === 1 ? "" : "s" }} to your new offer{{ numNewOffersToUserProjects === 1 ? "" : "s" }} to your
@ -461,6 +462,8 @@ export default class HomeView extends Vue {
isRegistered = false; isRegistered = false;
lastAckedOfferToUserJwtId?: string; // the last JWT ID for offer-to-user that they've acknowledged seeing lastAckedOfferToUserJwtId?: string; // the last JWT ID for offer-to-user that they've acknowledged seeing
lastAckedOfferToUserProjectsJwtId?: string; // the last JWT ID for offers-to-user's-projects that they've acknowledged seeing lastAckedOfferToUserProjectsJwtId?: string; // the last JWT ID for offers-to-user's-projects that they've acknowledged seeing
newOffersToUserHitLimit: boolean = false;
newOffersToUserProjectsHitLimit: boolean = false;
numNewOffersToUser: number = 0; // number of new offers-to-user numNewOffersToUser: number = 0; // number of new offers-to-user
numNewOffersToUserProjects: number = 0; // number of new offers-to-user's-projects numNewOffersToUserProjects: number = 0; // number of new offers-to-user's-projects
searchBoxes: Array<{ searchBoxes: Array<{
@ -529,25 +532,25 @@ export default class HomeView extends Vue {
this.updateAllFeed(); this.updateAllFeed();
if (this.activeDid) { if (this.activeDid) {
this.numNewOffersToUser = ( const offersToUserData = await getNewOffersToUser(
await getNewOffersToUser( this.axios,
this.axios, this.apiServer,
this.apiServer, this.activeDid,
this.activeDid, this.lastAckedOfferToUserJwtId,
this.lastAckedOfferToUserJwtId, );
) this.numNewOffersToUser = offersToUserData.data.length;
).length; this.newOffersToUserHitLimit = offersToUserData.hitLimit;
} }
if (this.activeDid) { if (this.activeDid) {
this.numNewOffersToUserProjects = ( const offersToUserProjects = await getNewOffersToUserProjects(
await getNewOffersToUserProjects( this.axios,
this.axios, this.apiServer,
this.apiServer, this.activeDid,
this.activeDid, this.lastAckedOfferToUserProjectsJwtId,
this.lastAckedOfferToUserProjectsJwtId, );
) this.numNewOffersToUserProjects = offersToUserProjects.data.length;
).length; this.newOffersToUserProjectsHitLimit = offersToUserProjects.hitLimit;
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any

24
src/views/NewActivityView.vue

@ -17,7 +17,10 @@
<!-- Display a single row with the name of "New Offers To You" with a count. --> <!-- Display a single row with the name of "New Offers To You" with a count. -->
<div> <div>
<span class="text-lg font-medium">{{ newOffersToUser.length }}</span> <span class="text-lg font-medium"
>{{ newOffersToUser.length
}}{{ newOffersToUserHitLimit ? "+" : "" }}</span
>
<span class="text-lg font-medium ml-4" <span class="text-lg font-medium ml-4"
>New Offer{{ newOffersToUser.length === 1 ? "" : "s" }} To You</span >New Offer{{ newOffersToUser.length === 1 ? "" : "s" }} To You</span
> >
@ -68,9 +71,10 @@
<!-- Display a single row with the name of "New Offers To Your Projects" with a count. --> <!-- Display a single row with the name of "New Offers To Your Projects" with a count. -->
<div class="mt-4"> <div class="mt-4">
<span class="text-lg font-medium">{{ <span class="text-lg font-medium"
newOffersToUserProjects.length >{{ newOffersToUserProjects.length
}}</span> }}{{ newOffersToUserProjectsHitLimit ? "+" : "" }}</span
>
<span class="text-lg font-medium ml-4" <span class="text-lg font-medium ml-4"
>New Offer{{ newOffersToUserProjects.length === 1 ? "" : "s" }} To Your >New Offer{{ newOffersToUserProjects.length === 1 ? "" : "s" }} To Your
Projects</span Projects</span
@ -162,7 +166,9 @@ export default class NewActivityView extends Vue {
lastAckedOfferToUserJwtId = ""; lastAckedOfferToUserJwtId = "";
lastAckedOfferToUserProjectsJwtId = ""; lastAckedOfferToUserProjectsJwtId = "";
newOffersToUser: Array<OfferSummaryRecord> = []; newOffersToUser: Array<OfferSummaryRecord> = [];
newOffersToUserHitLimit = false;
newOffersToUserProjects: Array<OfferToPlanSummaryRecord> = []; newOffersToUserProjects: Array<OfferToPlanSummaryRecord> = [];
newOffersToUserProjectsHitLimit = false;
showOffersDetails = false; showOffersDetails = false;
showOffersToUserProjectsDetails = false; showOffersToUserProjectsDetails = false;
@ -185,18 +191,24 @@ export default class NewActivityView extends Vue {
if (allAccounts.length > 0) { if (allAccounts.length > 0) {
this.allMyDids = allAccounts.map((acc) => acc.did); this.allMyDids = allAccounts.map((acc) => acc.did);
} }
this.newOffersToUser = await getNewOffersToUser(
const offersToUserData = await getNewOffersToUser(
this.axios, this.axios,
this.apiServer, this.apiServer,
this.activeDid, this.activeDid,
this.lastAckedOfferToUserJwtId, this.lastAckedOfferToUserJwtId,
); );
this.newOffersToUserProjects = await getNewOffersToUserProjects( this.newOffersToUser = offersToUserData.data;
this.newOffersToUserHitLimit = offersToUserData.hitLimit;
const offersToUserProjectsData = await getNewOffersToUserProjects(
this.axios, this.axios,
this.apiServer, this.apiServer,
this.activeDid, this.activeDid,
this.lastAckedOfferToUserProjectsJwtId, this.lastAckedOfferToUserProjectsJwtId,
); );
this.newOffersToUserProjects = offersToUserProjectsData.data;
this.newOffersToUserProjectsHitLimit = offersToUserProjectsData.hitLimit;
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) { } catch (err: any) {

2
test-playwright/50-record-offer.spec.ts

@ -72,7 +72,7 @@ test('Record an offer', async ({ page }) => {
// go to the home page and check that the offer is shown as new // go to the home page and check that the offer is shown as new
await page.goto('./'); await page.goto('./');
const offerNumElem = page.getByTestId('newOffersToUserProjectsActivityNumber'); const offerNumElem = page.getByTestId('newOffersToUserProjectsActivityNumber');
await expect(offerNumElem).toHaveText('50'); await expect(offerNumElem).toHaveText('50+');
// click on the number of new offers to go to the list page // click on the number of new offers to go to the list page
await offerNumElem.click(); await offerNumElem.click();

Loading…
Cancel
Save