|
1 | 1 | "use client";
|
2 | 2 |
|
3 | 3 | import { getStripeClient } from "@/client-only/stripe";
|
4 |
| -import Modal, { type ModalProps } from "@/components/common/modal"; |
5 |
| -import { Button } from "@/components/ui/button"; |
| 4 | + |
| 5 | +import { |
| 6 | + Dialog, |
| 7 | + DialogContent, |
| 8 | + DialogHeader, |
| 9 | + DialogTitle, |
| 10 | +} from "@/components/ui/dialog"; |
6 | 11 | import type { PricingPlanInterval, PricingType } from "@/prisma/enums";
|
7 | 12 | import { api } from "@/trpc/react";
|
8 | 13 | import type { TypeZodStripePortalMutationSchema } from "@/trpc/routers/billing-router/schema";
|
9 | 14 | import type { RouterOutputs } from "@/trpc/shared";
|
10 |
| -import { useRouter } from "next/navigation"; |
11 |
| -import { useState } from "react"; |
| 15 | +import { useRouter, useSearchParams } from "next/navigation"; |
| 16 | +import { useEffect, useState } from "react"; |
12 | 17 | import { EmptyPlans } from "./empty-plans";
|
13 | 18 | import { PricingButton } from "./pricing-button";
|
14 | 19 | import { PricingCard } from "./pricing-card";
|
@@ -170,13 +175,32 @@ export function Pricing({ products, subscription }: PricingProps) {
|
170 | 175 | export type PricingModalProps = PricingProps;
|
171 | 176 |
|
172 | 177 | export function PricingModal({ products, subscription }: PricingModalProps) {
|
| 178 | + const [open, setOpen] = useState(false); |
| 179 | + const router = useRouter(); |
| 180 | + const searchParams = useSearchParams(); |
| 181 | + const upgrade = searchParams.get("upgrade"); |
| 182 | + useEffect(() => { |
| 183 | + const isOpen = upgrade === "true"; |
| 184 | + if (isOpen) { |
| 185 | + setOpen(true); |
| 186 | + } |
| 187 | + }, [upgrade]); |
| 188 | + |
173 | 189 | return (
|
174 |
| - <Modal |
175 |
| - title="Upgrade or manage plans" |
176 |
| - trigger={<Button variant="secondary">Upgrade or Manage plan</Button>} |
177 |
| - size="screen" |
| 190 | + <Dialog |
| 191 | + open={open} |
| 192 | + onOpenChange={() => { |
| 193 | + router.back(); |
| 194 | + }} |
178 | 195 | >
|
179 |
| - <Pricing products={products} subscription={subscription} /> |
180 |
| - </Modal> |
| 196 | + <DialogContent className="max-w-[95vw]"> |
| 197 | + <DialogHeader className="flex items-center justify-center"> |
| 198 | + <DialogTitle>Upgrade or manage plans</DialogTitle> |
| 199 | + </DialogHeader> |
| 200 | + <div className="overflow-scroll no-scrollbar max-h-[80vh]"> |
| 201 | + <Pricing products={products} subscription={subscription} /> |
| 202 | + </div> |
| 203 | + </DialogContent> |
| 204 | + </Dialog> |
181 | 205 | );
|
182 | 206 | }
|
0 commit comments