diff --git a/src/components/panel/BuyANumber.tsx b/src/components/panel/BuyANumber.tsx index b668281..bcb0ff2 100644 --- a/src/components/panel/BuyANumber.tsx +++ b/src/components/panel/BuyANumber.tsx @@ -1,10 +1,8 @@ import { useState } from "react"; import { Send } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; import { Card } from "@/components/ui/card"; import { toast } from "sonner"; -import { supabase } from "@/lib/supabase"; import { CheckIcon, ChevronDownIcon } from "@radix-ui/react-icons"; import { Select, @@ -20,10 +18,6 @@ import { import countriesJson from "@/utils/countries.json"; import serviceJson from "@/utils/services.json"; -// const countries = Object.values(countriesJson).map((name) => ({ -// code: name.toLowerCase().replace(/\s/g, ""), // Creating a pseudo-code -// name, -// })); const countries = Object.entries(countriesJson).map(([code, name]) => ({ code, // Now it correctly stores the country code @@ -39,10 +33,8 @@ export function BuyANumber() { const [message, setMessage] = useState(""); const [phoneNumber, setPhoneNumber] = useState(""); const [isSending, setIsSending] = useState(false); - const [selectedCountry, setSelectedCountry] = useState("180"); + const [selectedCountry, setSelectedCountry] = useState("187"); const [selectedService, setSelectedService] = useState("fb"); - // const [selectedCountry, setSelectedCountry] = useState(countries[0]?.code || ""); - // const [selectedService, setSelectedService] = useState(services[0]?.name?.code || ""); const [response, setResponse] = useState(""); const handleSend = async () => { @@ -52,22 +44,23 @@ export function BuyANumber() { } try { const myHeaders = new Headers({ - Origin: window.location.origin, - "x-requested-with": "XMLHttpRequest", + Origin: "*", }); const requestOptions = { - method: "GET", + method: "POST", headers: myHeaders, + body: JSON.stringify({ + action: "getNumber", + selectedService, + selectedCountry + }) }; let apiResponse; - // Using a CORS proxy - const corsProxy = "https://cors-anywhere.herokuapp.com/"; - const apiUrl = `https://api.sms-activate.ae/stubs/handler_api.php?api_key=eA103094961490b3350620b1bdd57244&action=getNumber&service=${selectedService}&operator=any&country=${selectedCountry}&maxPrice=0.2250`; - // console.log(apiUrl); + const apiUrl= "https://ikmbnngahzcellthaysf.supabase.co/functions/v1/call-sms-gateway"; - await fetch(corsProxy + apiUrl, requestOptions) + await fetch(apiUrl, requestOptions) .then((response) => response.text()) .then((result) => (apiResponse = result)) .catch((error) => console.error(error)); diff --git a/src/components/panel/PhoneNumberList.tsx b/src/components/panel/PhoneNumberList.tsx index 1c820c1..0c2c2cd 100644 --- a/src/components/panel/PhoneNumberList.tsx +++ b/src/components/panel/PhoneNumberList.tsx @@ -10,25 +10,6 @@ interface PhoneNumber { status: "active" | "inactive"; } -const list = [ - { - "activationId": "3336974038", - "serviceCode": "fb", - "phoneNumber": "19892798946", - "activationCost": 0.225, - "activationStatus": "4", - "activationTime": "2025-03-03 19:22:40", - "countryCode": "187", - "countryName": "USA", - "canGetAnotherSms": "1", - "currency": 840, - "smsCode": 64744, - "smsText": null, - "discount": "0", - "repeated": "0" - } -] - export function PhoneNumberList() { const [numberList, setNumberList] = useState([]) @@ -40,13 +21,13 @@ export function PhoneNumberList() { }); const requestOptions = { - method: "GET", - headers: myHeaders + method: "POST", + headers: myHeaders, + body: JSON.stringify({ + action: "getActiveActivations", + }) }; - // const corsProxy = "https://cors-anywhere.herokuapp.com/"; - // const apiUrl = "https://api.sms-activate.ae/stubs/handler_api.php?api_key=eA103094961490b3350620b1bdd57244&action=getActiveActivations"; - // const response = await fetch(corsProxy + apiUrl, requestOptions) const response= await fetch("https://ikmbnngahzcellthaysf.supabase.co/functions/v1/call-sms-gateway", requestOptions) const data = await response.json() console.log(data)