11import type { Product , ProductPlan } from '@/api/dataclasses/product'
22import { ProductHelpers } from '@/api/dataclasses/product'
3+ import type { Translation } from '@helpwave/common/hooks/useTranslation'
4+
5+ export type CustomerProductStatus =
6+ 'trialing'
7+ | 'active'
8+ | 'activation'
9+ | 'payment'
10+ | 'scheduled'
11+ | 'canceled'
12+ | 'expired'
13+ | 'refunded'
14+
15+ export type CustomerProductStatusTranslation = Record < CustomerProductStatus , string >
16+
17+ export const defaultCustomerProductStatusTranslation : Translation < CustomerProductStatusTranslation > = {
18+ en : {
19+ trialing : 'Trialing' ,
20+ active : 'Active' ,
21+ activation : 'Activation Required' ,
22+ payment : 'Awaiting Payment' ,
23+ scheduled : 'Scheduled Cancelation' ,
24+ canceled : 'Canceled' ,
25+ expired : 'Expired' ,
26+ refunded : 'Refunded'
27+ } ,
28+ de : {
29+ trialing : 'Testphase' ,
30+ active : 'Aktiv' ,
31+ activation : 'Aktivierung erforderlich' ,
32+ payment : 'Zahlung ausstehend' ,
33+ scheduled : 'Geplante Kündingung' ,
34+ canceled : 'Kündigung' ,
35+ expired : 'Abgelaufen' ,
36+ refunded : 'Erstattet'
37+ }
38+ }
339
440export interface CustomerProduct {
541 /** The identifier of the booking
@@ -13,6 +49,8 @@ export interface CustomerProduct {
1349 productUUID : string ,
1450 /** The identifier of the plan for the booked product */
1551 productPlanUUID : string ,
52+ /** The status of the booking */
53+ status : CustomerProductStatus ,
1654 /** The number of seats allocated */
1755 seats ?: number ,
1856 /** The date from which the booking starts */
@@ -44,6 +82,8 @@ export interface ResolvedCustomerProduct {
4482 uuid : string ,
4583 /** The identifier of the customer that booked the product */
4684 customerUUID : string ,
85+ /** The status of the booking */
86+ status : CustomerProductStatus ,
4787 /** The number of seats allocated */
4888 seats ?: number ,
4989 /** The date from which the booking starts */
@@ -67,6 +107,7 @@ function fromJson(json: any): CustomerProduct {
67107 customerUUID : json . customer_uuid ,
68108 productUUID : json . product_uuid ,
69109 productPlanUUID : json . product_plan_uuid ,
110+ status : json . status ,
70111 seats : json . seats ,
71112 startDate : new Date ( json . start_date ) ,
72113 nextPaymentDate : json . next_payment_date ? new Date ( json . next_payment_date ) : undefined ,
@@ -82,6 +123,7 @@ function fromJsonResolvedCustomerProduct(json: any): ResolvedCustomerProduct {
82123 return {
83124 uuid : json . uuid ,
84125 customerUUID : json . customer_uuid ,
126+ status : json . status ,
85127 seats : json . seats ,
86128 startDate : new Date ( json . start_date ) ,
87129 nextPaymentDate : json . next_payment_date ? new Date ( json . next_payment_date ) : undefined ,
@@ -101,6 +143,7 @@ function toJson(customerProduct: CustomerProduct): any {
101143 customer_uuid : customerProduct . customerUUID ,
102144 product_uuid : customerProduct . productUUID ,
103145 product_plan_uuid : customerProduct . productPlanUUID ,
146+ status : customerProduct . status ,
104147 seats : customerProduct . seats ,
105148 start_date : customerProduct . startDate . toISOString ( ) ,
106149 next_payment_date : customerProduct . nextPaymentDate ?. toISOString ( ) ,
0 commit comments