mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
Compare commits
9 Commits
fix-plaid-
...
v0.18.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b6b73b77c | ||
|
|
107a6f793b | ||
|
|
67d155759e | ||
|
|
7e2e87256f | ||
|
|
df7790d7c1 | ||
|
|
72128a72c4 | ||
|
|
eb3f23554f | ||
|
|
69ddf43b3e | ||
|
|
249eadaeaa |
@@ -237,4 +237,8 @@ module.exports = {
|
|||||||
endpoint: process.env.S3_ENDPOINT,
|
endpoint: process.env.S3_ENDPOINT,
|
||||||
bucket: process.env.S3_BUCKET || 'bigcapital-documents',
|
bucket: process.env.S3_BUCKET || 'bigcapital-documents',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loops: {
|
||||||
|
apiKey: process.env.LOOPS_API_KEY,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ import { UnlinkBankRuleOnDeleteBankRule } from '@/services/Banking/Rules/events/
|
|||||||
import { DecrementUncategorizedTransactionOnMatching } from '@/services/Banking/Matching/events/DecrementUncategorizedTransactionsOnMatch';
|
import { DecrementUncategorizedTransactionOnMatching } from '@/services/Banking/Matching/events/DecrementUncategorizedTransactionsOnMatch';
|
||||||
import { DecrementUncategorizedTransactionOnExclude } from '@/services/Banking/Exclude/events/DecrementUncategorizedTransactionOnExclude';
|
import { DecrementUncategorizedTransactionOnExclude } from '@/services/Banking/Exclude/events/DecrementUncategorizedTransactionOnExclude';
|
||||||
import { DecrementUncategorizedTransactionOnCategorize } from '@/services/Cashflow/subscribers/DecrementUncategorizedTransactionOnCategorize';
|
import { DecrementUncategorizedTransactionOnCategorize } from '@/services/Cashflow/subscribers/DecrementUncategorizedTransactionOnCategorize';
|
||||||
|
import { LoopsEventsSubscriber } from '@/services/Loops/LoopsEventsSubscriber';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
return new EventPublisher();
|
return new EventPublisher();
|
||||||
@@ -274,5 +275,8 @@ export const susbcribers = () => {
|
|||||||
|
|
||||||
// Plaid
|
// Plaid
|
||||||
RecognizeSyncedBankTranasctions,
|
RecognizeSyncedBankTranasctions,
|
||||||
|
|
||||||
|
// Loops
|
||||||
|
LoopsEventsSubscriber
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ export class PlaidUpdateTransactions {
|
|||||||
added.concat(modified),
|
added.concat(modified),
|
||||||
trx
|
trx
|
||||||
);
|
);
|
||||||
// Sync removed transactions.
|
|
||||||
await this.plaidSync.syncRemoveTransactions(tenantId, removed, trx);
|
|
||||||
// Sync transactions cursor.
|
// Sync transactions cursor.
|
||||||
await this.plaidSync.syncTransactionsCursor(
|
await this.plaidSync.syncTransactionsCursor(
|
||||||
tenantId,
|
tenantId,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class CreateUncategorizedTransaction {
|
|||||||
tenantId,
|
tenantId,
|
||||||
async (trx: Knex.Transaction) => {
|
async (trx: Knex.Transaction) => {
|
||||||
await this.eventPublisher.emitAsync(
|
await this.eventPublisher.emitAsync(
|
||||||
events.cashflow.onTransactionUncategorizedCreated,
|
events.cashflow.onTransactionUncategorizedCreating,
|
||||||
{
|
{
|
||||||
tenantId,
|
tenantId,
|
||||||
createUncategorizedTransactionDTO,
|
createUncategorizedTransactionDTO,
|
||||||
|
|||||||
51
packages/server/src/services/Loops/LoopsEventsSubscriber.ts
Normal file
51
packages/server/src/services/Loops/LoopsEventsSubscriber.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import config from '@/config';
|
||||||
|
import { IAuthSignUpVerifiedEventPayload } from '@/interfaces';
|
||||||
|
import events from '@/subscribers/events';
|
||||||
|
import { SystemUser } from '@/system/models';
|
||||||
|
|
||||||
|
export class LoopsEventsSubscriber {
|
||||||
|
/**
|
||||||
|
* Constructor method.
|
||||||
|
*/
|
||||||
|
public attach(bus) {
|
||||||
|
bus.subscribe(
|
||||||
|
events.auth.signUpConfirmed,
|
||||||
|
this.triggerEventOnSignupVerified.bind(this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Once the user verified sends the event to the Loops.
|
||||||
|
* @param {IAuthSignUpVerifiedEventPayload} param0
|
||||||
|
*/
|
||||||
|
public async triggerEventOnSignupVerified({
|
||||||
|
email,
|
||||||
|
userId,
|
||||||
|
}: IAuthSignUpVerifiedEventPayload) {
|
||||||
|
// Can't continue since the Loops the api key is not configured.
|
||||||
|
if (!config.loops.apiKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const user = await SystemUser.query().findById(userId);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
url: 'https://app.loops.so/api/v1/events/send',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${config.loops.apiKey}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
email,
|
||||||
|
userId,
|
||||||
|
firstName: user.firstName,
|
||||||
|
lastName: user.lastName,
|
||||||
|
eventName: 'USER_VERIFIED',
|
||||||
|
eventProperties: {},
|
||||||
|
mailingLists: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await axios(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { getPrice } from '@lemonsqueezy/lemonsqueezy.js';
|
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import {
|
import {
|
||||||
@@ -10,7 +9,6 @@ import {
|
|||||||
} from './utils';
|
} from './utils';
|
||||||
import { Plan } from '@/system/models';
|
import { Plan } from '@/system/models';
|
||||||
import { Subscription } from './Subscription';
|
import { Subscription } from './Subscription';
|
||||||
import { isEmpty } from 'lodash';
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class LemonSqueezyWebhooks {
|
export class LemonSqueezyWebhooks {
|
||||||
@@ -18,7 +16,7 @@ export class LemonSqueezyWebhooks {
|
|||||||
private subscriptionService: Subscription;
|
private subscriptionService: Subscription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle the LemonSqueezy webhooks.
|
* Handles the Lemon Squeezy webhooks.
|
||||||
* @param {string} rawBody
|
* @param {string} rawBody
|
||||||
* @param {string} signature
|
* @param {string} signature
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
@@ -74,7 +72,7 @@ export class LemonSqueezyWebhooks {
|
|||||||
const variantId = attributes.variant_id as string;
|
const variantId = attributes.variant_id as string;
|
||||||
|
|
||||||
// We assume that the Plan table is up to date.
|
// We assume that the Plan table is up to date.
|
||||||
const plan = await Plan.query().findOne('slug', 'early-adaptor');
|
const plan = await Plan.query().findOne('lemonVariantId', variantId);
|
||||||
|
|
||||||
if (!plan) {
|
if (!plan) {
|
||||||
throw new Error(`Plan with variantId ${variantId} not found.`);
|
throw new Error(`Plan with variantId ${variantId} not found.`);
|
||||||
@@ -82,26 +80,9 @@ export class LemonSqueezyWebhooks {
|
|||||||
// Update the subscription in the database.
|
// Update the subscription in the database.
|
||||||
const priceId = attributes.first_subscription_item.price_id;
|
const priceId = attributes.first_subscription_item.price_id;
|
||||||
|
|
||||||
// Get the price data from Lemon Squeezy.
|
|
||||||
const priceData = await getPrice(priceId);
|
|
||||||
|
|
||||||
if (priceData.error) {
|
|
||||||
throw new Error(
|
|
||||||
`Failed to get the price data for the subscription ${eventBody.data.id}.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const isUsageBased =
|
|
||||||
attributes.first_subscription_item.is_usage_based;
|
|
||||||
const price = isUsageBased
|
|
||||||
? priceData.data?.data.attributes.unit_price_decimal
|
|
||||||
: priceData.data?.data.attributes.unit_price;
|
|
||||||
|
|
||||||
// Create a new subscription of the tenant.
|
// Create a new subscription of the tenant.
|
||||||
if (webhookEvent === 'subscription_created') {
|
if (webhookEvent === 'subscription_created') {
|
||||||
await this.subscriptionService.newSubscribtion(
|
await this.subscriptionService.newSubscribtion(tenantId, plan.slug);
|
||||||
tenantId,
|
|
||||||
'early-adaptor'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (webhookEvent.startsWith('order_')) {
|
} else if (webhookEvent.startsWith('order_')) {
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ export default {
|
|||||||
baseCurrencyUpdated: 'onOrganizationBaseCurrencyUpdated',
|
baseCurrencyUpdated: 'onOrganizationBaseCurrencyUpdated',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User subscription events.
|
||||||
|
*/
|
||||||
|
subscription: {
|
||||||
|
onSubscribed: 'onOrganizationSubscribed',
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tenants managment service.
|
* Tenants managment service.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.schema.table('subscription_plans', (table) => {
|
||||||
|
table.string('lemon_variant_id').nullable().index();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = (knex) => {
|
||||||
|
return knex.schema.table('subscription_plans', (table) => {
|
||||||
|
table.dropColumn('lemon_variant_id');
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
exports.up = function (knex) {
|
||||||
|
return knex('subscription_plans').insert([
|
||||||
|
// Capital Basic
|
||||||
|
{
|
||||||
|
name: 'Capital Basic (Monthly)',
|
||||||
|
slug: 'capital-basic-monthly',
|
||||||
|
price: 10,
|
||||||
|
active: true,
|
||||||
|
currency: 'USD',
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'month',
|
||||||
|
lemon_variant_id: '446152',
|
||||||
|
// lemon_variant_id: '450016',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Basic (Annually)',
|
||||||
|
slug: 'capital-basic-annually',
|
||||||
|
price: 90,
|
||||||
|
active: true,
|
||||||
|
currency: 'USD',
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'year',
|
||||||
|
lemon_variant_id: '446153',
|
||||||
|
// lemon_variant_id: '450018',
|
||||||
|
},
|
||||||
|
|
||||||
|
// # Capital Essential
|
||||||
|
{
|
||||||
|
name: 'Capital Essential (Monthly)',
|
||||||
|
slug: 'capital-essential-monthly',
|
||||||
|
price: 20,
|
||||||
|
active: true,
|
||||||
|
currency: 'USD',
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'month',
|
||||||
|
lemon_variant_id: '446155',
|
||||||
|
// lemon_variant_id: '450028',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Essential (Annually)',
|
||||||
|
slug: 'capital-essential-annually',
|
||||||
|
price: 180,
|
||||||
|
active: true,
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'year',
|
||||||
|
lemon_variant_id: '446156',
|
||||||
|
// lemon_variant_id: '450029',
|
||||||
|
},
|
||||||
|
|
||||||
|
// # Capital Plus
|
||||||
|
{
|
||||||
|
name: 'Capital Plus (Monthly)',
|
||||||
|
slug: 'capital-plus-monthly',
|
||||||
|
price: 25,
|
||||||
|
active: true,
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'month',
|
||||||
|
lemon_variant_id: '446165',
|
||||||
|
// lemon_variant_id: '450031',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Plus (Annually)',
|
||||||
|
slug: 'capital-plus-annually',
|
||||||
|
price: 228,
|
||||||
|
active: true,
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'year',
|
||||||
|
lemon_variant_id: '446164',
|
||||||
|
// lemon_variant_id: '450032',
|
||||||
|
},
|
||||||
|
|
||||||
|
// # Capital Big
|
||||||
|
{
|
||||||
|
name: 'Capital Big (Monthly)',
|
||||||
|
slug: 'capital-big-monthly',
|
||||||
|
price: 40,
|
||||||
|
active: true,
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'month',
|
||||||
|
lemon_variant_id: '446167',
|
||||||
|
// lemon_variant_id: '450024',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Big (Annually)',
|
||||||
|
slug: 'capital-big-annually',
|
||||||
|
price: 360,
|
||||||
|
active: true,
|
||||||
|
invoice_period: 1,
|
||||||
|
invoice_interval: 'year',
|
||||||
|
lemon_variant_id: '446168',
|
||||||
|
// lemon_variant_id: '450025',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {};
|
||||||
@@ -23,9 +23,10 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
.label {
|
.label {
|
||||||
font-size: 14px;
|
font-size: 16px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #2F343C;
|
color: #2F343C;
|
||||||
|
|
||||||
@@ -47,9 +48,9 @@
|
|||||||
}
|
}
|
||||||
.price {
|
.price {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #404854;
|
color: #252A31;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pricePer{
|
.pricePer{
|
||||||
@@ -57,3 +58,21 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.featureItem{
|
||||||
|
flex: 1;
|
||||||
|
color: #1C2127;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featurePopover :global .bp4-popover-content{
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.featurePopoverContent{
|
||||||
|
font-size: 12px
|
||||||
|
}
|
||||||
|
.featurePopoverLabel {
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
@@ -1,4 +1,11 @@
|
|||||||
import { Button, ButtonProps, Intent } from '@blueprintjs/core';
|
import {
|
||||||
|
Button,
|
||||||
|
ButtonProps,
|
||||||
|
Intent,
|
||||||
|
Position,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import clsx from 'classnames';
|
import clsx from 'classnames';
|
||||||
import { Box, Group, Stack } from '../Layout';
|
import { Box, Group, Stack } from '../Layout';
|
||||||
import styles from './PricingPlan.module.scss';
|
import styles from './PricingPlan.module.scss';
|
||||||
@@ -64,7 +71,7 @@ export interface PricingPriceProps {
|
|||||||
*/
|
*/
|
||||||
PricingPlan.Price = ({ price, subPrice }: PricingPriceProps) => {
|
PricingPlan.Price = ({ price, subPrice }: PricingPriceProps) => {
|
||||||
return (
|
return (
|
||||||
<Stack spacing={6} className={styles.priceRoot}>
|
<Stack spacing={4} className={styles.priceRoot}>
|
||||||
<h4 className={styles.price}>{price}</h4>
|
<h4 className={styles.price}>{price}</h4>
|
||||||
<span className={styles.pricePer}>{subPrice}</span>
|
<span className={styles.pricePer}>{subPrice}</span>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -101,7 +108,7 @@ export interface PricingFeaturesProps {
|
|||||||
*/
|
*/
|
||||||
PricingPlan.Features = ({ children }: PricingFeaturesProps) => {
|
PricingPlan.Features = ({ children }: PricingFeaturesProps) => {
|
||||||
return (
|
return (
|
||||||
<Stack spacing={10} className={styles.features}>
|
<Stack spacing={14} className={styles.features}>
|
||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
@@ -109,15 +116,41 @@ PricingPlan.Features = ({ children }: PricingFeaturesProps) => {
|
|||||||
|
|
||||||
export interface PricingFeatureLineProps {
|
export interface PricingFeatureLineProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
hintContent?: string;
|
||||||
|
hintLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a single feature line within a list of features.
|
* Displays a single feature line within a list of features.
|
||||||
* @param children - The content of the feature line.
|
* @param children - The content of the feature line.
|
||||||
*/
|
*/
|
||||||
PricingPlan.FeatureLine = ({ children }: PricingFeatureLineProps) => {
|
PricingPlan.FeatureLine = ({
|
||||||
return (
|
children,
|
||||||
<Group noWrap spacing={12}>
|
hintContent,
|
||||||
|
hintLabel,
|
||||||
|
}: PricingFeatureLineProps) => {
|
||||||
|
return hintContent ? (
|
||||||
|
<Tooltip
|
||||||
|
content={
|
||||||
|
<Stack spacing={5}>
|
||||||
|
{hintLabel && (
|
||||||
|
<Text className={styles.featurePopoverLabel}>{hintLabel}</Text>
|
||||||
|
)}
|
||||||
|
<Text className={styles.featurePopoverContent}>{hintContent}</Text>
|
||||||
|
</Stack>
|
||||||
|
}
|
||||||
|
position={Position.TOP_LEFT}
|
||||||
|
popoverClassName={styles.featurePopover}
|
||||||
|
modifiers={{ offset: { enabled: true, offset: '0,10' } }}
|
||||||
|
minimal
|
||||||
|
>
|
||||||
|
<Group noWrap spacing={8} style={{ cursor: 'help' }}>
|
||||||
|
<CheckCircled height={12} width={12} />
|
||||||
|
<Box className={styles.featureItem}>{children}</Box>
|
||||||
|
</Group>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
<Group noWrap spacing={8}>
|
||||||
<CheckCircled height={12} width={12} />
|
<CheckCircled height={12} width={12} />
|
||||||
<Box className={styles.featureItem}>{children}</Box>
|
<Box className={styles.featureItem}>{children}</Box>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -1,10 +1,140 @@
|
|||||||
// @ts-nocheck
|
interface SubscriptionPlanFeature {
|
||||||
// Subscription plans.
|
text: string;
|
||||||
export const plans = [
|
hint?: string;
|
||||||
|
label?: string;
|
||||||
|
style?: Record<string, string>;
|
||||||
|
}
|
||||||
|
interface SubscriptionPlan {
|
||||||
|
name: string;
|
||||||
|
slug: string;
|
||||||
|
description: string;
|
||||||
|
features: SubscriptionPlanFeature[];
|
||||||
|
featured?: boolean;
|
||||||
|
monthlyPrice: string;
|
||||||
|
monthlyPriceLabel: string;
|
||||||
|
annuallyPrice: string;
|
||||||
|
annuallyPriceLabel: string;
|
||||||
|
monthlyVariantId: string;
|
||||||
|
annuallyVariantId: string;
|
||||||
|
}
|
||||||
|
|
||||||
];
|
export const SubscriptionPlans = [
|
||||||
|
{
|
||||||
// Payment methods.
|
name: 'Capital Basic',
|
||||||
export const paymentMethods = [
|
slug: 'capital_basic',
|
||||||
|
description: 'Good for service businesses that just started.',
|
||||||
];
|
features: [
|
||||||
|
{
|
||||||
|
text: 'Unlimited Sale Invoices',
|
||||||
|
hintLabel: 'Unlimited Sale Invoices',
|
||||||
|
hint: 'Good for service businesses that just started for service businesses that just started',
|
||||||
|
},
|
||||||
|
{ text: 'Unlimated Sale Estimates' },
|
||||||
|
{ text: 'Track GST and VAT' },
|
||||||
|
{ text: 'Connect Banks for Automatic Importing' },
|
||||||
|
{ text: 'Chart of Accounts' },
|
||||||
|
{
|
||||||
|
text: 'Manual Journals',
|
||||||
|
hintLabel: 'Manual Journals',
|
||||||
|
hint: 'Write manual journals entries for financial transactions not automatically captured by the system to adjust financial statements.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Basic Financial Reports & Insights',
|
||||||
|
hint: 'Balance sheet, profit & loss statement, cashflow statement, general ledger, journal sheet, A/P aging summary, A/R aging summary',
|
||||||
|
},
|
||||||
|
{ text: 'Unlimited User Seats' },
|
||||||
|
],
|
||||||
|
monthlyPrice: '$10',
|
||||||
|
monthlyPriceLabel: 'Per month',
|
||||||
|
annuallyPrice: '$7.5',
|
||||||
|
annuallyPriceLabel: 'Per month',
|
||||||
|
monthlyVariantId: '446152',
|
||||||
|
// monthlyVariantId: '450016',
|
||||||
|
annuallyVariantId: '446153',
|
||||||
|
// annuallyVariantId: '450018',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Essential',
|
||||||
|
slug: 'capital_plus',
|
||||||
|
description: 'Good for have inventory and want more financial reports.',
|
||||||
|
features: [
|
||||||
|
{ text: 'All Capital Basic features' },
|
||||||
|
{ text: 'Purchase Invoices' },
|
||||||
|
{
|
||||||
|
text: 'Multi Currency Transactions',
|
||||||
|
hintLabel: 'Multi Currency',
|
||||||
|
hint: 'Pay and get paid and do manual journals in any currency with real time exchange rates conversions.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Transactions Locking',
|
||||||
|
hintLabel: 'Transactions Locking',
|
||||||
|
hint: 'Transaction Locking freezes transactions to prevent any additions, modifications, or deletions of transactions recorded during the specified date.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Inventory Tracking',
|
||||||
|
hintLabel: 'Inventory Tracking',
|
||||||
|
hint: 'Track goods in the stock, cost of goods, and get notifications when quantity is low.',
|
||||||
|
},
|
||||||
|
{ text: 'Smart Financial Reports' },
|
||||||
|
{ text: 'Advanced Inventory Reports' },
|
||||||
|
],
|
||||||
|
monthlyPrice: '$20',
|
||||||
|
monthlyPriceLabel: 'Per month',
|
||||||
|
annuallyPrice: '$15',
|
||||||
|
annuallyPriceLabel: 'Per month',
|
||||||
|
// monthlyVariantId: '450028',
|
||||||
|
monthlyVariantId: '446155',
|
||||||
|
// annuallyVariantId: '450029',
|
||||||
|
annuallyVariantId: '446156',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Plus',
|
||||||
|
slug: 'essentials',
|
||||||
|
description: 'Good for business want financial and access control.',
|
||||||
|
features: [
|
||||||
|
{ text: 'All Capital Essential features' },
|
||||||
|
{ text: 'Custom User Roles Access' },
|
||||||
|
{ text: 'Vendor Credits' },
|
||||||
|
{
|
||||||
|
text: 'Budgeting',
|
||||||
|
hint: 'Create multiple budgets and compare targets with actuals to understand how your business is performing.',
|
||||||
|
},
|
||||||
|
{ text: 'Analysis Cost Center' },
|
||||||
|
],
|
||||||
|
monthlyPrice: '$25',
|
||||||
|
monthlyPriceLabel: 'Per month',
|
||||||
|
annuallyPrice: '$19',
|
||||||
|
annuallyPriceLabel: 'Per month',
|
||||||
|
featured: true,
|
||||||
|
// monthlyVariantId: '450031',
|
||||||
|
monthlyVariantId: '446165',
|
||||||
|
// annuallyVariantId: '450032',
|
||||||
|
annuallyVariantId: '446164',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Capital Big',
|
||||||
|
slug: 'essentials',
|
||||||
|
description: 'Good for businesses have multiple branches.',
|
||||||
|
features: [
|
||||||
|
{ text: 'All Capital Plus features' },
|
||||||
|
{
|
||||||
|
text: 'Multiple Branches',
|
||||||
|
hintLabel: '',
|
||||||
|
hint: 'Track the organization transactions and accounts in multiple branches.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Multiple Warehouses',
|
||||||
|
hintLabel: 'Multiple Warehouses',
|
||||||
|
hint: 'Track the organization inventory in multiple warehouses and transfer goods between them.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
monthlyPrice: '$40',
|
||||||
|
monthlyPriceLabel: 'Per month',
|
||||||
|
annuallyPrice: '$30',
|
||||||
|
annuallyPriceLabel: 'Per month',
|
||||||
|
// monthlyVariantId: '450024',
|
||||||
|
monthlyVariantId: '446167',
|
||||||
|
// annuallyVariantId: '450025',
|
||||||
|
annuallyVariantId: '446168',
|
||||||
|
},
|
||||||
|
] as SubscriptionPlan[];
|
||||||
|
|||||||
@@ -3,3 +3,7 @@
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 40px;
|
padding: 0 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.periodSwitch {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
@@ -1,32 +1,65 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { AppToaster, Group, T } from '@/components';
|
|
||||||
import { useGetLemonSqueezyCheckout } from '@/hooks/query';
|
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
import { AppToaster } from '@/components';
|
||||||
|
import { useGetLemonSqueezyCheckout } from '@/hooks/query';
|
||||||
import { PricingPlan } from '@/components/PricingPlan/PricingPlan';
|
import { PricingPlan } from '@/components/PricingPlan/PricingPlan';
|
||||||
|
import { SubscriptionPlansPeriod } from '@/store/plans/plans.reducer';
|
||||||
|
import {
|
||||||
|
WithPlansProps,
|
||||||
|
withPlans,
|
||||||
|
} from '@/containers/Subscriptions/withPlans';
|
||||||
|
|
||||||
|
interface SubscriptionPricingFeature {
|
||||||
|
text: string;
|
||||||
|
hint?: string;
|
||||||
|
hintLabel?: string;
|
||||||
|
style?: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
interface SubscriptionPricingProps {
|
interface SubscriptionPricingProps {
|
||||||
slug: string;
|
slug: string;
|
||||||
label: string;
|
label: string;
|
||||||
description: string;
|
description: string;
|
||||||
features?: Array<String>;
|
features?: Array<SubscriptionPricingFeature>;
|
||||||
featured?: boolean;
|
featured?: boolean;
|
||||||
price: string;
|
monthlyPrice: string;
|
||||||
pricePeriod: string;
|
monthlyPriceLabel: string;
|
||||||
|
annuallyPrice: string;
|
||||||
|
annuallyPriceLabel: string;
|
||||||
|
monthlyVariantId?: string;
|
||||||
|
annuallyVariantId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SubscriptionPricing({
|
interface SubscriptionPricingCombinedProps
|
||||||
featured,
|
extends SubscriptionPricingProps,
|
||||||
|
WithPlansProps {}
|
||||||
|
|
||||||
|
function SubscriptionPlanRoot({
|
||||||
label,
|
label,
|
||||||
description,
|
description,
|
||||||
|
featured,
|
||||||
features,
|
features,
|
||||||
price,
|
monthlyPrice,
|
||||||
pricePeriod,
|
monthlyPriceLabel,
|
||||||
}: SubscriptionPricingProps) {
|
annuallyPrice,
|
||||||
|
annuallyPriceLabel,
|
||||||
|
monthlyVariantId,
|
||||||
|
annuallyVariantId,
|
||||||
|
|
||||||
|
// #withPlans
|
||||||
|
plansPeriod,
|
||||||
|
}: SubscriptionPricingCombinedProps) {
|
||||||
const { mutateAsync: getLemonCheckout, isLoading } =
|
const { mutateAsync: getLemonCheckout, isLoading } =
|
||||||
useGetLemonSqueezyCheckout();
|
useGetLemonSqueezyCheckout();
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
getLemonCheckout({ variantId: '338516' })
|
const variantId =
|
||||||
|
SubscriptionPlansPeriod.Monthly === plansPeriod
|
||||||
|
? monthlyVariantId
|
||||||
|
: annuallyVariantId;
|
||||||
|
|
||||||
|
getLemonCheckout({ variantId })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const checkoutUrl = res.data.data.attributes.url;
|
const checkoutUrl = res.data.data.attributes.url;
|
||||||
window.LemonSqueezy.Url.Open(checkoutUrl);
|
window.LemonSqueezy.Url.Open(checkoutUrl);
|
||||||
@@ -42,37 +75,34 @@ function SubscriptionPricing({
|
|||||||
return (
|
return (
|
||||||
<PricingPlan featured={featured}>
|
<PricingPlan featured={featured}>
|
||||||
{featured && <PricingPlan.Featured>Most Popular</PricingPlan.Featured>}
|
{featured && <PricingPlan.Featured>Most Popular</PricingPlan.Featured>}
|
||||||
|
|
||||||
<PricingPlan.Header label={label} description={description} />
|
<PricingPlan.Header label={label} description={description} />
|
||||||
<PricingPlan.Price price={price} subPrice={pricePeriod} />
|
|
||||||
|
{plansPeriod === SubscriptionPlansPeriod.Monthly ? (
|
||||||
|
<PricingPlan.Price price={monthlyPrice} subPrice={monthlyPriceLabel} />
|
||||||
|
) : (
|
||||||
|
<PricingPlan.Price
|
||||||
|
price={annuallyPrice}
|
||||||
|
subPrice={annuallyPriceLabel}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<PricingPlan.BuyButton loading={isLoading} onClick={handleClick}>
|
<PricingPlan.BuyButton loading={isLoading} onClick={handleClick}>
|
||||||
Subscribe
|
Subscribe
|
||||||
</PricingPlan.BuyButton>
|
</PricingPlan.BuyButton>
|
||||||
|
|
||||||
<PricingPlan.Features>
|
<PricingPlan.Features>
|
||||||
{features?.map((feature) => (
|
{features?.map((feature) => (
|
||||||
<PricingPlan.FeatureLine>{feature}</PricingPlan.FeatureLine>
|
<PricingPlan.FeatureLine
|
||||||
|
hintLabel={feature.hintLabel}
|
||||||
|
hintContent={feature.hint}
|
||||||
|
>
|
||||||
|
{feature.text}
|
||||||
|
</PricingPlan.FeatureLine>
|
||||||
))}
|
))}
|
||||||
</PricingPlan.Features>
|
</PricingPlan.Features>
|
||||||
</PricingPlan>
|
</PricingPlan>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SubscriptionPlans({ plans }) {
|
export const SubscriptionPlan = R.compose(
|
||||||
return (
|
withPlans(({ plansPeriod }) => ({ plansPeriod })),
|
||||||
<Group spacing={18} noWrap align='stretch'>
|
)(SubscriptionPlanRoot);
|
||||||
{plans.map((plan, index) => (
|
|
||||||
<SubscriptionPricing
|
|
||||||
key={index}
|
|
||||||
slug={plan.slug}
|
|
||||||
label={plan.name}
|
|
||||||
description={plan.description}
|
|
||||||
features={plan.features}
|
|
||||||
featured={plan.featured}
|
|
||||||
price={plan.price}
|
|
||||||
pricePeriod={plan.pricePeriod}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Group } from '@/components';
|
||||||
|
import { SubscriptionPlan } from './SubscriptionPlan';
|
||||||
|
import { useSubscriptionPlans } from './hooks';
|
||||||
|
|
||||||
|
export function SubscriptionPlans() {
|
||||||
|
const subscriptionPlans = useSubscriptionPlans();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group spacing={14} noWrap align="stretch">
|
||||||
|
{subscriptionPlans.map((plan, index) => (
|
||||||
|
<SubscriptionPlan
|
||||||
|
key={index}
|
||||||
|
slug={plan.slug}
|
||||||
|
label={plan.name}
|
||||||
|
description={plan.description}
|
||||||
|
features={plan.features}
|
||||||
|
featured={plan.featured}
|
||||||
|
monthlyPrice={plan.monthlyPrice}
|
||||||
|
monthlyPriceLabel={plan.monthlyPriceLabel}
|
||||||
|
annuallyPrice={plan.annuallyPrice}
|
||||||
|
annuallyPriceLabel={plan.annuallyPriceLabel}
|
||||||
|
monthlyVariantId={plan.monthlyVariantId}
|
||||||
|
annuallyVariantId={plan.annuallyVariantId}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { ChangeEvent } from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
import { Intent, Switch, Tag, Text } from '@blueprintjs/core';
|
||||||
|
import { Group } from '@/components';
|
||||||
|
import withSubscriptionPlansActions, {
|
||||||
|
WithSubscriptionPlansActionsProps,
|
||||||
|
} from '@/containers/Subscriptions/withSubscriptionPlansActions';
|
||||||
|
import { SubscriptionPlansPeriod } from '@/store/plans/plans.reducer';
|
||||||
|
import styles from './SetupSubscription.module.scss';
|
||||||
|
|
||||||
|
interface SubscriptionPlansPeriodsSwitchCombinedProps
|
||||||
|
extends WithSubscriptionPlansActionsProps {}
|
||||||
|
|
||||||
|
function SubscriptionPlansPeriodSwitcherRoot({
|
||||||
|
// #withSubscriptionPlansActions
|
||||||
|
changeSubscriptionPlansPeriod,
|
||||||
|
}: SubscriptionPlansPeriodsSwitchCombinedProps) {
|
||||||
|
// Handles the period switch change.
|
||||||
|
const handleSwitchChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
changeSubscriptionPlansPeriod(
|
||||||
|
event.currentTarget.checked
|
||||||
|
? SubscriptionPlansPeriod.Annually
|
||||||
|
: SubscriptionPlansPeriod.Monthly,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Group position={'center'} spacing={10} style={{ marginBottom: '1.2rem' }}>
|
||||||
|
<Text>Pay Monthly</Text>
|
||||||
|
<Switch
|
||||||
|
large
|
||||||
|
onChange={handleSwitchChange}
|
||||||
|
className={styles.periodSwitch}
|
||||||
|
/>
|
||||||
|
<Text>
|
||||||
|
Pay Yearly{' '}
|
||||||
|
<Tag minimal intent={Intent.NONE}>
|
||||||
|
25% Off All Year
|
||||||
|
</Tag>
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SubscriptionPlansPeriodSwitcher = R.compose(
|
||||||
|
withSubscriptionPlansActions,
|
||||||
|
)(SubscriptionPlansPeriodSwitcherRoot);
|
||||||
@@ -1,29 +1,21 @@
|
|||||||
// @ts-nocheck
|
|
||||||
import { Callout } from '@blueprintjs/core';
|
import { Callout } from '@blueprintjs/core';
|
||||||
import { SubscriptionPlans } from './SubscriptionPlan';
|
import { SubscriptionPlans } from './SubscriptionPlans';
|
||||||
import withPlans from '../../Subscriptions/withPlans';
|
import { SubscriptionPlansPeriodSwitcher } from './SubscriptionPlansPeriodSwitcher';
|
||||||
import { compose } from '@/utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Billing plans.
|
* Billing plans.
|
||||||
*/
|
*/
|
||||||
function SubscriptionPlansSectionRoot({ plans }) {
|
export function SubscriptionPlansSection() {
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<Callout
|
<Callout style={{ marginBottom: '2rem' }} icon={null}>
|
||||||
style={{ marginBottom: '1.5rem' }}
|
Simple plans. Simple prices. Only pay for what you really need. All
|
||||||
icon={null}
|
plans come with award-winning 24/7 customer support. Prices do not
|
||||||
title={'Early Adopter Plan'}
|
include applicable taxes.
|
||||||
>
|
|
||||||
We're looking for 200 early adopters, when you subscribe you'll get the
|
|
||||||
full features and unlimited users for a year regardless of the
|
|
||||||
subscribed plan.
|
|
||||||
</Callout>
|
</Callout>
|
||||||
<SubscriptionPlans plans={plans} />
|
|
||||||
|
<SubscriptionPlansPeriodSwitcher />
|
||||||
|
<SubscriptionPlans />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SubscriptionPlansSection = compose(
|
|
||||||
withPlans(({ plans }) => ({ plans })),
|
|
||||||
)(SubscriptionPlansSectionRoot);
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { SubscriptionPlans } from '@/constants/subscriptionModels';
|
||||||
|
|
||||||
|
export const useSubscriptionPlans = () => {
|
||||||
|
return SubscriptionPlans;
|
||||||
|
};
|
||||||
@@ -1,17 +1,35 @@
|
|||||||
// @ts-nocheck
|
import { MapStateToProps, connect } from 'react-redux';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import {
|
import {
|
||||||
|
getPlansPeriodSelector,
|
||||||
getPlansSelector,
|
getPlansSelector,
|
||||||
} from '@/store/plans/plans.selectors';
|
} from '@/store/plans/plans.selectors';
|
||||||
|
import { ApplicationState } from '@/store/reducers';
|
||||||
|
|
||||||
export default (mapState) => {
|
export interface WithPlansProps {
|
||||||
const mapStateToProps = (state, props) => {
|
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 getPlans = getPlansSelector();
|
||||||
|
const getPlansPeriod = getPlansPeriodSelector();
|
||||||
|
|
||||||
const mapped = {
|
const mapped = {
|
||||||
plans: getPlans(state, props),
|
plans: getPlans(state),
|
||||||
|
plansPeriod: getPlansPeriod(state),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
return connect(mapStateToProps);
|
return connect(mapStateToProps);
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,9 +1,22 @@
|
|||||||
// @ts-nocheck
|
import { MapDispatchToProps, connect } from 'react-redux';
|
||||||
import { connect } from 'react-redux';
|
import {
|
||||||
import { initSubscriptionPlans } from '@/store/plans/plans.actions';
|
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()),
|
initSubscriptionPlans: () => dispatch(initSubscriptionPlans()),
|
||||||
|
changeSubscriptionPlansPeriod: (period: SubscriptionPlansPeriod) =>
|
||||||
|
dispatch(changePlansPeriod({ period })),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -1,70 +1,46 @@
|
|||||||
// @ts-nocheck
|
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
|
||||||
import { createReducer } from '@reduxjs/toolkit';
|
import { SubscriptionPlans } from '@/constants/subscriptionModels';
|
||||||
import t from '@/store/types';
|
|
||||||
|
|
||||||
const getSubscriptionPlans = () => [
|
export enum SubscriptionPlansPeriod {
|
||||||
{
|
Monthly = 'monthly',
|
||||||
name: 'Capital Basic',
|
Annually = 'Annually',
|
||||||
slug: 'capital_basic',
|
}
|
||||||
description: 'Good for service businesses that just started.',
|
|
||||||
features: [
|
|
||||||
'Sale Invoices and Estimates',
|
|
||||||
'Tracking Expenses',
|
|
||||||
'Customize Invoice',
|
|
||||||
'Manual Journals',
|
|
||||||
'Bank Reconciliation',
|
|
||||||
'Chart of Accounts',
|
|
||||||
'Taxes',
|
|
||||||
'Basic Financial Reports & Insights',
|
|
||||||
],
|
|
||||||
price: '$29',
|
|
||||||
pricePeriod: 'Per Year',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Capital Plus',
|
|
||||||
slug: 'capital_plus',
|
|
||||||
description:
|
|
||||||
'Good for businesses have inventory and want more financial reports.',
|
|
||||||
features: [
|
|
||||||
'All Capital Basic features',
|
|
||||||
'Manage Bills',
|
|
||||||
'Inventory Tracking',
|
|
||||||
'Multi Currencies',
|
|
||||||
'Predefined user roles.',
|
|
||||||
'Transactions locking.',
|
|
||||||
'Smart Financial Reports.',
|
|
||||||
],
|
|
||||||
price: '$29',
|
|
||||||
pricePeriod: 'Per Year',
|
|
||||||
featured: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Capital Big',
|
|
||||||
slug: 'essentials',
|
|
||||||
description: 'Good for businesses have multiple inventory or branches.',
|
|
||||||
features: [
|
|
||||||
'All Capital Plus features',
|
|
||||||
'Multiple Warehouses',
|
|
||||||
'Multiple Branches',
|
|
||||||
'Invite >= 15 Users',
|
|
||||||
],
|
|
||||||
price: '$29',
|
|
||||||
pricePeriod: 'Per Year',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const initialState = {
|
interface StorePlansState {
|
||||||
plans: [],
|
plans: any;
|
||||||
periods: [],
|
plansPeriod: SubscriptionPlansPeriod;
|
||||||
};
|
}
|
||||||
|
|
||||||
export default createReducer(initialState, {
|
export const SubscriptionPlansSlice = createSlice({
|
||||||
/**
|
name: 'plans',
|
||||||
* Initialize the subscription plans.
|
initialState: {
|
||||||
*/
|
plans: [],
|
||||||
[t.INIT_SUBSCRIPTION_PLANS]: (state) => {
|
periods: [],
|
||||||
const plans = getSubscriptionPlans();
|
plansPeriod: 'monthly',
|
||||||
|
} as StorePlansState,
|
||||||
|
reducers: {
|
||||||
|
/**
|
||||||
|
* Initialize the subscription plans.
|
||||||
|
* @param {StorePlansState} state
|
||||||
|
*/
|
||||||
|
initSubscriptionPlans: (state: StorePlansState) => {
|
||||||
|
const plans = SubscriptionPlans;
|
||||||
|
state.plans = plans;
|
||||||
|
},
|
||||||
|
|
||||||
state.plans = plans;
|
/**
|
||||||
|
* Changes the plans period (monthly or annually).
|
||||||
|
* @param {StorePlansState} state
|
||||||
|
* @param {PayloadAction<{ period: SubscriptionPlansPeriod }>} action
|
||||||
|
*/
|
||||||
|
changePlansPeriod: (
|
||||||
|
state: StorePlansState,
|
||||||
|
action: PayloadAction<{ period: SubscriptionPlansPeriod }>,
|
||||||
|
) => {
|
||||||
|
state.plansPeriod = action.payload.period;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const { initSubscriptionPlans, changePlansPeriod } =
|
||||||
|
SubscriptionPlansSlice.actions;
|
||||||
|
|||||||
@@ -2,19 +2,21 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const plansSelector = (state) => state.plans.plans;
|
const plansSelector = (state) => state.plans.plans;
|
||||||
const planSelector = (state, props) => state.plans.plans
|
const planSelector = (state, props) =>
|
||||||
.find((plan) => plan.slug === props.planSlug);
|
state.plans.plans.find((plan) => plan.slug === props.planSlug);
|
||||||
|
|
||||||
|
const plansPeriodSelector = (state) => state.plans.plansPeriod;
|
||||||
|
|
||||||
// Retrieve manual jounral current page results.
|
// Retrieve manual jounral current page results.
|
||||||
export const getPlansSelector = () => createSelector(
|
export const getPlansSelector = () =>
|
||||||
plansSelector,
|
createSelector(plansSelector, (plans) => {
|
||||||
(plans) => {
|
|
||||||
return plans;
|
return plans;
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// Retrieve plan details.
|
// Retrieve plan details.
|
||||||
export const getPlanSelector = () => createSelector(
|
export const getPlanSelector = () =>
|
||||||
planSelector,
|
createSelector(planSelector, (plan) => plan);
|
||||||
(plan) => plan,
|
|
||||||
)
|
// Retrieves the plans period (monthly or annually).
|
||||||
|
export const getPlansPeriodSelector = () =>
|
||||||
|
createSelector(plansPeriodSelector, (periods) => periods);
|
||||||
|
|||||||
@@ -32,13 +32,17 @@ import paymentMades from './PaymentMades/paymentMades.reducer';
|
|||||||
import organizations from './organizations/organizations.reducers';
|
import organizations from './organizations/organizations.reducers';
|
||||||
import subscriptions from './subscription/subscription.reducer';
|
import subscriptions from './subscription/subscription.reducer';
|
||||||
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.reducer';
|
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.reducer';
|
||||||
import plans from './plans/plans.reducer';
|
import { SubscriptionPlansSlice } from './plans/plans.reducer';
|
||||||
import creditNotes from './CreditNote/creditNote.reducer';
|
import creditNotes from './CreditNote/creditNote.reducer';
|
||||||
import vendorCredit from './VendorCredit/VendorCredit.reducer';
|
import vendorCredit from './VendorCredit/VendorCredit.reducer';
|
||||||
import warehouseTransfers from './WarehouseTransfer/warehouseTransfer.reducer';
|
import warehouseTransfers from './WarehouseTransfer/warehouseTransfer.reducer';
|
||||||
import projects from './Project/projects.reducer';
|
import projects from './Project/projects.reducer';
|
||||||
import { PlaidSlice } from './banking/banking.reducer';
|
import { PlaidSlice } from './banking/banking.reducer';
|
||||||
|
|
||||||
|
export interface ApplicationState {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const appReducer = combineReducers({
|
const appReducer = combineReducers({
|
||||||
authentication,
|
authentication,
|
||||||
organizations,
|
organizations,
|
||||||
@@ -69,7 +73,7 @@ const appReducer = combineReducers({
|
|||||||
paymentReceives,
|
paymentReceives,
|
||||||
paymentMades,
|
paymentMades,
|
||||||
inventoryAdjustments,
|
inventoryAdjustments,
|
||||||
plans,
|
plans: SubscriptionPlansSlice.reducer,
|
||||||
creditNotes,
|
creditNotes,
|
||||||
vendorCredit,
|
vendorCredit,
|
||||||
warehouseTransfers,
|
warehouseTransfers,
|
||||||
|
|||||||
Reference in New Issue
Block a user