(params: {
status: string;
cancelAtPeriodEnd: boolean;
currentPeriodEnd: string;
creditRenewalAt: string;
paymentGraceExpiresAt: string | null;
canceledAt: string | null;
})
| 26 | } |
| 27 | |
| 28 | export function getCodingPlanBillingDate(params: { |
| 29 | status: string; |
| 30 | cancelAtPeriodEnd: boolean; |
| 31 | currentPeriodEnd: string; |
| 32 | creditRenewalAt: string; |
| 33 | paymentGraceExpiresAt: string | null; |
| 34 | canceledAt: string | null; |
| 35 | }): { label: string; date: string } { |
| 36 | if (params.status === 'canceled') { |
| 37 | return { label: 'Ended at', date: params.canceledAt ?? params.currentPeriodEnd }; |
| 38 | } |
| 39 | |
| 40 | if (params.status === 'past_due') { |
| 41 | return { |
| 42 | label: 'Grace expires', |
| 43 | date: params.paymentGraceExpiresAt ?? params.currentPeriodEnd, |
| 44 | }; |
| 45 | } |
| 46 | |
| 47 | if (params.cancelAtPeriodEnd) { |
| 48 | return { label: 'Access ends', date: params.currentPeriodEnd }; |
| 49 | } |
| 50 | |
| 51 | return { label: 'Renews at', date: params.creditRenewalAt }; |
| 52 | } |
| 53 | |
| 54 | export function getCodingPlanPriceParts( |
| 55 | costKiloCredits: number, |
no outgoing calls
no test coverage detected