import React, { useState } from 'react'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../ui/card'; import { Button } from '../ui/button'; import { useIsLoggedIn } from '../../lib/isLoggedIn'; import Loader from "../ui/loader"; import { Loader2 } from "lucide-react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "../ui/dialog"; const PRICE_CONFIG = [ {purchaseType: 'loose', price: 2000, minute: 10000}, {purchaseType: 'bulk', price: 1000, minute: 10000} ]; export default function STTStreaming(){ const USER_API_URL = 'https://host-api.cs1.hz.siliconpin.com/v1/users/'; const [purchaseType, setPurchaseType] = useState(); const [amount, setAmount] = useState(); const [dataError, setDataError] = useState(); const [isProcessing, setIsProcessing] = useState(false); const handlePurchaseType = (type) => { const selected = PRICE_CONFIG.find(item => item.purchaseType === type); setAmount(type === 'bulk' ? selected.price : type === 'loose' ? selected.price : '') setPurchaseType(type); } const handlePurchase = async () => { // Validate inputs if (!purchaseType) { setDataError('Please select a Plan'); return; } setIsProcessing(true); setDataError(null); try { const formData = new FormData(); formData.append('service', 'STT Streaming API'); formData.append('serviceId', 'sttstreamingapi'); formData.append('cycle', 'monthly'); formData.append('amount', amount.toString()); formData.append('service_type', 'streaming_api'); const response = await fetch(`${USER_API_URL}?query=initiate_payment`, { method: 'POST', body: formData, // Using FormData instead of JSON credentials: 'include' }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); if (data.success) { // Redirect to payment success page with order ID window.location.href = `/success?service=streaming_api&orderId=${data.order_id}`; } else { throw new Error(data.message || 'Payment initialization failed'); } } catch (error) { console.error('Purchase error:', error); setDataError(error.message || 'An error occurred during purchase. Please try again.'); } finally { setIsProcessing(false); } }; if(!purchaseType){

{dataError}

} return( <>
STT Streaming API Real-time Speech-to-Text (STT) streaming that converts spoken words into accurate, readable text
    {['Setup Charge 5000', '10000 Min INR 2000 in Loose Plan', '10000 Min INR 1000 in Bulk Plan', 'Real-time transcription with high accuracy', 'Supports multiple languages', 'Custom vocabulary for domain-specific terms', 'Integrates easily with video/audio streams', 'Secure and scalable API access', 'Live subtitle overlay options'].map((feature, index) => (
  • {feature}
  • ))}
) }