-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pro subscription modal when api limit exhausts
- Loading branch information
1 parent
b6747bc
commit c718971
Showing
15 changed files
with
322 additions
and
24 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
|
||
import { ProModal } from "@/components/pro-modal"; | ||
|
||
export const ModalProvider = () => { | ||
const [isMounted, setIsMounted] = useState(false); | ||
|
||
useEffect(() => setIsMounted(true), []); | ||
|
||
if (!isMounted) return null; | ||
|
||
return ( | ||
<> | ||
<ProModal /> | ||
</> | ||
); | ||
}; |
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,77 @@ | ||
"use client"; | ||
|
||
import axios from "axios"; | ||
import { useState } from "react"; | ||
import { Check, Zap } from "lucide-react"; | ||
import { toast } from "react-hot-toast"; | ||
|
||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogDescription, | ||
DialogFooter | ||
} from "@/components/ui/dialog"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { Button } from "@/components/ui/button"; | ||
import { useProModal } from "@/hooks/use-pro-modal"; | ||
import { tools } from "@/constants"; | ||
import { Card } from "@/components/ui/card"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export const ProModal = () => { | ||
const proModal = useProModal(); | ||
const [loading, setLoading] = useState(false); | ||
|
||
const onSubscribe = async () => { | ||
try { | ||
setLoading(true); | ||
const response = await axios.get("/api/stripe"); | ||
|
||
window.location.href = response.data.url; | ||
} catch (error) { | ||
toast.error("Something went wrong"); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
|
||
return ( | ||
<Dialog open={proModal.isOpen} onOpenChange={proModal.onClose}> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle className="flex justify-center items-center flex-col gap-y-4 pb-2"> | ||
<div className="flex items-center gap-x-2 font-bold text-xl"> | ||
Upgrade to Genius | ||
<Badge variant="premium" className="uppercase text-sm py-1"> | ||
pro | ||
</Badge> | ||
</div> | ||
</DialogTitle> | ||
<DialogDescription className="text-center pt-2 space-y-2 text-zinc-900 font-medium"> | ||
{tools.map((tool) => ( | ||
<Card key={tool.href} className="p-3 border-black/5 flex items-center justify-between"> | ||
<div className="flex items-center gap-x-4"> | ||
<div className={cn("p-2 w-fit rounded-md", tool.bgColor)}> | ||
<tool.icon className={cn("w-6 h-6", tool.color)} /> | ||
</div> | ||
<div className="font-semibold text-sm"> | ||
{tool.label} | ||
</div> | ||
</div> | ||
<Check className="text-primary w-5 h-5" /> | ||
</Card> | ||
))} | ||
</DialogDescription> | ||
</DialogHeader> | ||
<DialogFooter> | ||
<Button disabled={loading} onClick={onSubscribe} size="lg" variant="premium" className="w-full"> | ||
Upgrade | ||
<Zap className="w-4 h-4 ml-2 fill-white" /> | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as React from "react" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const badgeVariants = cva( | ||
"inline-flex items-center rounded-full border px-2.5 py-0.25 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80", | ||
secondary: | ||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
destructive: | ||
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", | ||
outline: "text-foreground", | ||
premium: "bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-primary-foreground border-0" | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
}, | ||
} | ||
) | ||
|
||
export interface BadgeProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> { } | ||
|
||
function Badge({ className, variant, ...props }: BadgeProps) { | ||
return ( | ||
<div className={cn(badgeVariants({ variant }), className)} {...props} /> | ||
) | ||
} | ||
|
||
export { Badge, badgeVariants } |
Oops, something went wrong.