File size: 1,454 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import type { Plan, PlanFeature, FeaturesByType, PlanProduct } from './types';
type setFeaturesAction = {
type: 'SET_FEATURES';
features: Record< string, PlanFeature >;
locale: string;
};
export const setFeatures = (
features: Record< string, PlanFeature >,
locale: string
): setFeaturesAction => ( {
type: 'SET_FEATURES' as const,
features,
locale,
} );
type setFeaturesByTypeAction = {
type: 'SET_FEATURES_BY_TYPE';
featuresByType: Array< FeaturesByType >;
locale: string;
};
export const setFeaturesByType = (
featuresByType: Array< FeaturesByType >,
locale: string
): setFeaturesByTypeAction => ( {
type: 'SET_FEATURES_BY_TYPE' as const,
featuresByType,
locale,
} );
type setPlansAction = {
type: 'SET_PLANS';
plans: Plan[];
locale: string;
};
export const setPlans = ( plans: Plan[], locale: string ): setPlansAction => ( {
type: 'SET_PLANS' as const,
plans,
locale,
} );
type setPlanProductsAction = {
type: 'SET_PLAN_PRODUCTS';
products: PlanProduct[];
};
export const setPlanProducts = ( products: PlanProduct[] ): setPlanProductsAction => ( {
type: 'SET_PLAN_PRODUCTS' as const,
products,
} );
type resetPlanAction = { type: 'RESET_PLAN' };
export const resetPlan = (): resetPlanAction => ( {
type: 'RESET_PLAN' as const,
} );
export type PlanAction = ReturnType<
| typeof setFeatures
| typeof setFeaturesByType
| typeof setPlans
| typeof resetPlan
| typeof setPlanProducts
| ( () => { type: 'NOOP' } )
>;
|