fix list of offers (and some other lists), and add tests for offers

This commit is contained in:
2024-08-12 09:25:01 -06:00
parent 089d4f0733
commit 1fe540d5a8
16 changed files with 71 additions and 28 deletions

View File

@@ -4,6 +4,7 @@
<h1 class="text-xl font-bold text-center mb-4">Offer Help</h1>
<input
type="text"
data-testId="inputDescription"
class="block w-full rounded border border-slate-400 mb-2 px-3 py-2"
placeholder="Description, prerequisites, terms, etc."
v-model="description"
@@ -23,6 +24,7 @@
<fa icon="chevron-left" />
</div>
<input
data-testId="inputOfferAmount"
type="number"
class="w-full border border-r-0 border-slate-400 px-2 py-2 text-center"
v-model="amountInput"

View File

@@ -831,10 +831,16 @@ export default class AccountViewView extends Vue {
* Beware! I've seen where we never get to this point because "ready" never resolves.
*/
} catch (error) {
// this can happen when running automated tests in dev mode because notifications don't work
console.error(
"Telling user to clear cache at page create because:",
error,
);
// this sometimes gives different information on the error
console.error(
"Telling user to clear cache at page create because (error added): " +
error,
);
this.$notify(
{
group: "alert",
@@ -1282,17 +1288,6 @@ export default class AccountViewView extends Vue {
}
} catch (error) {
this.handleRateLimitsError(error);
try {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
isRegistered: false,
});
this.isRegistered = false;
} catch (err) {
console.error("Got an error marking user not registered:", err);
// already set an error notification for the user
}
}
this.loadingLimits = false;

View File

@@ -51,7 +51,10 @@
</div>
<div>
<fa icon="message" class="fa-fw text-slate-400" />
{{ veriClaim.claim?.description }}
{{
veriClaim.claim?.description ||
veriClaim.claim?.itemOffered?.description
}}
</div>
<div>
<fa icon="user" class="fa-fw text-slate-400" />

View File

@@ -271,7 +271,7 @@ export default class ContactAmountssView extends Vue {
// Make the xhr request payload
const payload = JSON.stringify({ jwtEncoded: vcJwt });
const url = this.apiServer + "/api/v2/claim";
const headers = getHeaders(this.activeDid) as AxiosRequestHeaders;
const headers = (await getHeaders(this.activeDid)) as AxiosRequestHeaders;
try {
const resp = await this.axios.post(url, payload, { headers });

View File

@@ -265,6 +265,8 @@ export default class DiscoverView extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.error("Error with feed load:", e);
// this sometimes gives different information
console.error("Error with feed load (error added): " + e);
this.$notify(
{
group: "alert",

View File

@@ -309,7 +309,7 @@ export default class NewEditProjectView extends Vue {
return;
}
try {
const headers = getHeaders(this.activeDid) as AxiosRequestHeaders;
const headers = (await getHeaders(this.activeDid)) as AxiosRequestHeaders;
const response = await this.axios.delete(
DEFAULT_IMAGE_API_SERVER +
"/image/" +

View File

@@ -162,6 +162,7 @@
<div v-if="activeDid && isRegistered" class="mt-4">
<div class="text-center">
<button
data-testId="offerButton"
@click="openOfferDialog()"
class="block w-full text-lg font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md"
>

View File

@@ -396,7 +396,7 @@ export default class ProjectsView extends Vue {
* @param token Authorization token
**/
async offerDataLoader(url: string) {
const headers = getHeaders(this.activeDid);
const headers = await getHeaders(this.activeDid);
try {
this.isLoading = true;
@@ -443,7 +443,7 @@ export default class ProjectsView extends Vue {
async loadMoreOfferData(payload: boolean) {
if (this.offers.length > 0 && payload) {
const latestOffer = this.offers[this.offers.length - 1];
await this.loadOffers(this.activeDid, `&beforeId=${latestOffer.jwtId}`);
await this.loadOffers(`&beforeId=${latestOffer.jwtId}`);
}
}
@@ -452,8 +452,8 @@ export default class ProjectsView extends Vue {
* @param issuerDid of the user
* @param urlExtra additional url parameters in a string
**/
async loadOffers(issuerDid?: string, urlExtra: string = "") {
const url = `${this.apiServer}/api/v2/report/offers?offeredByDid=${issuerDid}${urlExtra}`;
async loadOffers(urlExtra: string = "") {
const url = `${this.apiServer}/api/v2/report/offers?offeredByDid=${this.activeDid}${urlExtra}`;
await this.offerDataLoader(url);
}

View File

@@ -54,9 +54,11 @@
service code underneath. To fix this, first make sure you have latest
version by comparing your version at the bottom of "Help" with the
version at the bottom of https://timesafari.app/help in a browser. After
that, it may eventually work, but you can speed up the process by clearing
your data cache (in the browser on mobile, even if you installed it) and/or
reinstalling the app (after backing up all your data, of course).</p>
that, it may eventually work, but you can speed up the process by
clearing your data cache (in the browser on mobile, even if you
installed it) and/or reinstalling the app (after backing up all your
data, of course).
</p>
</div>
</section>
</template>