|
| 1 | +type StateName = |
| 2 | + | 'lead' |
| 3 | + | 'prospect' |
| 4 | + | 'trial active' |
| 5 | + | 'trial active, yearly dromant' |
| 6 | + | 'yearly active' |
| 7 | + | 'yearly grace period' |
| 8 | + | 'yearly active, yearly dormant' |
| 9 | + | 'monthly active' |
| 10 | + | 'monthly grace period' |
| 11 | +// | 'monthly gift active' |
| 12 | + |
| 13 | +type Trigger = |
| 14 | + | 'activate free trial' |
| 15 | + | 'buy yearly' |
| 16 | + | 'buy monthly' |
| 17 | + | 'buy prolongation' |
| 18 | + | 'redeem monthly gift' |
| 19 | + | 'prolongation auto-payed' |
| 20 | + | 'active period ends' |
| 21 | + | 'grace period ends' |
| 22 | + |
| 23 | +type State = { |
| 24 | + [key in Trigger]?: StateName |
| 25 | +} |
| 26 | + |
| 27 | +type States = { |
| 28 | + [key in StateName]: State |
| 29 | +} |
| 30 | + |
| 31 | +const states: States = { |
| 32 | + lead: { |
| 33 | + 'buy yearly': 'yearly active', |
| 34 | + 'buy monthly': 'monthly active', |
| 35 | + 'activate free trial': 'trial active' |
| 36 | + }, |
| 37 | + prospect: { |
| 38 | + 'buy yearly': 'yearly active', |
| 39 | + 'buy monthly': 'monthly active' |
| 40 | + }, |
| 41 | + 'trial active': { |
| 42 | + 'buy yearly': 'trial active, yearly dromant', |
| 43 | + 'active period ends': 'prospect' |
| 44 | + }, |
| 45 | + 'trial active, yearly dromant': { |
| 46 | + 'active period ends': 'yearly active' |
| 47 | + }, |
| 48 | + 'yearly active': { |
| 49 | + 'active period ends': 'yearly grace period', |
| 50 | + 'buy prolongation': 'yearly active', |
| 51 | + 'buy yearly': 'yearly active, yearly dormant' |
| 52 | + // 'redeem monthly gift' |
| 53 | + }, |
| 54 | + 'yearly active, yearly dormant': { |
| 55 | + 'active period ends': 'yearly active' |
| 56 | + }, |
| 57 | + 'yearly grace period': { |
| 58 | + 'buy prolongation': 'yearly active', |
| 59 | + 'prolongation auto-payed': 'yearly active', |
| 60 | + 'buy yearly': 'yearly active, yearly dormant', |
| 61 | + 'grace period ends': 'prospect' |
| 62 | + }, |
| 63 | + 'monthly active': { |
| 64 | + 'active period ends': 'monthly grace period', |
| 65 | + 'prolongation auto-payed': 'monthly active' |
| 66 | + }, |
| 67 | + 'monthly grace period': { |
| 68 | + 'prolongation auto-payed': 'monthly active', |
| 69 | + 'grace period ends': 'prospect' |
| 70 | + } |
| 71 | +} |
0 commit comments