slider component updated
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { innerCardTypes } from "@/types";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import axios from "axios";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
interface CarRentalModalProps {
|
||||
car: innerCardTypes;
|
||||
@@ -16,7 +16,7 @@ export default function CarRentalModal({
|
||||
isOpen,
|
||||
onClose,
|
||||
}: CarRentalModalProps) {
|
||||
const { t } = useTranslation();
|
||||
const t = useTranslations();
|
||||
const [userName, setUserName] = useState("");
|
||||
const [phone, setPhone] = useState("+998 ");
|
||||
const [phoneError, setPhoneError] = useState("");
|
||||
@@ -50,7 +50,6 @@ export default function CarRentalModal({
|
||||
if (phoneError) setPhoneError("");
|
||||
};
|
||||
|
||||
// 🧩 Telegramga yuboruvchi funksiya
|
||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -65,13 +64,11 @@ export default function CarRentalModal({
|
||||
}
|
||||
|
||||
try {
|
||||
// ⚙️ Telegram bot ma'lumotlari
|
||||
const token =
|
||||
process.env.NEXT_PUBLIC_TELEGRAM_TOKEN ||
|
||||
"7940057045:AAHRFPvgUCo_7pqpXD6uq4li7-_DYx2J96g";
|
||||
const chatId = process.env.NEXT_PUBLIC_TELEGRAM_CHAT_ID || "6134458285";
|
||||
|
||||
// 🧾 Yuboriladigan xabar
|
||||
const message = `
|
||||
🚗 *Yangi buyurtma!*
|
||||
|
||||
@@ -82,14 +79,13 @@ export default function CarRentalModal({
|
||||
💰 Umumiy summa: ${total?.toLocaleString("uz-UZ")} UZS
|
||||
|
||||
📦 Mashina: ${car.name}
|
||||
⛽️ Yoqilg‘i turi: ${car.fuelType || "Noma’lum"}
|
||||
⛽️ Yoqilg'i turi: ${car.fuelType || "Noma'lum"}
|
||||
⚙️ Dvigatel: ${car.enginePower_hp || "-"}
|
||||
🚀 Maks tezlik: ${car.maxSpeed_kmh ? car.maxSpeed_kmh + " km/soat" : "-"}
|
||||
|
||||
📝 Qo‘shimcha ma’lumot: ${car.path || "-"}
|
||||
📝 Qo'shimcha ma'lumot: ${car.path || "-"}
|
||||
`;
|
||||
|
||||
// 📤 Telegram API orqali yuborish
|
||||
await axios.post(`https://api.telegram.org/bot${token}/sendMessage`, {
|
||||
chat_id: chatId,
|
||||
text: message,
|
||||
@@ -112,7 +108,6 @@ export default function CarRentalModal({
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4">
|
||||
<div className="bg-white rounded-xl shadow-xl max-w-lg w-full p-6 relative animate-fade-in">
|
||||
{/* Close button */}
|
||||
<button
|
||||
className="absolute top-4 right-4 text-gray-500 hover:text-gray-900 text-2xl font-bold transition"
|
||||
onClick={onClose}
|
||||
@@ -120,7 +115,6 @@ export default function CarRentalModal({
|
||||
×
|
||||
</button>
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex flex-col md:flex-row gap-4">
|
||||
<div className="flex-1">
|
||||
<h2 className="text-2xl font-bold text-gray-800">{car.name}</h2>
|
||||
@@ -129,14 +123,14 @@ export default function CarRentalModal({
|
||||
{t("modal-hourly-price")}{" "}
|
||||
<span className="text-red-600">
|
||||
{car.price
|
||||
? Math.round(Number(car.price)).toLocaleString("ru-RU")
|
||||
: ""} UZS
|
||||
? Math.round(Number(car.price)).toLocaleString("ru-RU")
|
||||
: ""}{" "}
|
||||
UZS
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Form */}
|
||||
<form onSubmit={handleSubmit} className="mt-6 space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
@@ -186,9 +180,8 @@ export default function CarRentalModal({
|
||||
<div className="text-lg font-semibold text-gray-800 mt-2">
|
||||
{t("modal-total")}{" "}
|
||||
<span className="text-green-600">
|
||||
{total
|
||||
? Math.round(Number(total)).toLocaleString("ru-RU")
|
||||
: ""} UZS
|
||||
{total ? Math.round(Number(total)).toLocaleString("ru-RU") : ""}{" "}
|
||||
UZS
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user