mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
feat: upgrade the subscription plans
This commit is contained in:
@@ -1,17 +1,35 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import { MapStateToProps, connect } from 'react-redux';
|
||||
import {
|
||||
getPlansPeriodSelector,
|
||||
getPlansSelector,
|
||||
} from '@/store/plans/plans.selectors';
|
||||
import { ApplicationState } from '@/store/reducers';
|
||||
|
||||
export default (mapState) => {
|
||||
const mapStateToProps = (state, props) => {
|
||||
export interface WithPlansProps {
|
||||
plans: ReturnType<ReturnType<typeof getPlansSelector>>;
|
||||
plansPeriod: ReturnType<ReturnType<typeof getPlansPeriodSelector>>;
|
||||
}
|
||||
|
||||
type MapState<Props> = (
|
||||
mapped: WithPlansProps,
|
||||
state: ApplicationState,
|
||||
props: Props,
|
||||
) => any;
|
||||
|
||||
export function withPlans<Props>(mapState?: MapState<Props>) {
|
||||
const mapStateToProps: MapStateToProps<
|
||||
WithPlansProps,
|
||||
Props,
|
||||
ApplicationState
|
||||
> = (state, props) => {
|
||||
const getPlans = getPlansSelector();
|
||||
const getPlansPeriod = getPlansPeriodSelector();
|
||||
|
||||
const mapped = {
|
||||
plans: getPlans(state, props),
|
||||
plans: getPlans(state),
|
||||
plansPeriod: getPlansPeriod(state),
|
||||
};
|
||||
return mapState ? mapState(mapped, state, props) : mapped;
|
||||
};
|
||||
return connect(mapStateToProps);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import { initSubscriptionPlans } from '@/store/plans/plans.actions';
|
||||
import { MapDispatchToProps, connect } from 'react-redux';
|
||||
import {
|
||||
SubscriptionPlansPeriod,
|
||||
changePlansPeriod,
|
||||
initSubscriptionPlans,
|
||||
} from '@/store/plans/plans.reducer';
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
export interface WithSubscriptionPlansActionsProps {
|
||||
initSubscriptionPlans: () => void;
|
||||
changeSubscriptionPlansPeriod: (period: SubscriptionPlansPeriod) => void;
|
||||
}
|
||||
|
||||
export const mapDispatchToProps: MapDispatchToProps<
|
||||
WithSubscriptionPlansActionsProps,
|
||||
{}
|
||||
> = (dispatch: any) => ({
|
||||
initSubscriptionPlans: () => dispatch(initSubscriptionPlans()),
|
||||
changeSubscriptionPlansPeriod: (period: SubscriptionPlansPeriod) =>
|
||||
dispatch(changePlansPeriod({ period })),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps);
|
||||
export default connect(null, mapDispatchToProps);
|
||||
|
||||
Reference in New Issue
Block a user