Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 35 additions & 157 deletions apps/api/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1632,22 +1632,14 @@
},
{
"schema": {
"type": "string",
"description": "ID of the last transaction from the previous page (if paginating forwards)",
"example": "ch_1234567890"
},
"required": false,
"name": "startingAfter",
"in": "query"
},
{
"schema": {
"type": "string",
"description": "ID of the first transaction from the previous page (if paginating backwards)",
"example": "ch_0987654321"
"type": "number",
"description": "Number of transactions to skip for pagination",
"minimum": 0,
"example": 0,
"default": 0
},
"required": false,
"name": "endingBefore",
"name": "offset",
"in": "query"
},
{
Expand Down Expand Up @@ -1692,9 +1684,20 @@
"id": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"payment_intent",
"coupon_claim",
"manual_credit"
]
},
"amount": {
"type": "number"
},
"amountRefunded": {
"type": "number"
},
"bonusAmount": {
"type": "number"
},
Expand All @@ -1707,136 +1710,17 @@
"created": {
"type": "number"
},
"paymentMethod": {
"type": "object",
"nullable": true,
"properties": {
"type": {
"type": "string"
},
"validated": {
"type": "boolean"
},
"isDefault": {
"type": "boolean"
},
"card": {
"type": "object",
"nullable": true,
"properties": {
"brand": {
"type": "string",
"nullable": true
},
"last4": {
"type": "string",
"nullable": true
},
"exp_month": {
"type": "number"
},
"exp_year": {
"type": "number"
},
"funding": {
"type": "string",
"nullable": true
},
"country": {
"type": "string",
"nullable": true
},
"network": {
"type": "string",
"nullable": true
},
"three_d_secure_usage": {
"type": "object",
"nullable": true,
"properties": {
"supported": {
"type": "boolean",
"nullable": true
}
}
}
},
"required": [
"brand",
"last4",
"exp_month",
"exp_year"
]
},
"link": {
"type": "object",
"nullable": true,
"properties": {
"email": {
"type": "string",
"nullable": true
}
}
},
"billing_details": {
"type": "object",
"properties": {
"address": {
"type": "object",
"nullable": true,
"properties": {
"city": {
"type": "string",
"nullable": true
},
"country": {
"type": "string",
"nullable": true
},
"line1": {
"type": "string",
"nullable": true
},
"line2": {
"type": "string",
"nullable": true
},
"postal_code": {
"type": "string",
"nullable": true
},
"state": {
"type": "string",
"nullable": true
}
},
"required": [
"city",
"country",
"line1",
"line2",
"postal_code",
"state"
]
},
"email": {
"type": "string",
"nullable": true
},
"name": {
"type": "string",
"nullable": true
},
"phone": {
"type": "string",
"nullable": true
}
}
}
},
"required": [
"type"
]
"cardBrand": {
"type": "string",
"nullable": true
},
"cardLast4": {
"type": "string",
"nullable": true
},
"stripeInvoiceId": {
"type": "string",
"nullable": true
},
"receiptUrl": {
"type": "string",
Expand All @@ -1845,35 +1729,29 @@
"description": {
"type": "string",
"nullable": true
},
"metadata": {
"type": "object",
"nullable": true,
"additionalProperties": {
"type": "string"
}
}
},
"required": [
"id",
"type",
"amount",
"amountRefunded",
"currency",
"status",
"created",
"paymentMethod"
"created"
]
}
},
"totalCount": {
"type": "number"
},
"hasMore": {
"type": "boolean"
},
"nextPage": {
"type": "string",
"nullable": true
}
},
"required": [
"transactions",
"totalCount",
"hasMore"
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from "react";
import type { BillingTransaction } from "@akashnetwork/http-sdk";
import { ApiError } from "@akashnetwork/openapi-sdk";
import type { PaginationState } from "@tanstack/react-table";
import type { AxiosError } from "axios";
import { describe, expect, it, type MockedFunction, vi } from "vitest";
import { mock } from "vitest-mock-extended";

import type { usePaymentTransactionsQuery } from "@src/queries";
import type { BillingTransaction, usePaymentTransactionsQuery } from "@src/queries";
import type { ChildrenProps } from "./BillingContainer";
import { BillingContainer } from "./BillingContainer";

Expand All @@ -28,12 +26,9 @@ describe(BillingContainer.name, () => {
expect(child.isError).toBe(true);
});

it("passes error object if queryError is axios error", async () => {
const axiosError = mock<AxiosError>({
isAxiosError: true,
response: { data: { message: "fail" } }
});
const { child } = await setup({ queryError: axiosError });
it("surfaces the API error message when the query fails", async () => {
const apiError = new ApiError(500, { message: "fail" }, "GET /v1/stripe/transactions → 500");
const { child } = await setup({ queryError: apiError });
expect(child.errorMessage).toBe("fail");
});

Expand Down Expand Up @@ -69,7 +64,7 @@ describe(BillingContainer.name, () => {
data: { transactions: BillingTransaction[]; hasMore: boolean; totalCount: number };
isFetching: boolean;
isError: boolean;
queryError: AxiosError;
queryError: Error;
}> = {}
) {
const useDefaultData = !Object.prototype.hasOwnProperty.call(overrides, "data");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useState } from "react";
import type { BillingTransaction } from "@akashnetwork/http-sdk";
import { ApiError, extractApiErrorMessage } from "@akashnetwork/openapi-sdk";
import { useToast } from "@akashnetwork/ui/hooks";
import type { PaginationState } from "@tanstack/react-table";
import axios from "axios";

import { useServices } from "@src/context/ServicesProvider";
import type { BillingTransaction } from "@src/queries";
import { usePaymentTransactionsQuery } from "@src/queries";
import { createDateRange } from "@src/utils/dateUtils";
import { downloadCsv } from "@src/utils/domUtils";
Expand Down Expand Up @@ -56,8 +57,8 @@ export const BillingContainer: React.FC<BillingContainerProps> = ({ children, de
});

React.useEffect(() => {
if (axios.isAxiosError(queryError)) {
setErrorMessage(queryError.response?.data.message || "An error occurred while fetching payment transactions.");
if (queryError instanceof ApiError) {
setErrorMessage(extractApiErrorMessage(queryError) || "An error occurred while fetching payment transactions.");
}
}, [queryError]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import type { BillingTransaction } from "@akashnetwork/http-sdk";
import { TooltipProvider } from "@akashnetwork/ui/components";
import { describe, expect, it, vi } from "vitest";

import type { BillingTransaction } from "@src/queries";
import type { BillingViewProps } from "./BillingView";
import { BillingView } from "./BillingView";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import { FormattedNumber } from "react-intl";
import type { BillingTransaction } from "@akashnetwork/http-sdk";
import {
Alert,
AlertDescription,
Expand Down Expand Up @@ -32,6 +31,7 @@ import { Download, Page } from "iconoir-react";
import Link from "next/link";

import { Title } from "@src/components/shared/Title";
import type { BillingTransaction } from "@src/queries";
import { capitalizeFirstLetter } from "@src/utils/stringUtils";

export const COMPONENTS = {
Expand Down Expand Up @@ -113,7 +113,7 @@ export const BillingView: React.FC<BillingViewProps> = ({
<div>
<span
className={cn(
"inline-flex items-center justify-center rounded-full px-2 py-1 text-xs font-semibold",
"inline-flex items-center justify-center rounded-full px-2 py-0.5 text-xs font-semibold",
TRANSACTION_TYPE_BADGE_CLASSES[type] ?? DEFAULT_TRANSACTION_TYPE_BADGE_CLASS
)}
>
Expand Down Expand Up @@ -162,7 +162,7 @@ export const BillingView: React.FC<BillingViewProps> = ({
cell: info => (
<div
className={cn(
"inline-flex items-center justify-center rounded-full px-2 py-1 text-xs font-semibold",
"inline-flex items-center justify-center rounded-full px-2 py-0.5 text-xs font-semibold",
STATUS_BADGE_CLASSES[info.getValue()] ?? DEFAULT_STATUS_BADGE_CLASS
)}
>
Expand Down
Loading