barcha apilar ulandi

This commit is contained in:
Samandar Turgunboyev
2025-10-31 18:42:21 +05:00
parent 39f5b8ca3c
commit 77bce24399
19 changed files with 1306 additions and 656 deletions

View File

@@ -40,7 +40,16 @@ import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { toast } from "sonner";
const Tours = () => {
type Role =
| "superuser"
| "admin"
| "moderator"
| "tour_admin"
| "buxgalter"
| "operator"
| "user";
const Tours = ({ user }: { user: Role }) => {
const { t } = useTranslation();
const [page, setPage] = useState(1);
const [deleteId, setDeleteId] = useState<number | null>(null);
@@ -133,7 +142,11 @@ const Tours = () => {
<div className="min-h-screen bg-gray-900 text-foreground py-10 px-5 w-full">
<div className="flex justify-between items-center mb-8">
<h1 className="text-3xl font-semibold">{t("Turlar ro'yxati")}</h1>
<Button onClick={() => navigate("/tours/create")} variant="default">
<Button
onClick={() => navigate("/tours/create")}
variant="default"
disabled={user !== "tour_admin"}
>
<PlusCircle className="w-5 h-5 mr-2" /> {t("Yangi tur qo'shish")}
</Button>
</div>
@@ -149,9 +162,11 @@ const Tours = () => {
</TableHead>
<TableHead className="min-w-[180px]">{t("Mehmonxona")}</TableHead>
<TableHead className="min-w-[200px]">{t("Narxi")}</TableHead>
<TableHead className="min-w-[120px] text-center">
{t("Popular")}
</TableHead>
{user && user === "moderator" && (
<TableHead className="min-w-[120px] text-center">
{t("Popular")}
</TableHead>
)}
<TableHead className="min-w-[150px] text-center">
{t("Операции")}
</TableHead>
@@ -170,7 +185,7 @@ const Tours = () => {
</div>
</TableCell>
<TableCell className="text-sm text-primary font-medium">
{tour.duration_days} kun
{tour.duration_days} {t("kun")}
</TableCell>
<TableCell>
<div className="flex flex-col">
@@ -185,18 +200,19 @@ const Tours = () => {
{formatPrice(tour.price, true)}
</span>
</TableCell>
<TableCell className="text-center">
<Switch
checked={tour.featured_tickets}
onCheckedChange={() =>
popular({
id: tour.id,
value: tour.featured_tickets ? 0 : 1,
})
}
/>
</TableCell>
{user && user === "moderator" && (
<TableCell className="text-center">
<Switch
checked={tour.featured_tickets}
onCheckedChange={() =>
popular({
id: tour.id,
value: tour.featured_tickets ? 0 : 1,
})
}
/>
</TableCell>
)}
<TableCell className="text-center">
<div className="flex gap-2 justify-center">