mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-03 22:32:35 +02:00
wip
This commit is contained in:
@@ -28,6 +28,7 @@ import { queryClient } from '../../stores/query-client';
|
|||||||
import { billingDetailsOptions } from '../../queries/billing';
|
import { billingDetailsOptions } from '../../queries/billing';
|
||||||
import { LoadingChip } from '../LoadingChip';
|
import { LoadingChip } from '../LoadingChip';
|
||||||
import { getTailwindScreenDimension } from '../../lib/is-mobile';
|
import { getTailwindScreenDimension } from '../../lib/is-mobile';
|
||||||
|
import { useToast } from '../../hooks/use-toast';
|
||||||
|
|
||||||
type AIRoadmapChatProps = {
|
type AIRoadmapChatProps = {
|
||||||
roadmapSlug?: string;
|
roadmapSlug?: string;
|
||||||
@@ -38,6 +39,7 @@ type AIRoadmapChatProps = {
|
|||||||
export function AIRoadmapChat(props: AIRoadmapChatProps) {
|
export function AIRoadmapChat(props: AIRoadmapChatProps) {
|
||||||
const { roadmapSlug, isRoadmapLoading, onUpgrade } = props;
|
const { roadmapSlug, isRoadmapLoading, onUpgrade } = props;
|
||||||
|
|
||||||
|
const toast = useToast();
|
||||||
const scrollareaRef = useRef<HTMLDivElement>(null);
|
const scrollareaRef = useRef<HTMLDivElement>(null);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@@ -52,11 +54,8 @@ export function AIRoadmapChat(props: AIRoadmapChatProps) {
|
|||||||
refetch: refetchTokenUsage,
|
refetch: refetchTokenUsage,
|
||||||
} = useQuery(getAiCourseLimitOptions(), queryClient);
|
} = useQuery(getAiCourseLimitOptions(), queryClient);
|
||||||
|
|
||||||
const {
|
const { data: userBillingDetails, isLoading: isBillingDetailsLoading } =
|
||||||
data: userBillingDetails,
|
useQuery(billingDetailsOptions(), queryClient);
|
||||||
isLoading: isBillingDetailsLoading,
|
|
||||||
refetch: refetchBillingDetails,
|
|
||||||
} = useQuery(billingDetailsOptions(), queryClient);
|
|
||||||
|
|
||||||
const isLimitExceeded = (tokenUsage?.used || 0) >= (tokenUsage?.limit || 0);
|
const isLimitExceeded = (tokenUsage?.used || 0) >= (tokenUsage?.limit || 0);
|
||||||
const isPaidUser = userBillingDetails?.status === 'active';
|
const isPaidUser = userBillingDetails?.status === 'active';
|
||||||
@@ -72,9 +71,10 @@ export function AIRoadmapChat(props: AIRoadmapChatProps) {
|
|||||||
endpoint: `${import.meta.env.PUBLIC_API_URL}/v1-ai-roadmap-chat`,
|
endpoint: `${import.meta.env.PUBLIC_API_URL}/v1-ai-roadmap-chat`,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
toast.error(error?.message || 'Something went wrong');
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
roadmapSlug,
|
aiRoadmapSlug: roadmapSlug,
|
||||||
},
|
},
|
||||||
onFinish: () => {
|
onFinish: () => {
|
||||||
refetchTokenUsage();
|
refetchTokenUsage();
|
||||||
|
Reference in New Issue
Block a user