This commit is contained in:
Samandar Turgunboyev
2025-10-30 10:29:45 +05:00
parent 0154fa8950
commit 352efd6391
4 changed files with 320 additions and 161 deletions

View File

@@ -89,32 +89,6 @@ const SupportTours = () => {
});
};
if (isLoading) {
return (
<div className="flex flex-col items-center justify-center min-h-screen bg-slate-900 text-white gap-4 w-full">
<Loader2 className="w-10 h-10 animate-spin text-cyan-400" />
<p className="text-slate-400">{t("Ma'lumotlar yuklanmoqda...")}</p>
</div>
);
}
if (isError) {
return (
<div className="flex flex-col items-center justify-center min-h-screen bg-slate-900 w-full text-center text-white gap-4">
<AlertTriangle className="w-10 h-10 text-red-500" />
<p className="text-lg">
{t("Ma'lumotlarni yuklashda xatolik yuz berdi.")}
</p>
<Button
onClick={() => refetch()}
className="bg-gradient-to-r from-blue-600 to-cyan-600 text-white rounded-lg px-5 py-2 hover:opacity-90"
>
{t("Qayta urinish")}
</Button>
</div>
);
}
return (
<div className="min-h-screen bg-gray-900 text-gray-100 p-6 space-y-6 w-full">
<h1 className="text-3xl font-bold tracking-tight mb-4 text-white">
@@ -141,76 +115,100 @@ const SupportTours = () => {
</button>
))}
</div>
{/* Cards */}
<div className="grid gap-5 sm:grid-cols-3 lg:grid-cols-3">
{data && data.data.data.results.length === 0 ? (
<div className="col-span-full flex flex-col items-center justify-center min-h-[50vh] w-full text-center text-white gap-4">
<p className="text-lg">{t("Natija topilmadi")}</p>
</div>
) : (
data?.data.data.results.map((req) => (
<Card
key={req.id}
className="bg-gray-800/70 border border-gray-700 shadow-md hover:shadow-lg hover:bg-gray-800 transition-all duration-200 justify-between"
>
<CardHeader className="pb-2 flex justify-between items-center">
<div className="flex gap-2">
<CardTitle className="flex items-center gap-2 text-lg font-semibold text-white">
<User className="w-5 h-5 text-blue-400" />
{req.name}
</CardTitle>
{isError ? (
<div className="flex flex-col items-center justify-center min-h-screen bg-slate-900 w-full text-center text-white gap-4">
<AlertTriangle className="w-10 h-10 text-red-500" />
<p className="text-lg">
{t("Ma'lumotlarni yuklashda xatolik yuz berdi.")}
</p>
<Button
onClick={() => refetch()}
className="bg-gradient-to-r from-blue-600 to-cyan-600 text-white rounded-lg px-5 py-2 hover:opacity-90"
>
{t("Qayta urinish")}
</Button>
</div>
) : (
<>
{isLoading ? (
<div className="flex flex-col items-center justify-center min-h-screen bg-slate-900 text-white gap-4 w-full">
<Loader2 className="w-10 h-10 animate-spin text-cyan-400" />
<p className="text-slate-400">
{t("Ma'lumotlar yuklanmoqda...")}
</p>
</div>
) : (
<div className="grid gap-5 sm:grid-cols-3 lg:grid-cols-3">
{data && data.data.data.results.length === 0 ? (
<div className="col-span-full flex flex-col items-center justify-center min-h-[50vh] w-full text-center text-white gap-4">
<p className="text-lg">{t("Natija topilmadi")}</p>
</div>
<Badge
variant="outline"
className={`px-2 py-1 rounded-md text-xs font-medium ${
req.status === "pending"
? "bg-red-500/10 text-red-400 border-red-400/40"
: "bg-green-500/10 text-green-400 border-green-400/40"
}`}
>
{req.status === "pending" ? t("Kutilmoqda") : t("done")}
</Badge>
</CardHeader>
<CardContent className="space-y-3 mt-1">
{req.travel_agency !== null ? (
<span className="text-md text-gray-400">
{t("Agentlikka tegishli")}
</span>
) : (
<span className="text-md text-gray-400">
{t("Sayt bo'yicha")}
</span>
)}
<div className="flex items-center gap-2 mt-2 text-sm text-gray-400">
<Phone className="w-4 h-4 text-gray-400" />
{formatPhone(req.phone_number)}
</div>
<div className="grid grid-cols-2 justify-end items-end gap-2">
<Button
variant="outline"
size="sm"
className="mt-3 w-full border-gray-600 text-gray-200 hover:bg-gray-700 hover:text-white"
onClick={() => setSelected(req)}
) : (
data?.data.data.results.map((req) => (
<Card
key={req.id}
className="bg-gray-800/70 border border-gray-700 shadow-md hover:shadow-lg hover:bg-gray-800 transition-all duration-200 justify-between"
>
{t("Batafsil ko'rish")}
</Button>
<Button
size="sm"
variant="destructive"
className="flex items-center gap-1"
onClick={() => setSelectedToDelete(req)}
>
<Trash2 className="w-4 h-4" /> {t("O'chirish")}
</Button>
</div>
</CardContent>
</Card>
))
)}
</div>
<CardHeader className="pb-2 flex justify-between items-center">
<div className="flex gap-2">
<CardTitle className="flex items-center gap-2 text-lg font-semibold text-white">
<User className="w-5 h-5 text-blue-400" />
{req.name}
</CardTitle>
</div>
<Badge
variant="outline"
className={`px-2 py-1 rounded-md text-xs font-medium ${
req.status === "pending"
? "bg-red-500/10 text-red-400 border-red-400/40"
: "bg-green-500/10 text-green-400 border-green-400/40"
}`}
>
{req.status === "pending" ? t("Kutilmoqda") : t("done")}
</Badge>
</CardHeader>
<CardContent className="space-y-3 mt-1">
{req.travel_agency !== null ? (
<span className="text-md text-gray-400">
{t("Agentlikka tegishli")}
</span>
) : (
<span className="text-md text-gray-400">
{t("Sayt bo'yicha")}
</span>
)}
<div className="flex items-center gap-2 mt-2 text-sm text-gray-400">
<Phone className="w-4 h-4 text-gray-400" />
{formatPhone(req.phone_number)}
</div>
<div className="grid grid-cols-2 justify-end items-end gap-2">
<Button
variant="outline"
size="sm"
className="mt-3 w-full border-gray-600 text-gray-200 hover:bg-gray-700 hover:text-white"
onClick={() => setSelected(req)}
>
{t("Batafsil ko'rish")}
</Button>
<Button
size="sm"
variant="destructive"
className="flex items-center gap-1"
onClick={() => setSelectedToDelete(req)}
>
<Trash2 className="w-4 h-4" /> {t("O'chirish")}
</Button>
</div>
</CardContent>
</Card>
))
)}
</div>
)}
</>
)}
{/* Detail Modal */}
<Dialog open={!!selected} onOpenChange={() => setSelected(null)}>