Skip to content

Commit 736da68

Browse files
committed
move SubscriberProfile creation to util file
1 parent 07e3e2a commit 736da68

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/utils/utils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import maestro from '@app/assets/images/card-issuers/maestro.png';
66
import { CurrencyTypeEnum, Severity } from '@app/interfaces/interfaces';
77
import { BaseBadgeProps } from '@app/components/common/BaseBadge/BaseBadge';
88
import { currencies } from '@app/constants/config/currencies';
9-
9+
import { NDKUserProfile } from '@nostr-dev-kit/ndk';
10+
import { SubscriberProfile } from '@app/hooks/usePaidSubscribers';
1011
export const camelize = (string: string): string => {
1112
return string
1213
.split(' ')
@@ -21,7 +22,14 @@ export const getSatsCurrency = (price: number | string, currency: CurrencyTypeEn
2122
// Handle potential negative sign placement
2223
return isIcon ? `${currencySymbol}${formattedPrice}` : `${formattedPrice} ${currency}`;
2324
};
24-
25+
export const convertNDKUserProfileToSubscriberProfile = (pubkey: string, user: NDKUserProfile): SubscriberProfile => {
26+
return {
27+
pubkey,
28+
name: user.name || '',
29+
picture: user.picture || '',
30+
about: user.about || '',
31+
};
32+
};
2533

2634
export const getCurrencyPrice = (price: number | string, currency: CurrencyTypeEnum, isIcon = true): string => {
2735
const currencySymbol = currencies[currency][isIcon ? 'icon' : 'text'];

0 commit comments

Comments
 (0)