|
|
@ -1,19 +1,11 @@ |
|
|
|
import { useQuery } from '@tanstack/react-query'; |
|
|
|
import { useQuery } from '@tanstack/react-query'; |
|
|
|
import { |
|
|
|
import { useState } from 'react'; |
|
|
|
BookIcon, |
|
|
|
|
|
|
|
BookOpenIcon, |
|
|
|
|
|
|
|
MessageCircleQuestionIcon, |
|
|
|
|
|
|
|
ChevronDownIcon, |
|
|
|
|
|
|
|
ClockIcon, |
|
|
|
|
|
|
|
BotIcon, |
|
|
|
|
|
|
|
} from 'lucide-react'; |
|
|
|
|
|
|
|
import { useState, useRef } from 'react'; |
|
|
|
|
|
|
|
import { getAiCourseLimitOptions } from '../../queries/ai-course'; |
|
|
|
import { getAiCourseLimitOptions } from '../../queries/ai-course'; |
|
|
|
import { queryClient } from '../../stores/query-client'; |
|
|
|
import { queryClient } from '../../stores/query-client'; |
|
|
|
import { useOutsideClick } from '../../hooks/use-outside-click'; |
|
|
|
|
|
|
|
import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal'; |
|
|
|
import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal'; |
|
|
|
import { billingDetailsOptions } from '../../queries/billing'; |
|
|
|
import { billingDetailsOptions } from '../../queries/billing'; |
|
|
|
import { getPercentage } from '../../helper/number'; |
|
|
|
import { getPercentage } from '../../helper/number'; |
|
|
|
|
|
|
|
import { Gift, Info } from 'lucide-react'; |
|
|
|
|
|
|
|
|
|
|
|
export function AICourseLimit() { |
|
|
|
export function AICourseLimit() { |
|
|
|
const [showUpgradeModal, setShowUpgradeModal] = useState(false); |
|
|
|
const [showUpgradeModal, setShowUpgradeModal] = useState(false); |
|
|
@ -28,7 +20,7 @@ export function AICourseLimit() { |
|
|
|
|
|
|
|
|
|
|
|
if (isLoading || !limits || isBillingDetailsLoading || !userBillingDetails) { |
|
|
|
if (isLoading || !limits || isBillingDetailsLoading || !userBillingDetails) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="h-[38px] w-[208.09px] animate-pulse rounded-lg border border-gray-200 bg-gray-200"></div> |
|
|
|
<div className="hidden h-[38px] w-[208.09px] animate-pulse rounded-lg border border-gray-200 bg-gray-200 lg:block"></div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -38,24 +30,30 @@ export function AICourseLimit() { |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<div className="relative flex h-full min-h-[38px] cursor-pointer items-center overflow-hidden rounded-lg border border-gray-200 px-3 py-1.5 text-sm hover:bg-gray-50"> |
|
|
|
<button className="mr-1 flex items-center gap-1 text-sm font-medium lg:hidden underline underline-offset-2"> |
|
|
|
|
|
|
|
<Info className="size-4" /> |
|
|
|
|
|
|
|
{totalPercentage}% of limit used |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button className="relative hidden h-full min-h-[38px] cursor-pointer items-center overflow-hidden rounded-lg border border-gray-300 px-3 py-1.5 text-sm hover:bg-gray-50 lg:flex"> |
|
|
|
<span className="relative z-10"> |
|
|
|
<span className="relative z-10"> |
|
|
|
{totalPercentage}% of the daily limit used |
|
|
|
{totalPercentage}% of the daily limit used |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<div |
|
|
|
<div |
|
|
|
className="absolute inset-0 h-full bg-gray-50" |
|
|
|
className="absolute inset-0 h-full bg-gray-200/80" |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
width: `${totalPercentage}%`, |
|
|
|
width: `${totalPercentage}%`, |
|
|
|
}} |
|
|
|
}} |
|
|
|
></div> |
|
|
|
></div> |
|
|
|
</div> |
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
|
|
{userBillingDetails.status === 'none' && ( |
|
|
|
{userBillingDetails.status === 'none' && ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<button |
|
|
|
<button |
|
|
|
className="ml-2 rounded-md border border-gray-200 px-2 py-1 text-sm hover:bg-gray-50" |
|
|
|
className="hidden items-center justify-center gap-1 rounded-md bg-yellow-400 px-4 py-1 text-sm font-medium underline-offset-2 hover:bg-yellow-500 lg:flex" |
|
|
|
onClick={() => setShowUpgradeModal(true)} |
|
|
|
onClick={() => setShowUpgradeModal(true)} |
|
|
|
> |
|
|
|
> |
|
|
|
|
|
|
|
<Gift className="size-4" /> |
|
|
|
Upgrade |
|
|
|
Upgrade |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
|
|