-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up fair limits SQL schema + remove legacy dialog (#4358)
* Clean up fair limits SQL schema + remove legacy dialog * Move to a dedicated component * 👕
- Loading branch information
Showing
5 changed files
with
69 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ( | ||
<p className="text-sm font-normal text-element-800"> | ||
Come back tomorrow for a fresh start or{" "} | ||
<span className="font-bold">skip the trial and start paying now.</span> | ||
</p> | ||
), | ||
}; | ||
} | ||
|
||
function getUpsellDialogDetailsForFreePlan() { | ||
return { | ||
title: "You’ve reach the messages limit", | ||
validateLabel: "Check Dust plans", | ||
children: ( | ||
<p className="text-sm font-normal text-element-800"> | ||
Looks like you've used up all your messages. Check out our paid plans to | ||
get unlimited messages. | ||
</p> | ||
), | ||
}; | ||
} | ||
|
||
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 ( | ||
<Dialog | ||
isOpen={isOpened} | ||
title={title} | ||
onValidate={() => { | ||
void router.push(`/w/${workspaceId}/subscription`); | ||
}} | ||
onCancel={() => onClose()} | ||
cancelLabel="Close" | ||
validateLabel={validateLabel} | ||
> | ||
{children} | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters