Skip to content

Commit

Permalink
Plan/Subscription: fix model and add type (#2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph authored Oct 25, 2023
1 parent 7807811 commit 698df45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions front/lib/models/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Plan extends Model<
declare name: string;

// workspace limitations
declare maxWeeklyMessages: number;
declare maxMessages: number;
declare maxUsersInWorkspace: number;
declare isSlackbotAllowed: boolean;
declare isManagedSlackAllowed: boolean;
Expand Down Expand Up @@ -60,7 +60,7 @@ Plan.init(
type: DataTypes.STRING,
allowNull: false,
},
maxWeeklyMessages: {
maxMessages: {
type: DataTypes.INTEGER,
allowNull: false,
},
Expand Down Expand Up @@ -117,7 +117,7 @@ export class Subscription extends Model<
declare updatedAt: CreationOptional<Date>;

declare sId: string; // unique
declare status: string; // "active" | "ended"
declare status: "active" | "ended" | "cancelled";
declare startDate: Date;
declare endDate: Date | null;

Expand Down Expand Up @@ -152,7 +152,7 @@ Subscription.init(
type: DataTypes.STRING,
allowNull: false,
validate: {
isIn: [["active", "ended"]],
isIn: [["active", "ended", "cancelled"]],
},
},
startDate: {
Expand Down Expand Up @@ -196,7 +196,7 @@ Subscription.addHook(

// Plan <> Subscription relationship: attribute "planId" in Subscription
Plan.hasMany(Subscription, {
foreignKey: { name: "workspaceId", allowNull: false },
foreignKey: { name: "planId", allowNull: false },
onDelete: "CASCADE",
});
Subscription.belongsTo(Plan, {
Expand Down
4 changes: 2 additions & 2 deletions front/lib/plans/free_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const FREE_PLANS_DATA: PlanAttributes[] = [
{
code: "TEST_PLAN_V0",
name: "Test",
maxWeeklyMessages: 50,
maxMessages: 50,
maxUsersInWorkspace: 1,
isSlackbotAllowed: false,
isManagedSlackAllowed: false,
Expand All @@ -26,7 +26,7 @@ const FREE_PLANS_DATA: PlanAttributes[] = [
{
code: "TRIAL_PLAN_V0",
name: "Free Trial",
maxWeeklyMessages: -1,
maxMessages: -1,
maxUsersInWorkspace: -1,
isSlackbotAllowed: true,
isManagedSlackAllowed: true,
Expand Down

0 comments on commit 698df45

Please sign in to comment.