Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 16 additions & 1 deletion src/generated/client/sdk.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
import type { ListQuotesData, ListQuotesResponse, ListPendingQuotesData, ListPendingQuotesResponse, AdminLookupQuoteData, AdminLookupQuoteResponse, AdminUpdateQuoteData, AdminUpdateQuoteResponse, ResolveOfferData, EnquireQuoteData, EnquireQuoteResponse, LookupQuoteData, LookupQuoteResponse, ActivateKeysetData, ActivateKeysetResponse, DebitData, CreditData, ECashBalance, OnChainBalanceData, OnChainData, KeysetInfoData, KeySetInfo, RequestToMintData, RequestToMintResponseInfo, IdentityDetailData, IdentityDetailInfo} from './types.gen';
import type { ListQuotesData, ListQuotesResponse, ListPendingQuotesData, ListPendingQuotesResponse, AdminLookupQuoteData, AdminLookupQuoteResponse, AdminUpdateQuoteData, AdminUpdateQuoteResponse, ResolveOfferData, EnquireQuoteData, EnquireQuoteResponse, LookupQuoteData, LookupQuoteResponse, ActivateKeysetData, ActivateKeysetResponse, DebitData, CreditData, ECashBalance, OnChainBalanceData, OnChainData, KeysetInfoData, KeySetInfo, RequestToMintData, RequestToMintResponseInfo, IdentityDetailData, IdentityDetailInfo, BillPaymentData, BillPaymentState} from './types.gen';

import { client as _heyApiClient } from './client.gen';

Expand Down Expand Up @@ -168,3 +168,18 @@
}
});
};

/**
* --------------------------- BillPaymentStatus
*/

export const paymentStatus = <ThrowOnError extends boolean = false>(options?: Options<BillPaymentData, ThrowOnError>) => {
return (_heyApiClient).get<BillPaymentState, unknown, ThrowOnError>({
url: '/v1/admin/bill/payment_status/{bill_id}',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
};

Check warning on line 185 in src/generated/client/sdk.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/sdk.gen.ts#L176-L185

Added lines #L176 - L185 were not covered by tests
139 changes: 87 additions & 52 deletions src/generated/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,67 +498,102 @@ export type KeysetInfoData = {
};

/**
* Request Mint
*/
* Request Mint
*/

export type RequestToMintRequest = {
ebill_id: string;
amount: number;
};

export type RequestToMintRequest = {
ebill_id: string;
amount: number;
};
export type RequestToMintResponseInfo = {
request_id: string;
request: string;
};

export type RequestToMintResponseInfo = {
request_id: string;
request: string;
};
export type RequestToMintResponse = {
/**
* Successful response
*/
200: RequestToMintResponseInfo;
};

export type RequestToMintResponse = {
/**
export type RequestToMintData = {
body?: RequestToMintRequest;
path?: never;
query?: never;
url: '/v1/admin/treasury/debit/request_to_mint_from_ebill'
};

/**
* Node ID
*/

export type IdentityDetailRequest = {
};

export type IdentityDetailInfo = {
node_id: string;
name: string;
email: string | null;
bitcoin_public_key: string;
npub: string;
postal_address: PostalAddress | null;
date_of_birth: string | null;
country_of_birth: string | null;
city_of_birth: string | null;
identification_number: string | null;
profile_picture_file: string | null;
identity_document_file: string | null;
nostr_relays: Array<string>;
};

export type IdentityDetailResponse = {
/**
* Successful response
*/
200: RequestToMintResponseInfo;
};

export type RequestToMintData = {
body?: RequestToMintRequest;
path?: never;
query?: never;
url: '/v1/admin/treasury/debit/request_to_mint_from_ebill'
};
200: IdentityDetailInfo;
};

/**
* Node ID
*/

export type IdentityDetailRequest = {
};
export type IdentityDetailData = {
body?: never;
path?: never;
query?: never;
url: '/v1/admin/identity/detail'
};

export type IdentityDetailInfo = {
node_id: string;
name: string;
email: string | null;
bitcoin_public_key: string;
npub: string;
postal_address: PostalAddress | null;
date_of_birth: string | null;
country_of_birth: string | null;
city_of_birth: string | null;
identification_number: string | null;
profile_picture_file: string | null;
identity_document_file: string | null;
nostr_relays: Array<string>;
};
/**
* Bill Payment Status
*/

export type BillWaitingForPaymentState = {
time_of_request: number,
currency: string,
sum: string,
link_to_pay: string,
address_to_pay: string,
mempool_link_for_address_to_pay: string,
}

export type IdentityDetailResponse = {
/**
* Successful response
*/
200: IdentityDetailInfo;
};
export type BillPaymentStatus = {
time_of_request_to_pay: number | null,
requested_to_pay: boolean,
paid: boolean,
request_to_pay_timed_out: boolean,
rejected_to_pay: boolean,
}

export type BillPaymentState = {
payment_status: BillPaymentStatus,
payment_details: BillWaitingForPaymentState | null,
}

export type IdentityDetailData = {
body?: never;
path?: never;
query?: never;
url: '/v1/admin/identity/detail'
export type BillPaymentData = {
body?: never;
path: {
bill_id: string;
};
query?: never;
url: '/v1/admin/bill/payment_status/{bill_id}';
};
38 changes: 34 additions & 4 deletions src/pages/quotes/QuotePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
adminLookupQuoteQueryKey,
adminUpdateQuoteMutation,
} from "@/generated/client/@tanstack/react-query.gen"
import { activateKeyset, keysetInfo, requestToMint } from "@/generated/client/sdk.gen"
import { activateKeyset, keysetInfo, paymentStatus, requestToMint } from "@/generated/client/sdk.gen"

Check warning on line 21 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L21

Added line #L21 was not covered by tests
import { cn, getInitials } from "@/lib/utils"
import { formatDate, humanReadableDuration } from "@/utils/dates"

Expand Down Expand Up @@ -222,11 +222,13 @@
isFetching,
newKeyset,
ebillPaid,
requestedToPay,

Check warning on line 225 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L225

Added line #L225 was not covered by tests
}: {
value: InfoReply
isFetching: boolean
newKeyset: boolean
ebillPaid: boolean
requestedToPay: boolean
}) {
const [offerFormData, setOfferFormData] = useState<OfferFormResult>()
const [offerFormDrawerOpen, setOfferFormDrawerOpen] = useState(false)
Expand Down Expand Up @@ -323,7 +325,7 @@
return data
},
onMutate: () => {
toast.loading("Requesting to pay…", { id: `quote-${value.id}-request-to-mint` })
toast.loading("Requesting to pay…", { id: `quote-${value.id}-request-to-pay` })

Check warning on line 328 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L328

Added line #L328 was not covered by tests
},
onSettled: () => {
toast.dismiss(`quote-${value.id}-request-to-pay`)
Expand Down Expand Up @@ -476,7 +478,7 @@
<></>
)}

{value.status === "Accepted" && "keyset_id" in value && !ebillPaid && !newKeyset ? (
{value.status === "Accepted" && "keyset_id" in value && !ebillPaid && !newKeyset && !requestedToPay ? (

Check warning on line 481 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L481

Added line #L481 was not covered by tests
<ConfirmDrawer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit confusing that this button and the confirmation vary between "request to pay" and "request to mint" 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll adjust for consistency

title="Confirm requesting to mint"
description="Are you sure you want to request to mint from this e-bill?"
Expand Down Expand Up @@ -676,6 +678,7 @@
const shouldFetchKeyset = (value.status === "Offered" || value.status === "Accepted") && "keyset_id" in value

const keysetId = "keyset_id" in value ? value.keyset_id : ""
const billId = "bill" in value && "id" in value.bill ? value.bill.id : ""

Check warning on line 681 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L681

Added line #L681 was not covered by tests

const { data: keysetData } = useQuery({
queryKey: ["keyset", keysetId],
Expand All @@ -686,6 +689,17 @@
enabled: shouldFetchKeyset,
})

const { data: paymentData } = useQuery({
Copy link
Preview

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an enabled: !!billId flag to this query to avoid unnecessary network requests when billId is empty.

Copilot uses AI. Check for mistakes.

queryKey: ["bill_id", billId],
queryFn: () =>
paymentStatus({
path: { bill_id: billId },
}),
})

Check warning on line 698 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L692-L698

Added lines #L692 - L698 were not covered by tests

const requestedToPay = paymentData?.data?.payment_status.requested_to_pay ?? false
const paymentAddress = paymentData?.data?.payment_details?.address_to_pay ?? ""

Check warning on line 701 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L700-L701

Added lines #L700 - L701 were not covered by tests

const ebillPaid = keysetData?.data && "active" in keysetData.data && keysetData.data.active === false
const newKeyset = "keyset_id" in value && (!keysetData?.data || !("active" in keysetData.data))

Expand Down Expand Up @@ -727,6 +741,16 @@
) : (
<></>
)}
{requestedToPay ? (
<TableRow>
<TableCell className="font-bold">Payment Address: </TableCell>
<TableCell className="flex items-center gap-2">
<span className="font-mono">{paymentAddress}</span>
</TableCell>
</TableRow>

Check warning on line 750 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L744-L750

Added lines #L744 - L750 were not covered by tests
) : (
<></>

Check warning on line 752 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L752

Added line #L752 was not covered by tests
)}
<TableRow>
<TableCell className="font-bold">Status: </TableCell>
<TableCell>
Expand Down Expand Up @@ -796,7 +820,13 @@
</TableBody>
</Table>

<QuoteActions value={value} isFetching={isFetching} newKeyset={newKeyset} ebillPaid={ebillPaid ?? false} />
<QuoteActions
value={value}
isFetching={isFetching}
newKeyset={newKeyset}
ebillPaid={ebillPaid ?? false}
requestedToPay={requestedToPay ?? false}
/>

Check warning on line 829 in src/pages/quotes/QuotePage.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/quotes/QuotePage.tsx#L823-L829

Added lines #L823 - L829 were not covered by tests
</div>
)
}
Expand Down
Loading