diff --git a/front/components/app/ReachedLimitPopup.tsx b/front/components/app/ReachedLimitPopup.tsx new file mode 100644 index 000000000000..e811ec29c44a --- /dev/null +++ b/front/components/app/ReachedLimitPopup.tsx @@ -0,0 +1,64 @@ +import { Dialog } from "@dust-tt/sparkle"; +import type { SubscriptionType } from "@dust-tt/types"; +import { useRouter } from "next/router"; + +import { isTrial } from "@app/lib/plans/trial"; + +function getUpsellDialogDetailsForFreeTrial() { + return { + title: "You’ve reach the Free Trial daily messages limit", + validateLabel: "Skip trial & upgrade now", + children: ( +
+ Come back tomorrow for a fresh start or{" "} + skip the trial and start paying now. +
+ ), + }; +} + +function getUpsellDialogDetailsForFreePlan() { + return { + title: "You’ve reach the messages limit", + validateLabel: "Check Dust plans", + children: ( ++ Looks like you've used up all your messages. Check out our paid plans to + get unlimited messages. +
+ ), + }; +} + +export function ReachedLimitPopup({ + isOpened, + onClose, + subscription, + workspaceId, +}: { + isOpened: boolean; + onClose: () => void; + subscription: SubscriptionType; + workspaceId: string; +}) { + const router = useRouter(); + + const { children, title, validateLabel } = isTrial(subscription) + ? getUpsellDialogDetailsForFreeTrial() + : getUpsellDialogDetailsForFreePlan(); + + return ( + + ); +} diff --git a/front/lib/models/plan.ts b/front/lib/models/plan.ts index 60968294c1ec..2a7c278c5b2d 100644 --- a/front/lib/models/plan.ts +++ b/front/lib/models/plan.ts @@ -106,8 +106,7 @@ Plan.init( }, maxMessagesTimeframe: { type: DataTypes.ENUM("day", "lifetime"), - // TODO(2024-03-18 flav) Set to false, once migrated. - allowNull: true, + allowNull: false, }, maxUsersInWorkspace: { type: DataTypes.INTEGER, diff --git a/front/package-lock.json b/front/package-lock.json index 460f7a390191..4425d11bae8c 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -150,7 +150,6 @@ "devDependencies": { "@tsconfig/recommended": "^1.0.3", "@types/uuid": "^9.0.7", - "sequelize": "^6.31.0", "tslib": "^2.6.2", "typescript": "^5.0.3" }, diff --git a/front/pages/w/[wId]/assistant/[cId]/index.tsx b/front/pages/w/[wId]/assistant/[cId]/index.tsx index 14e8a3941bbf..5ec349c67587 100644 --- a/front/pages/w/[wId]/assistant/[cId]/index.tsx +++ b/front/pages/w/[wId]/assistant/[cId]/index.tsx @@ -5,6 +5,7 @@ import { useRouter } from "next/router"; import type { ReactElement } from "react"; import { useContext, useEffect, useState } from "react"; +import { ReachedLimitPopup } from "@app/components/app/ReachedLimitPopup"; import { AssistantDetails } from "@app/components/assistant/AssistantDetails"; import Conversation from "@app/components/assistant/conversation/Conversation"; import type { ConversationLayoutProps } from "@app/components/assistant/conversation/ConversationLayout"; @@ -13,7 +14,6 @@ import { FixedAssistantInputBar } from "@app/components/assistant/conversation/i import { submitMessage } from "@app/components/assistant/conversation/lib"; import { SendNotificationsContext } from "@app/components/sparkle/Notification"; import { withDefaultUserAuthRequirements } from "@app/lib/iam/session"; -import { LimitReachedPopup } from "@app/pages/w/[wId]/assistant/new"; const { URL = "", GA_TRACKING_ID = "" } = process.env; @@ -154,7 +154,7 @@ export default function AssistantConversation({ stickyMentions={stickyMentions} conversationId={conversationId} /> -