Skip to content

Commit 1f9eedb

Browse files
committed
Add comprehensive comments and documentation to shared helpers
1 parent a3efd12 commit 1f9eedb

4 files changed

Lines changed: 138 additions & 0 deletions

File tree

src/helpers/profile_helpers.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Profile-related constants and business logic that works across React Native and Web
3+
*/
4+
5+
/**
6+
* Helper class containing profile type constants and related utilities
7+
*/
8+
export class ProfileHelpers {
9+
/**
10+
* Map of profile type keys to their display names
11+
* Used throughout the application to identify and display different profile types
12+
*/
13+
static profileTypes = {
14+
model: 'Model',
15+
photo: 'Photographer',
16+
makeUp: 'Make-up Artist',
17+
hair: 'Hair Stylist',
18+
video: 'Videographer',
19+
influencer: 'Influencer',
20+
stylist: 'Stylist',
21+
prop: 'Prop Stylist',
22+
manicurist: 'Manicurist',
23+
parts: 'Hand / Foot Model',
24+
studio: 'Rental Studio',
25+
retoucher: 'Retoucher',
26+
producer: 'Producer',
27+
creative: 'Creative Director',
28+
casting: 'Casting Director',
29+
designer: 'Designer',
30+
eComManager: 'E-Commerce Manager',
31+
studioManager: 'Studio Manager',
32+
other: 'Other',
33+
}
34+
}

src/helpers/stripe_helpers.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,105 @@
22
* Stripe-related business logic that works across React Native and Web
33
*/
44

5+
/**
6+
* Represents a Stripe card payment method
7+
*/
58
export interface StripeCard {
9+
/** Card brand (e.g., 'visa', 'mastercard', 'american express') */
610
brand: string;
11+
/** Last 4 digits of the card number */
712
last4?: string;
13+
/** Expiration month (1-12) */
814
exp_month?: number;
15+
/** Expiration year (4 digits) */
916
exp_year?: number;
1017
}
1118

19+
/**
20+
* Represents a Stripe US bank account payment method
21+
*/
1222
export interface StripeUSBankAccount {
23+
/** Name of the bank */
1324
bank_name: string;
25+
/** Last 4 digits of the account number */
1426
last4: string;
1527
}
1628

29+
/**
30+
* Represents a Stripe payment method object as returned by the API
31+
*/
1732
export interface StripePaymentMethod {
1833
data: {
34+
/** Type of payment method */
1935
type: 'card' | 'us_bank_account';
36+
/** Card details if type is 'card' */
2037
card?: StripeCard;
38+
/** US bank account details if type is 'us_bank_account' */
2139
us_bank_account?: StripeUSBankAccount;
2240
};
2341
}
2442

43+
/**
44+
* Represents a default payment method from Stripe customer invoice settings
45+
*/
2546
export interface StripeDefaultPaymentMethod {
47+
/** Payment method ID */
2648
id: string;
49+
/** Type of payment method */
2750
type: 'card' | 'us_bank_account';
51+
/** Stripe object type */
2852
object?: string;
53+
/** Card details if type is 'card' */
2954
card?: StripeCard;
55+
/** US bank account details if type is 'us_bank_account' */
3056
us_bank_account?: StripeUSBankAccount;
3157
}
3258

59+
/**
60+
* Represents a Stripe customer object as returned by the API
61+
*/
3362
export interface StripeCustomer {
3463
data: {
64+
/** Invoice settings containing default payment method */
3565
invoice_settings?: {
66+
/** Default payment method for invoices */
3667
default_payment_method?: StripeDefaultPaymentMethod;
3768
};
69+
/** Legacy card sources (deprecated in favor of payment methods) */
3870
sources?: {
71+
/** Array of card sources */
3972
data: Array<StripeCard & { id?: string; object?: string }>;
4073
};
4174
};
4275
}
4376

77+
/**
78+
* Normalized payment method object used internally in the application
79+
*/
4480
export interface CustomerDefaultPaymentMethod {
81+
/** Whether this is a payment method (true) or legacy source (false) */
4582
isPaymentMethod: boolean;
83+
/** Formatted display label for the payment method */
4684
label: string;
85+
/** Last 4 digits of the card or account */
4786
last4: string;
87+
/** Expiration month (for cards only) */
4888
expMonth?: number;
89+
/** Expiration year (for cards only) */
4990
expYear?: number;
91+
/** Bank name (for US bank accounts only) */
5092
bankName?: string;
93+
/** Card brand (for cards only) */
5194
brand?: string;
95+
/** Payment method or source ID */
5296
id: string;
97+
/** Stripe object type */
5398
object: string;
5499
}
55100

101+
/**
102+
* Helper class containing Stripe-related business logic and formatting utilities
103+
*/
56104
export class StripeHelpers {
57105
/**
58106
* Returns a formatted card brand label. Abbreviates "American Express" to "Amex".

src/helpers/user_helpers.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* User-related business logic that works across React Native and Web
3+
*/
4+
5+
import { ProfileHelpers } from './profile_helpers'
6+
7+
/**
8+
* User interface representing user data structure
9+
*/
10+
export interface User {
11+
/** Whether the user is on a waitlist */
12+
waitlisted?: boolean
13+
/** Array of user profiles, each containing a profile type */
14+
profiles?: Array<{
15+
/** The type of profile (e.g., 'Model', 'Photographer', etc.) */
16+
profile_type: string
17+
}>
18+
}
19+
20+
/**
21+
* Helper class containing user-related business logic utilities
22+
*/
23+
export class UserHelpers {
24+
/**
25+
* Determines if a user is eligible for the Digital Content Creator (DCC) flow
26+
* A user is eligible if they are waitlisted and have a profile type that qualifies as a digital content creator
27+
* @param user - The user object to check for DCC eligibility
28+
* @returns true if the user is eligible for DCC flow, false otherwise
29+
*/
30+
static dccEligible(user: User): boolean {
31+
if (!user.waitlisted || !user.profiles?.length) return false
32+
33+
const profileType = user.profiles[0].profile_type
34+
const digitalContentCreatorProfiles = [
35+
ProfileHelpers.profileTypes.photo,
36+
ProfileHelpers.profileTypes.hair,
37+
ProfileHelpers.profileTypes.makeUp,
38+
ProfileHelpers.profileTypes.stylist,
39+
ProfileHelpers.profileTypes.model,
40+
ProfileHelpers.profileTypes.influencer,
41+
ProfileHelpers.profileTypes.video,
42+
ProfileHelpers.profileTypes.manicurist,
43+
ProfileHelpers.profileTypes.prop,
44+
ProfileHelpers.profileTypes.parts,
45+
]
46+
47+
return digitalContentCreatorProfiles.includes(profileType)
48+
}
49+
}

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
/**
2+
* Shared utilities and helpers that work across React Native and Web platforms
3+
* This module exports all helper classes and their associated types/interfaces
4+
*/
5+
16
export * from './helpers/stripe_helpers';
7+
export * from './helpers/profile_helpers';
8+
export * from './helpers/user_helpers';

0 commit comments

Comments
 (0)