Skip to content

Commit 06e2639

Browse files
authored
Display Node ID (#69)
* Fetch identity detail * Check if data not null * Display identity detail information * Make email DOB and postal address optional from identity * Remove unused import * Handle error case * Update changelog
1 parent e35e957 commit 06e2639

File tree

4 files changed

+139
-22
lines changed

4 files changed

+139
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# 0.1.0
22

33
* Initial version
4+
5+
# 0.1.1
6+
7+
* Add request to pay eBill button
8+
* Display Node ID on Home

src/generated/client/sdk.gen.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

33
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
4-
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} from './types.gen';
4+
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';
55

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

@@ -152,3 +152,19 @@ export const requestToMint = <ThrowOnError extends boolean = false>(options: Opt
152152
}
153153
});
154154
};
155+
156+
157+
/**
158+
* --------------------------- IdentityDetail
159+
*/
160+
161+
export const identityDetail = <ThrowOnError extends boolean = false>(options?: Options<IdentityDetailData, ThrowOnError>) => {
162+
return (_heyApiClient).get<IdentityDetailInfo, unknown, ThrowOnError>({
163+
url: '/v1/admin/identity/detail',
164+
...options,
165+
headers: {
166+
'Content-Type': 'application/json',
167+
...options?.headers
168+
}
169+
});
170+
};

src/generated/client/types.gen.ts

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,6 @@ export type KeysetInfoData = {
501501
* Request Mint
502502
*/
503503

504-
// pub struct RequestToMintFromEBillRequest {
505-
// pub ebill_id: String,
506-
// pub amount: Amount,
507-
// }
508-
509504
export type RequestToMintRequest = {
510505
ebill_id: string;
511506
amount: number;
@@ -529,3 +524,41 @@ export type KeysetInfoData = {
529524
query?: never;
530525
url: '/v1/admin/treasury/debit/request_to_mint_from_ebill'
531526
};
527+
528+
/**
529+
* Node ID
530+
*/
531+
532+
export type IdentityDetailRequest = {
533+
};
534+
535+
export type IdentityDetailInfo = {
536+
node_id: string;
537+
name: string;
538+
email: string | null;
539+
bitcoin_public_key: string;
540+
npub: string;
541+
postal_address: PostalAddress | null;
542+
date_of_birth: string | null;
543+
country_of_birth: string | null;
544+
city_of_birth: string | null;
545+
identification_number: string | null;
546+
profile_picture_file: string | null;
547+
identity_document_file: string | null;
548+
nostr_relays: Array<string>;
549+
};
550+
551+
export type IdentityDetailResponse = {
552+
/**
553+
* Successful response
554+
*/
555+
200: IdentityDetailInfo;
556+
};
557+
558+
559+
export type IdentityDetailData = {
560+
body?: never;
561+
path?: never;
562+
query?: never;
563+
url: '/v1/admin/identity/detail'
564+
};

src/pages/home/HomePage.tsx

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PageTitle } from "@/components/PageTitle"
22
import { Skeleton } from "@/components/ui/skeleton"
3-
// import { fetchInfo } from "@/lib/api"
4-
// import { useSuspenseQuery } from "@tanstack/react-query"
3+
import { identityDetail } from "@/generated/client/sdk.gen"
4+
import { useSuspenseQuery } from "@tanstack/react-query"
55
import { Suspense } from "react"
66

77
function Loader() {
@@ -13,25 +13,88 @@ function Loader() {
1313
}
1414

1515
function PageBody() {
16-
// const { data } = []; useSuspenseQuery({
17-
// queryKey: ["info"],
18-
// queryFn: fetchInfo,
19-
// })
16+
const { data } = useSuspenseQuery({
17+
queryKey: ["identity-detail"],
18+
queryFn: async () => {
19+
const response = await identityDetail()
20+
return response.data ?? null
21+
},
22+
staleTime: Infinity,
23+
gcTime: Infinity,
24+
})
2025

21-
const data = {
22-
name: "bcr-wdc-quote-service",
23-
version: "0.1.0",
24-
pubkey: "0283bf290884eed3a7ca2663fc0260de2e2064d6b355ea13f98dec004b7a7ead99",
26+
if (!data) {
27+
return (
28+
<div className="bg-card text-card-foreground rounded-lg border p-6">
29+
<div className="text-center text-muted-foreground">No identity found</div>
30+
</div>
31+
)
2532
}
2633

2734
return (
28-
<>
29-
<div className="flex flex-col gap-0.5 bg-accent text-accent-foreground rounded-lg p-2 my-2">
30-
<span className="font-bold">{data.name}</span>
31-
<span className="text-sm font-mono text-accent-foreground/50">{data.version}</span>
32-
<span className="text-sm font-mono">{data.pubkey}</span>
35+
<div className="flex flex-col gap-4">
36+
<div className="bg-card text-card-foreground rounded-lg border p-6">
37+
<h3 className="text-lg font-semibold mb-4">Information</h3>
38+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
39+
<div className="flex flex-col gap-1">
40+
<span className="text-xs text-muted-foreground uppercase tracking-wide font-medium">Name</span>
41+
<span className="font-semibold text-base">{data.name}</span>
42+
</div>
43+
{data.email && (
44+
<div className="flex flex-col gap-1">
45+
<span className="text-xs text-muted-foreground uppercase tracking-wide font-medium">Email</span>
46+
<span className="font-mono text-sm text-muted-foreground">{data.email}</span>
47+
</div>
48+
)}
49+
{data.date_of_birth && (
50+
<div className="flex flex-col gap-1">
51+
<span className="text-xs text-muted-foreground uppercase tracking-wide font-medium">Date of Birth</span>
52+
<span className="text-sm">{data.date_of_birth}</span>
53+
</div>
54+
)}
55+
</div>
3356
</div>
34-
</>
57+
58+
<div className="bg-card text-card-foreground rounded-lg border p-6">
59+
<h3 className="text-lg font-semibold mb-4">Keys</h3>
60+
<div className="flex flex-col gap-4">
61+
<div className="flex flex-col gap-1">
62+
<span className="text-xs text-muted-foreground uppercase tracking-wide font-medium">Node ID</span>
63+
<span className="font-mono text-sm break-all bg-muted p-2 rounded text-muted-foreground">
64+
{data.node_id}
65+
</span>
66+
</div>
67+
<div className="flex flex-col gap-1">
68+
<span className="text-xs text-muted-foreground uppercase tracking-wide font-medium">
69+
Bitcoin Public Key
70+
</span>
71+
<span className="font-mono text-sm break-all bg-muted p-2 rounded text-muted-foreground">
72+
{data.bitcoin_public_key}
73+
</span>
74+
</div>
75+
<div className="flex flex-col gap-1">
76+
<span className="text-xs text-muted-foreground uppercase tracking-wide font-medium">Nostr Public Key</span>
77+
<span className="font-mono text-sm break-all bg-muted p-2 rounded text-muted-foreground">{data.npub}</span>
78+
</div>
79+
</div>
80+
</div>
81+
82+
{data.postal_address && (
83+
<div className="bg-card text-card-foreground rounded-lg border p-6">
84+
<h3 className="text-lg font-semibold mb-4">Address</h3>
85+
<div className="flex flex-col gap-1">
86+
<div className="text-sm leading-relaxed">
87+
<div className="font-medium">{data.postal_address.address}</div>
88+
<div className="text-muted-foreground">
89+
{data.postal_address.city}
90+
{data.postal_address.zip && `, ${data.postal_address.zip}`}
91+
</div>
92+
<div className="text-muted-foreground">{data.postal_address.country}</div>
93+
</div>
94+
</div>
95+
</div>
96+
)}
97+
</div>
3598
)
3699
}
37100

0 commit comments

Comments
 (0)