Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f1ef0df
Remove mocks
stefanbitcr May 21, 2025
525d7cf
Add debit and credit types
stefanbitcr May 21, 2025
f14ccbc
Show balance
stefanbitcr May 21, 2025
e3852ea
Hide earnings and info from side bar
stefanbitcr May 26, 2025
b1921a7
Update payee data type
stefanbitcr May 26, 2025
c41a982
Refresh keycloak
stefanbitcr May 26, 2025
c28cbd4
Display Ecash balance
stefanbitcr May 26, 2025
5ddd9b2
Display anon payee
stefanbitcr May 26, 2025
242c39e
Use generic quote page for different statusses
stefanbitcr May 26, 2025
7a12cc4
Use initials as avatar
stefanbitcr May 26, 2025
cb8cb73
Use correct avatar
stefanbitcr May 26, 2025
c41165a
Update balance page
stefanbitcr May 26, 2025
ae600ad
Remove dev mode
stefanbitcr May 26, 2025
4b1f3ca
Remove dev mode
stefanbitcr May 26, 2025
b98a8a2
Display keycloak user
stefanbitcr May 26, 2025
8cebd48
Display keycloak user
stefanbitcr May 26, 2025
476dda9
Fetch on chain balance
stefanbitcr May 26, 2025
df4abb7
Remove comment
stefanbitcr May 26, 2025
540cfa7
Remove unnecessary import
stefanbitcr May 26, 2025
2d34a18
Only allow keyset activation for accepted quotes
stefanbitcr May 26, 2025
8e41cef
Move functional get Initials to utils
stefanbitcr May 26, 2025
7d38995
Directly set color using bg-
stefanbitcr May 29, 2025
9f72f22
Use BalanceDisplay for consistency
stefanbitcr May 29, 2025
dcba10c
Minor changes
stefanbitcr May 29, 2025
4517455
Use tanstack useQueries and add timeout
stefanbitcr May 29, 2025
099660a
Remove is pending
stefanbitcr May 29, 2025
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
1 change: 0 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
VITE_API_BASE_URL="http://localhost:4242"
VITE_API_MOCKING_ENABLED=false

VITE_KEYCLOAK_URL="http://localhost:8080/"
VITE_KEYCLOAK_REALM="dev"
Expand Down
1 change: 0 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
VITE_API_BASE_URL=http://127.0.0.1:3338
VITE_API_MOCKING_ENABLED=false
56 changes: 5 additions & 51 deletions src/components/AppSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Bitcoin, Home, Inbox, Settings, InfoIcon, LifeBuoy, Send, TrendingUpIcon } from "lucide-react"
import { Bitcoin, Home, Inbox } from "lucide-react"
import { Sidebar, SidebarContent, SidebarFooter, SidebarRail } from "@/components/ui/sidebar"
import { NavUser } from "./nav/NavUser"
import { randomAvatar } from "@/utils/dev"
import { NavMain } from "./nav/NavMain"
import { NavSecondary } from "./nav/NavSecondary"
import { useKeycloak } from "../lib/keycloak-user"

Check warning on line 5 in src/components/AppSidebar.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/AppSidebar.tsx#L5

Added line #L5 was not covered by tests

const data = {
navMain: [
Expand All @@ -17,11 +16,6 @@
url: "/balances",
icon: Bitcoin,
},
{
title: "Earnings",
url: "/earnings",
icon: TrendingUpIcon,
},
{
title: "Quotes",
url: "/quotes",
Expand All @@ -47,60 +41,20 @@
title: "Rejected",
url: "/quotes/rejected",
},
/*{
title: "Expired",
url: "/quotes/expired",
},*/
],
},
{
title: "Settings",
url: "/settings",
icon: Settings,
items: [
{
title: "General",
url: "/settings",
},
],
},
{
title: "Info",
url: "/info",
icon: InfoIcon,
},
],

navSecondary: [
{
title: "Support",
url: "/#",
icon: LifeBuoy,
},
{
title: "Feedback",
url: "/#",
icon: Send,
},
],
}

export function AppSidebar() {
const { user, isLoading } = useKeycloak()

Check warning on line 50 in src/components/AppSidebar.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/AppSidebar.tsx#L50

Added line #L50 was not covered by tests

return (
<Sidebar collapsible="icon">
<SidebarContent>
<NavMain items={data.navMain} />
<NavSecondary items={data.navSecondary} className="mt-auto" />
</SidebarContent>
<SidebarFooter>
<NavUser
user={{
name: "Account",
email: "",
avatar: randomAvatar("women", "0283bf290884eed3a7ca2663fc0260de2e2064d6b355ea13f98dec004b7a7ead99"),
}}
/>
</SidebarFooter>
<SidebarFooter>{!isLoading && user && <NavUser user={user} />}</SidebarFooter>

Check warning on line 57 in src/components/AppSidebar.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/AppSidebar.tsx#L57

Added line #L57 was not covered by tests
<SidebarRail />
</Sidebar>
)
Expand Down
14 changes: 9 additions & 5 deletions src/components/nav/NavUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
}) {
const { isMobile } = useSidebar()

const initials = user.name.length > 0 ? user.name[0].toUpperCase() : "U"

Check warning on line 26 in src/components/nav/NavUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/nav/NavUser.tsx#L26

Added line #L26 was not covered by tests

return (
<SidebarMenu>
<SidebarMenuItem>
Expand All @@ -31,14 +33,16 @@
<SidebarMenuButton
size="lg"
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
tooltip={user.name}
tooltip={user.name || "Unknown User"}

Check warning on line 36 in src/components/nav/NavUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/nav/NavUser.tsx#L36

Added line #L36 was not covered by tests
>
<Avatar className="h-8 w-8 rounded-lg">
<AvatarImage src={user.avatar} alt={user.name} />
<AvatarFallback className="rounded-lg">{user.name}</AvatarFallback>
<div className="w-full h-full flex items-center justify-center text-white font-semibold text-sm bg-[#f59e0b]">
{initials}
</div>

Check warning on line 41 in src/components/nav/NavUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/nav/NavUser.tsx#L39-L41

Added lines #L39 - L41 were not covered by tests
</Avatar>

<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-semibold">{user.name}</span>
<span className="truncate font-semibold">{user.name || "Unknown User"}</span>

Check warning on line 45 in src/components/nav/NavUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/nav/NavUser.tsx#L45

Added line #L45 was not covered by tests
<span className="truncate text-xs">{user.email}</span>
</div>
<ChevronsUpDown className="ml-auto size-4" />
Expand All @@ -57,7 +61,7 @@
<AvatarFallback className="rounded-lg">CN</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-semibold">{user.name}</span>
<span className="truncate font-semibold">{user.name || "Unknown User"}</span>

Check warning on line 64 in src/components/nav/NavUser.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/nav/NavUser.tsx#L64

Added line #L64 was not covered by tests
<span className="truncate text-xs">{user.email}</span>
</div>
</div>
Expand Down
40 changes: 37 additions & 3 deletions src/generated/client/@tanstack/react-query.gen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// This file is auto-generated by @hey-api/openapi-ts

import { type Options, listQuotes, listPendingQuotes, adminLookupQuote, adminUpdateQuote, resolveOffer, enquireQuote, lookupQuote } from '../sdk.gen';
import { type Options, listQuotes, listPendingQuotes, adminLookupQuote, adminUpdateQuote, resolveOffer, enquireQuote, lookupQuote, debitBalance, creditBalance } from '../sdk.gen';

Check warning on line 3 in src/generated/client/@tanstack/react-query.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/@tanstack/react-query.gen.ts#L3

Added line #L3 was not covered by tests
import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query';
import type { ListQuotesData, ListPendingQuotesData, AdminLookupQuoteData, AdminUpdateQuoteData, AdminUpdateQuoteResponse, ResolveOfferData, EnquireQuoteData, EnquireQuoteResponse, LookupQuoteData } from '../types.gen';
import type { ListQuotesData, ListPendingQuotesData, AdminLookupQuoteData, AdminUpdateQuoteData, AdminUpdateQuoteResponse, ResolveOfferData, EnquireQuoteData, EnquireQuoteResponse, LookupQuoteData, DebitData} from '../types.gen';
import { client as _heyApiClient } from '../client.gen';

export type QueryKey<TOptions extends Options> = [
Expand Down Expand Up @@ -195,4 +195,38 @@
},
queryKey: lookupQuoteQueryKey(options)
});
};
};

Check warning on line 198 in src/generated/client/@tanstack/react-query.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/@tanstack/react-query.gen.ts#L198

Added line #L198 was not covered by tests

export const debitBalanceQueryKey = (options?: Options<DebitData>) => createQueryKey('debitBalance', options);

Check warning on line 200 in src/generated/client/@tanstack/react-query.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/@tanstack/react-query.gen.ts#L200

Added line #L200 was not covered by tests

export const debitBalanceOptions = (options?: Options<DebitData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await debitBalance({
...options,
...queryKey[0],
signal,
throwOnError: true
});
return data;
},
queryKey: debitBalanceQueryKey(options)
});
};

Check warning on line 215 in src/generated/client/@tanstack/react-query.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/@tanstack/react-query.gen.ts#L202-L215

Added lines #L202 - L215 were not covered by tests

export const creditBalanceQueryKey = (options?: Options<DebitData>) => createQueryKey('creditBalance', options);

Check warning on line 217 in src/generated/client/@tanstack/react-query.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/@tanstack/react-query.gen.ts#L217

Added line #L217 was not covered by tests

export const creditBalanceOptions = (options?: Options<DebitData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await creditBalance({
...options,
...queryKey[0],
signal,
throwOnError: true
});
return data;
},
queryKey: creditBalanceQueryKey(options)
});
};

Check warning on line 232 in src/generated/client/@tanstack/react-query.gen.ts

View check run for this annotation

Codecov / codecov/patch

src/generated/client/@tanstack/react-query.gen.ts#L219-L232

Added lines #L219 - L232 were not covered by tests
30 changes: 28 additions & 2 deletions 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 } 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} from './types.gen';
import { client as _heyApiClient } from './client.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
Expand Down Expand Up @@ -98,4 +98,30 @@
...options?.headers
}
});
};
};

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

View check run for this annotation

Codecov / codecov/patch

src/generated/client/sdk.gen.ts#L101

Added line #L101 was not covered by tests


/**
* --------------------------- Balance Check
*/

export const debitBalance = <ThrowOnError extends boolean = false>(options: Options<DebitData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).get<ECashBalance, unknown, ThrowOnError>({
url: '/v1/admin/balance/debit',
...options
});
};

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

View check run for this annotation

Codecov / codecov/patch

src/generated/client/sdk.gen.ts#L108-L113

Added lines #L108 - L113 were not covered by tests

export const creditBalance = <ThrowOnError extends boolean = false>(options: Options<CreditData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).get<ECashBalance, unknown, ThrowOnError>({
url: '/v1/admin/balance/credit',
...options
});
};

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

View check run for this annotation

Codecov / codecov/patch

src/generated/client/sdk.gen.ts#L115-L120

Added lines #L115 - L120 were not covered by tests

export const onchainBalance = <ThrowOnError extends boolean = false>(options: Options<OnChainData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).get<OnChainBalanceData, unknown, ThrowOnError>({
url: '/v1/admin/onchain/balance',
...options
});
};

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

View check run for this annotation

Codecov / codecov/patch

src/generated/client/sdk.gen.ts#L122-L127

Added lines #L122 - L127 were not covered by tests
60 changes: 58 additions & 2 deletions src/generated/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export type ListReplyLight = {
*/
export type Amount = number;


export type PayeePublicData = {
Ident: IdentityPublicData;
} | {
Anon: AnonPublicData;
};


/**
* --------------------------- Enquire mint quote
*/
Expand All @@ -36,7 +44,7 @@ export type BillInfo = {
endorsees: Array<IdentityPublicData>;
id: string;
maturity_date: string;
payee: IdentityPublicData;
payee: PayeePublicData;
sum: number;
};

Expand Down Expand Up @@ -109,6 +117,12 @@ export type IdentityPublicData = PostalAddress & {
type: ContactType;
};

export type AnonPublicData = {
node_id: string;
email?: string | null;
nostr_relays: Array<string>;
}

/**
* --------------------------- Quote info request
*/
Expand Down Expand Up @@ -405,4 +419,46 @@ export type ActivateKeysetResponses = {
200: unknown;
};

export type ActivateKeysetResponse = ActivateKeysetResponses[keyof ActivateKeysetResponses];
export type ActivateKeysetResponse = ActivateKeysetResponses[keyof ActivateKeysetResponses];

/**
* Currency unit used for ECash
*/
export type CurrencyUnit = string;

/**
* ECash balance information
*/
export type ECashBalance = {
amount: Amount;
unit: CurrencyUnit;
};

export type DebitData = {
body?: never;
path?: never;
query?: never;
url: '/v1/admin/balance/debit';
};

export type CreditData = {
body?: never;
path?: never;
query?: never;
url: '/v1/admin/balance/credit';
};

export type OnChainBalanceData = {
immature: number;
trusted_pending: number;
untrusted_pending: number;
confirmed: number;
};


export type OnChainData = {
body?: never;
path?: never;
query?: never;
url: '/v1/admin/onchain/balance';
};
12 changes: 12 additions & 0 deletions src/lib/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,17 @@
return request
})

const originalFetch = window.fetch
window.fetch = async function (...args) {
try {
console.log("Refreshing token...")
await keycloak.updateToken(30)
} catch (error) {
console.error("Failed to refresh token:", error)
}

Check warning on line 33 in src/lib/api-client.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/api-client.ts#L26-L33

Added lines #L26 - L33 were not covered by tests

return originalFetch.apply(this, args)
}

Check warning on line 36 in src/lib/api-client.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/api-client.ts#L35-L36

Added lines #L35 - L36 were not covered by tests

export const client = heyApiClient
export { sdk }
Loading