image added and trnslation texts done and contact connnected to telegrtam chatBot all tasks done

This commit is contained in:
nabijonovdavronbek619@gmail.com
2025-11-11 14:34:17 +05:00
parent f963aaf2b8
commit c8c77f3788
9 changed files with 364 additions and 61 deletions

View File

@@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { MessageSquare } from "lucide-react";
import { useLanguage } from "@/contexts/language-context";
import axios from "axios";
export default function Contact() {
const [formData, setFormData] = useState({
@@ -25,9 +26,39 @@ export default function Contact() {
});
};
const handleSubmit = (e: React.FormEvent) => {
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// Handle form submission
try {
const token = "7940057045:AAHRFPvgUCo_7pqpXD6uq4li7-_DYx2J96g"; // Use environment variable
const chatId = 6134458285;
if (!token || !chatId) {
throw new Error("Telegram token yoki chat ID topilmadi!");
}
const message = `
📥 Yangi xabar keldi!
👤 Ism: ${formData.name}
📧 Email: ${formData.email}
💬 Xabar: ${formData.message}
`;
await axios.post(`https://api.telegram.org/bot${token}/sendMessage`, {
chat_id: chatId,
text: message,
});
alert("✅ Tez orada bog'lanamiz!");
setFormData({
name: "",
email: "",
message: "",
});
} catch (error) {
console.error("Yuborishda xatolik:", error);
alert("❌ Yuborishda xatolik yuz berdi!");
}
console.log(formData);
};
@@ -54,7 +85,7 @@ export default function Contact() {
name="name"
value={formData.name}
onChange={handleChange}
placeholder={t.contact.fields.name}
placeholder={t.contact.fields.name_placeholder}
className="bg-background border-border"
required
/>
@@ -69,7 +100,7 @@ export default function Contact() {
name="email"
value={formData.email}
onChange={handleChange}
placeholder={t.contact.fields.email}
placeholder={t.contact.fields.email_placeholder}
className="bg-background border-border"
required
/>
@@ -108,12 +139,14 @@ export default function Contact() {
<p className="text-muted-foreground mb-4">
{t.contact.whatsapp.desc}
</p>
<Button
variant="outline"
className="w-full border-primary text-primary hover:bg-primary/90 bg-transparent"
>
{t.contact.open}
</Button>
<a href="https://t.me/Felix_IT_solutions">
<Button
variant="outline"
className="w-full border-primary text-primary hover:bg-primary/90 bg-transparent"
>
{t.contact.open}
</Button>
</a>
</div>
<div className="bg-background rounded-xl p-6 border border-border">