-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(saas): Switch subscription modal
- Loading branch information
1 parent
a0e889a
commit 6a353c7
Showing
3 changed files
with
106 additions
and
23 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
66 changes: 66 additions & 0 deletions
66
starterkits/saas/src/app/(app)/(user)/org/billing/_components/switch-plan-modal.tsx
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,66 @@ | ||
"use client"; | ||
|
||
import { SubscribeBtn } from "@/app/(app)/(user)/org/billing/_components/subscribe-btn"; | ||
import { | ||
AlertDialog, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogTrigger, | ||
} from "@/components/ui/alert-dialog"; | ||
import { Button } from "@/components/ui/button"; | ||
import { useState } from "react"; | ||
|
||
type SwitchPlanModalProps = { | ||
variantId: number | undefined; | ||
lastCardDigits: string; | ||
cardBrand: string; | ||
currencySymbol: string; | ||
price: number; | ||
currencyCode: string; | ||
planName: string; | ||
}; | ||
|
||
export function SwitchPlanModal({ | ||
cardBrand, | ||
currencyCode, | ||
currencySymbol, | ||
lastCardDigits, | ||
planName, | ||
price, | ||
variantId, | ||
}: SwitchPlanModalProps) { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
|
||
return ( | ||
<AlertDialog open={isOpen} onOpenChange={(o) => setIsOpen(o)}> | ||
<AlertDialogTrigger asChild> | ||
<Button variant="outline" className="w-full"> | ||
Switch to {currencySymbol} | ||
{price} {currencyCode} per month | ||
</Button> | ||
</AlertDialogTrigger> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle> | ||
Are you sure you want to switch to the {planName} plan? | ||
</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
You will be charged the pro-rated amount for the rest of | ||
plan. Your billing card brand{" "} | ||
<strong className="capitalize">{cardBrand}</strong>{" "} | ||
ending in <strong>{lastCardDigits}</strong> will be | ||
charged. | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>Cancel</AlertDialogCancel> | ||
<SubscribeBtn variantId={variantId}>Continue</SubscribeBtn> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
} |
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