fixed some ui, upgrade functionalitym added permission to operator
This commit is contained in:
1 parent
25c104ad8c
commit
5ed4c9a8ec
46 files changed
+1058
-1401
No files matched your search
@@ -1,21 +1,10 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Trash2, Database, CheckCircle2, XCircle, Clock, AlertCircle } from "lucide-react";
|
||||
import { Download, Database, CheckCircle2, XCircle, Clock, AlertCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { useBackup, useDeleteBackup, useDownloadBackup } from "@/features/backups/hooks/useBackups";
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
import { InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import type { BackupStatus } from "@/features/backups/api/backupsApi";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
@@ -43,8 +32,6 @@ export default function BackupViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useBackup(numericId);
|
||||
const deleteMutation = useDeleteBackup();
|
||||
@@ -92,14 +79,11 @@ export default function BackupViewPage() {
|
||||
>
|
||||
<Download size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteDescription={t("backups.deleteConfirm.description", "Bu backup pozulsynmy? Bu amal yzyna gaýtarylmaz.")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -120,24 +104,6 @@ export default function BackupViewPage() {
|
||||
<InfoRow label={t("backups.col.createdAt", "Döredilen wagty")} value={formatFromApiDate(data.createdAt)} />
|
||||
<InfoRow label={t("Updated at", "Täzelenen wagty")} value={formatFromApiDate(data.updatedAt)} />
|
||||
</div>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("Are you sure?", "Eminsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("backups.deleteConfirm.description", "Bu backup pozulsynmy? Bu amal yzyna gaýtarylmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteMutation.isPending ? t("Deleting...", "Öçürilýär...") : t("Delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +1,9 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { useCardBalance, useDeleteCardBalance } from "@/features/cardBalance/hooks/useCardBalance";
|
||||
import { InfoRow } from "@/components/viewPageComponents";
|
||||
import { InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import type { CardBalanceStatus } from "@/features/cardBalance/api/cardBalanceApi";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
@@ -44,8 +32,6 @@ export default function CardBalanceViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useCardBalance(numericId);
|
||||
const deleteMutation = useDeleteCardBalance();
|
||||
@@ -83,19 +69,12 @@ export default function CardBalanceViewPage() {
|
||||
{t("Card balance detail", "Kart galyndysy giňişleýin")}: #{data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<Link to={`/card-balances/${numericId}/edit`}>
|
||||
<Pencil size={14} />
|
||||
</Link>
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/card-balances/${numericId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteDescription={t("This action cannot be undone.", "Bu amal yzyna gaýtarylmaz. Kart galyndysy hemişelik öçüriler.")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -119,24 +98,6 @@ export default function CardBalanceViewPage() {
|
||||
<InfoRow label={t("Created at", "Döredilen wagty")} value={formatFromApiDate(data.createdAt)} />
|
||||
<InfoRow label={t("Updated at", "Täzelenen wagty")} value={formatFromApiDate(data.updatedAt)} />
|
||||
</div>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("Are you sure?", "Eminsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("This action cannot be undone.", "Bu amal yzyna gaýtarylmaz. Kart galyndysy hemişelik öçüriler.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteMutation.isPending ? t("Deleting...", "Öçürilýär...") : t("Delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,24 +1,10 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useCardPin, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, ViewActions } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
@@ -84,11 +70,9 @@ export default function CardPinViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading, isError } = useCardPin(numericId);
|
||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin();
|
||||
const deleteMutation = useDeleteCardPin();
|
||||
|
||||
if (isLoading) return <CardPinViewSkeleton />;
|
||||
|
||||
@@ -103,46 +87,13 @@ export default function CardPinViewPage() {
|
||||
<h1 className="text-xl font-bold text-foreground">
|
||||
{t("cardPin.viewTitle", "Kart pin bukja giňişleýin")}: <span className="text-primary font-mono">{data.uniqueId}</span>
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("cardPin.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>{t("cardPin.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")}</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() => deletePin(data.id, { onSuccess: () => navigate("/card-pins") })}
|
||||
>
|
||||
{isDeleting ? t("common.deleting", "Pozulýar...") : t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8"
|
||||
onClick={() => navigate(`/card-pins/${numericId}/edit`)}
|
||||
title={t("common.edit", "Düzet")}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
<ViewActions
|
||||
editTo={`/card-pins/${numericId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(data.id).then(() => navigate("/card-pins"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("cardPin.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
deleteDescription={t("cardPin.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
|
||||
@@ -1,25 +1,14 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ArrowLeft, Pencil, Trash2 } from "lucide-react";
|
||||
import { ArrowLeft } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { useCardRequisite, useDeleteCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { resolveLocalizedName } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, ViewActions } from "@/components/viewPageComponents";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
@@ -75,7 +64,6 @@ export default function CardRequisiteViewPage() {
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading, isError } = useCardRequisite(numericId);
|
||||
const deleteMutation = useDeleteCardRequisite();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
if (isLoading) {
|
||||
return <CardRequisiteViewSkeleton />;
|
||||
@@ -99,42 +87,13 @@ export default function CardRequisiteViewPage() {
|
||||
{t("cardRequisite.viewTitle", "Kart rekwizit giňişleýin")}: {data.id}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogTitle asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardRequisite.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} {data.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteMutation.isPending}>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() => deleteMutation.mutate(data.id, { onSuccess: () => navigate("/card-requisites") })}
|
||||
>
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8" onClick={() => navigate(`/card-requisites/${id}/edit`)}>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
<ViewActions
|
||||
editTo={`/card-requisites/${id}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(data.id).then(() => navigate("/card-requisites"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
deleteDescription={`${t("cardRequisite.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} ${data.id}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ────────────────────────────────── */}
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { useCardTransaction, useDeleteCardTransaction } from "@/features/cardTransactions/hooks/useCardTransactions";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import i18n from "@/lib/i18n";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
@@ -26,8 +13,6 @@ export default function CardTransactionViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useCardTransaction(numericId);
|
||||
const deleteMutation = useDeleteCardTransaction();
|
||||
@@ -64,21 +49,15 @@ export default function CardTransactionViewPage() {
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("Card transaction detail", "Kart giňişleýin")}: <span className="text-primary font-mono">{data.number}</span>
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1.5 text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" className="gap-1.5" asChild>
|
||||
<Link to={`/card-transactions/${numericId}/edit`}>
|
||||
<Pencil size={14} />
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
<ViewActions
|
||||
editTo={`/card-transactions/${numericId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteDescription={t(
|
||||
"This action cannot be undone. This will permanently delete the card.",
|
||||
"Bu amal yzyna gaýtarylmaz. Kart hemişelik öçüriler.",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Detail cards */}
|
||||
@@ -115,27 +94,6 @@ export default function CardTransactionViewPage() {
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("Are you sure?", "Eminsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
"This action cannot be undone. This will permanently delete the card.",
|
||||
"Bu amal yzyna gaýtarylmaz. Kart hemişelik öçüriler.",
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteMutation.isPending ? t("Deleting...", "Öçürilýär...") : t("Delete", "Öçür")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Printer, Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useCardById, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
@@ -83,8 +70,6 @@ export default function CardOrderDetailPage() {
|
||||
const navigate = useNavigate();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useCardById(Number(id));
|
||||
const deleteMutation = useDeleteCard();
|
||||
|
||||
@@ -106,27 +91,13 @@ export default function CardOrderDetailPage() {
|
||||
</h1>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<Button variant="outline" size="icon" title={t("common.print", "Çap etmek")}>
|
||||
<Printer size={15} />
|
||||
</Button>
|
||||
<Button variant="outline" size="icon" title={t("common.export", "Eksport")}>
|
||||
<Download size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-destructive hover:text-destructive hover:bg-destructive/10 border-destructive/20"
|
||||
title={t("common.delete", "Pozmak")}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button size="sm" asChild>
|
||||
<Link to={`/order-new-card/${order.id}/edit`}>
|
||||
<Pencil size={14} className="mr-1.5" />
|
||||
{t("common.edit", "Düzetmek")}
|
||||
</Link>
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/order-new-card/${order.id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
deleteDescription={t("cardOrder.deleteDescription", "Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -225,24 +196,6 @@ export default function CardOrderDetailPage() {
|
||||
<PassportImage label={t("cardOrder.field.passportFour", "Pasport 4")} src={order.passportFour || "—"} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Delete confirm dialog ─────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardOrder.deleteDescription", "Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteMutation.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Pozmak")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
// pages/CurrencyRateDetailPage.tsx
|
||||
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useGetCurrencyRateById, useDeleteCurrencyRate } from "@/features/currencyRates/hooks/useCurrencyRates";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── CurrencyRateDetailPage ───────────────────────────────────────────────────
|
||||
@@ -19,12 +15,10 @@ export default function CurrencyRateDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data: rate, isLoading } = useGetCurrencyRateById(numericId);
|
||||
const deleteMutation = useDeleteCurrencyRate();
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(numericId);
|
||||
navigate("/currency-rates");
|
||||
};
|
||||
@@ -58,24 +52,17 @@ export default function CurrencyRateDetailPage() {
|
||||
{t("currencyRates.detail.title", "Walýuta kursy giňişleýin")}: {rate.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-destructive"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
title={t("common.delete", "Pozmak")}
|
||||
>
|
||||
<Trash2 size={18} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
onClick={() => navigate(`/currency-rates/${rate.id}/edit`)}
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={18} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/currency-rates/${numericId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("currencyRates.deleteDialog.title", "Pozmak isleýärsiňizmi?")}
|
||||
deleteDescription={t(
|
||||
"currencyRates.deleteDialog.description",
|
||||
"Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.",
|
||||
)}
|
||||
deleteConfirmLabel={t("common.delete", "Pozmak")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -100,16 +87,6 @@ export default function CurrencyRateDetailPage() {
|
||||
<InfoRow label={t("common.createdAt", "Döredilen senesi")} value={formatFromApiDate(rate.createdAt)} />
|
||||
<InfoRow label={t("common.updatedAt", "Üýtgedilen senesi")} value={formatFromApiDate(rate.updatedAt)} />
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("currencyRates.deleteDialog.title", "Pozmak isleýärsiňizmi?")}
|
||||
description={t("currencyRates.deleteDialog.description", "Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.")}
|
||||
confirmLabel={deleteMutation.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Pozmak")}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
import { format } from "date-fns";
|
||||
import { Trash2, Edit, Search, Download, XCircle, CheckCircle2, AlertCircle } from "lucide-react";
|
||||
import { Search, Download, XCircle, CheckCircle2, AlertCircle } from "lucide-react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { useSberPaymentOrder, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import type { PaymentPaidStatus, PaymentStatus } from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import { useState } from "react";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -119,7 +118,6 @@ export default function SberPaymentViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [historySearch, setHistorySearch] = useState("");
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id!);
|
||||
const deleteMutation = useDeleteSberPayment();
|
||||
@@ -160,21 +158,13 @@ export default function SberPaymentViewPage() {
|
||||
{t("sberPayments.viewTitle", "Sberbank töleg")}: {order.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/sber-payments/${id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Edit size={16} />
|
||||
</button>
|
||||
<ViewActions
|
||||
editTo={`/sber-payments/${id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("sberPayments.deleteDialog.title", "Bu tölegi pozmak isleýärsiňizmi?")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -281,15 +271,6 @@ export default function SberPaymentViewPage() {
|
||||
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("sberPayments.deleteDialog.title", "Bu tölegi pozmak isleýärsiňizmi?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, Download, Search, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { Download, Search, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
import type { IntlPaymentStatus } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
@@ -98,13 +97,13 @@ export default function IntlPaymentViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const [historySearch, setHistorySearch] = useState("");
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data, isLoading, isError } = useIntlPayment(id!);
|
||||
const { mutate: deletePayment, isPending: isDeleting } = useDeleteIntlPayment();
|
||||
|
||||
const confirmDelete = () => {
|
||||
deletePayment(data!.id, { onSuccess: () => navigate("/visa-master") });
|
||||
const handleDelete = async () => {
|
||||
await deletePayment(data!.id);
|
||||
navigate("/visa-master");
|
||||
};
|
||||
|
||||
if (isLoading) return <IntlPaymentViewSkeleton />;
|
||||
@@ -171,21 +170,14 @@ export default function IntlPaymentViewPage() {
|
||||
{t("intlPayment.viewTitle", "Halkara töleg")}: {data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => navigate(`/intl-payments/visa-master/${id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
<ViewActions
|
||||
editTo={`/intl-payments/visa-master/${id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={isDeleting}
|
||||
deleteTitle={t("intlPayment.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
deleteDescription={t("intlPayment.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -285,16 +277,6 @@ export default function IntlPaymentViewPage() {
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("intlPayment.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
description={`${t("intlPayment.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} ${data?.id}`}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={isDeleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { useLoanOrderMobileById, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
@@ -56,18 +53,12 @@ export default function LoanOrderMobilesViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanOrderMobile();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useLoanOrderMobileById(id!);
|
||||
|
||||
const handleDelete = () => {
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => navigate("/loan-order-mobiles"),
|
||||
});
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(id!);
|
||||
navigate("/loan-order-mobiles");
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanOrderMobilesViewSkeleton />;
|
||||
@@ -100,21 +91,13 @@ export default function LoanOrderMobilesViewPage() {
|
||||
{t("loanOrderMobiles.view.title", "Karz sargyt giriş")}: {order.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/loan-order-mobiles/${order.id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
<ViewActions
|
||||
editTo={`/loan-order-mobiles/${order.id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("loanOrderMobiles.deleteConfirm", "Bu sargyt pozulsynmy?")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -384,15 +367,6 @@ export default function LoanOrderMobilesViewPage() {
|
||||
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanOrderMobiles.deleteConfirm", "Bu sargyt pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { useLoanOrderById, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
@@ -63,18 +60,12 @@ export default function LoanOrderViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanOrder();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useLoanOrderById(id!);
|
||||
|
||||
const handleDelete = () => {
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => navigate("/loan-orders"),
|
||||
});
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(id!);
|
||||
navigate("/loan-orders");
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanOrderViewSkeleton />;
|
||||
@@ -107,21 +98,13 @@ export default function LoanOrderViewPage() {
|
||||
{t("loanOrders.view.title", "Karz sargyt giriş")}: {order.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/loan-orders/${order.id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
<ViewActions
|
||||
editTo={`/loan-orders/${order.id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("loanOrders.deleteConfirm", "Bu sargyt pozulsynmy?")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -326,15 +309,6 @@ export default function LoanOrderViewPage() {
|
||||
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanOrders.deleteConfirm", "Bu sargyt pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil, FileText, ExternalLink } from "lucide-react";
|
||||
import { FileText, ExternalLink } from "lucide-react";
|
||||
import { useLoanPaidOffLetterById, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { STATUS_BADGE_VARIANTS } from "@/constants";
|
||||
import { buildFileUrl } from "@/features/shared/api/sharedApi";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
@@ -45,14 +43,12 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanPaidOffLetter();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: record, isLoading } = useLoanPaidOffLetterById(id!);
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(Number(id!), {
|
||||
onSuccess: () => navigate("/loan-paid-off-letters"),
|
||||
});
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(Number(id!));
|
||||
navigate("/loan-paid-off-letters");
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanPaidOffLetterViewSkeleton />;
|
||||
@@ -71,21 +67,13 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
{t("loanPaidOffLetters.view.title", "Güwanama maglumaty")}: {record.uniqueId}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => setShowDeleteDialog(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/loan-paid-off-letters/${record.id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
<ViewActions
|
||||
editTo={`/loan-paid-off-letters/${record.id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -167,15 +155,6 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.notes", "Bellikler")} value={record.notes || "—"} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { useLoanRemainingById, useDeleteLoanRemaining } from "@/features/loanRemaining/hooks/useLoanRemaining";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { InfoRow, Section, ViewActions } from "@/components/viewPageComponents";
|
||||
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
@@ -31,18 +28,12 @@ export default function LoanRemainingViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanRemaining();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: record, isLoading } = useLoanRemainingById(id!);
|
||||
|
||||
const handleDelete = () => {
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(Number(id!), {
|
||||
onSuccess: () => navigate("/loan-remaining"),
|
||||
});
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(Number(id!));
|
||||
navigate("/loan-remaining");
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanRemainingViewSkeleton />;
|
||||
@@ -59,21 +50,13 @@ export default function LoanRemainingViewPage() {
|
||||
{t("loanRemaining.view.title", "Karz galyndysy maglumaty")}: {record.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/loan-remaining/${record.id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
<ViewActions
|
||||
editTo={`/loan-remaining/${record.id}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -97,15 +80,6 @@ export default function LoanRemainingViewPage() {
|
||||
<InfoRow label={t("loanRemaining.columns.createdAt", "Döredilen wagty")} value={formatFromApiDate(record.createdAt)} />
|
||||
)}
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+2
-206
@@ -1,34 +1,19 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
|
||||
import { Pencil, CheckCircle2, UserRound, X, Shield, KeyRound, Building2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { FormInput } from "@/components/formInput";
|
||||
import { AvatarUpload } from "@/components/avatarUpload";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { InfiniteSelect, type InfiniteSelectOption } from "@/components/infiniteSelect";
|
||||
import { useAuthStore } from "@/app/store/authStore";
|
||||
import { isAdmin as isAdminUser } from "@/lib/auth/permissions";
|
||||
import { useProfile, useUpdateProfile } from "@/features/auth/hooks/useLogin";
|
||||
import { useInfiniteRoles } from "@/features/roles/hooks/useRoles";
|
||||
import { useInfinitePermissions } from "@/features/permissions/hooks/usePermissions";
|
||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||
import { useInfiniteStaff } from "@/features/operators/hooks/useOperators";
|
||||
import { useAssignRoleToUser, useAssignPermissionToRole, useAssignBranchToUser } from "@/features/shared/hooks/useSharedUserAssignments";
|
||||
import { AssignDialog, type AssignDialogKind } from "@/features/shared/components/assignDialog";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
type AssignDialogKind = "role" | "permission" | "branch";
|
||||
|
||||
export default function ProfilePage() {
|
||||
const { t, i18n } = useTranslation();
|
||||
@@ -360,192 +345,3 @@ export default function ProfilePage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Assign dialog ────────────────────────────────────────────────────────────
|
||||
|
||||
const ASSIGN_DIALOG_TITLES: Record<AssignDialogKind, string> = {
|
||||
role: "profile.actions.assignRole",
|
||||
permission: "profile.actions.assignPermission",
|
||||
branch: "profile.actions.assignBranch",
|
||||
};
|
||||
|
||||
const ASSIGN_DIALOG_FIELD_LABELS: Record<AssignDialogKind, string> = {
|
||||
role: "users.fields.role",
|
||||
permission: "users.sections.permissions",
|
||||
branch: "users.sections.branches",
|
||||
};
|
||||
|
||||
/**
|
||||
* Dialog for assigning a role / branch to a staff user, or assigning a permission to a role.
|
||||
*/
|
||||
function AssignDialog({ kind, onClose }: { kind: AssignDialogKind; onClose: () => void }) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as keyof LocalizedText;
|
||||
|
||||
const isPermission = kind === "permission";
|
||||
|
||||
const [targetSearch, setTargetSearch] = useState("");
|
||||
const [targetValue, setTargetValue] = useState("");
|
||||
const [resourceSearch, setResourceSearch] = useState("");
|
||||
const [resourceValue, setResourceValue] = useState("");
|
||||
const [error, setError] = useState<string | undefined>();
|
||||
|
||||
// Target query: Staff users when assigning role/branch to a user; Roles when assigning permission to a role.
|
||||
const staffQuery = useInfiniteStaff(targetSearch);
|
||||
const targetRolesQuery = useInfiniteRoles(targetSearch, isPermission);
|
||||
|
||||
// Resource query:
|
||||
const rolesQuery = useInfiniteRoles(resourceSearch, kind === "role");
|
||||
const permissionsQuery = useInfinitePermissions(resourceSearch, kind === "permission");
|
||||
const branchesQuery = useInfiniteBranches(resourceSearch, kind === "branch");
|
||||
|
||||
const roleMutation = useAssignRoleToUser();
|
||||
const permissionMutation = useAssignPermissionToRole();
|
||||
const branchMutation = useAssignBranchToUser();
|
||||
const isPending = roleMutation.isPending || permissionMutation.isPending || branchMutation.isPending;
|
||||
|
||||
const staffOptions: InfiniteSelectOption[] = useMemo(
|
||||
() =>
|
||||
(staffQuery.data?.pages ?? [])
|
||||
.flatMap((p) => p?.users ?? [])
|
||||
.map((u) => ({
|
||||
value: String(u.id),
|
||||
label: [u.firstName, u.lastName].filter(Boolean).join(" ") || u.name || u.username || String(u.id),
|
||||
})),
|
||||
[staffQuery.data],
|
||||
);
|
||||
|
||||
const targetRoleOptions: InfiniteSelectOption[] = useMemo(
|
||||
() =>
|
||||
(targetRolesQuery.data?.pages ?? [])
|
||||
.flatMap((p) => p?.roles ?? [])
|
||||
.map((r) => ({ value: String(r.id), label: r.name || r.code || String(r.id) })),
|
||||
[targetRolesQuery.data],
|
||||
);
|
||||
|
||||
const targetOptions = isPermission ? targetRoleOptions : staffOptions;
|
||||
const targetLabel = isPermission ? t("users.fields.role", "Rol") : t("profile.assign.userLabel", "Ulanyjy (staff)");
|
||||
const targetLoading = isPermission ? targetRolesQuery.isLoading : staffQuery.isLoading;
|
||||
const targetLoadingMore = isPermission ? targetRolesQuery.isFetchingNextPage : staffQuery.isFetchingNextPage;
|
||||
const targetHasNextPage = isPermission ? !!targetRolesQuery.hasNextPage : !!staffQuery.hasNextPage;
|
||||
const loadMoreTargets = () => {
|
||||
if (isPermission) targetRolesQuery.fetchNextPage();
|
||||
else staffQuery.fetchNextPage();
|
||||
};
|
||||
|
||||
const resourceOptions: InfiniteSelectOption[] = useMemo(() => {
|
||||
if (kind === "role") {
|
||||
return (rolesQuery.data?.pages ?? [])
|
||||
.flatMap((p) => p?.roles ?? [])
|
||||
.map((r) => ({ value: String(r.id), label: r.name || r.code || String(r.id) }));
|
||||
}
|
||||
if (kind === "permission") {
|
||||
return (permissionsQuery.data?.pages ?? [])
|
||||
.flatMap((p) => p?.permissions ?? [])
|
||||
.map((perm) => ({ value: String(perm.id), label: perm.name || perm.code || String(perm.id) }));
|
||||
}
|
||||
return (branchesQuery.data?.pages ?? [])
|
||||
.flatMap((p) => p?.branches ?? [])
|
||||
.map((b) => ({
|
||||
value: String(b.id),
|
||||
label: b.name?.[lang] || b.name?.tm || b.name?.en || b.name?.ru || b.uniqueCode || String(b.id),
|
||||
}));
|
||||
}, [kind, rolesQuery.data, permissionsQuery.data, branchesQuery.data, lang]);
|
||||
|
||||
const resourceLoading =
|
||||
kind === "role" ? rolesQuery.isLoading : kind === "permission" ? permissionsQuery.isLoading : branchesQuery.isLoading;
|
||||
const resourceLoadingMore =
|
||||
kind === "role"
|
||||
? rolesQuery.isFetchingNextPage
|
||||
: kind === "permission"
|
||||
? permissionsQuery.isFetchingNextPage
|
||||
: branchesQuery.isFetchingNextPage;
|
||||
const resourceHasNextPage =
|
||||
kind === "role" ? !!rolesQuery.hasNextPage : kind === "permission" ? !!permissionsQuery.hasNextPage : !!branchesQuery.hasNextPage;
|
||||
const loadMoreResources = () => {
|
||||
if (kind === "role") rolesQuery.fetchNextPage();
|
||||
else if (kind === "permission") permissionsQuery.fetchNextPage();
|
||||
else branchesQuery.fetchNextPage();
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!targetValue || !resourceValue) {
|
||||
setError(t("common.errors.required", "Meýdança hökmany doldurylmaly"));
|
||||
return;
|
||||
}
|
||||
setError(undefined);
|
||||
|
||||
const firstId = Number(targetValue);
|
||||
const secondId = Number(resourceValue);
|
||||
const onSuccess = () => {
|
||||
setTargetValue("");
|
||||
setResourceValue("");
|
||||
onClose();
|
||||
};
|
||||
|
||||
if (kind === "role") roleMutation.mutate({ userId: firstId, roleId: secondId }, { onSuccess });
|
||||
else if (kind === "permission") permissionMutation.mutate({ roleId: firstId, permissionId: secondId }, { onSuccess });
|
||||
else branchMutation.mutate({ userId: firstId, branchId: secondId }, { onSuccess });
|
||||
};
|
||||
|
||||
return (
|
||||
<AlertDialog open onOpenChange={(open) => !open && onClose()}>
|
||||
<AlertDialogContent className="max-w-md sm:max-w-md">
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t(ASSIGN_DIALOG_TITLES[kind])}</AlertDialogTitle>
|
||||
<VisuallyHidden.Root>
|
||||
<AlertDialogDescription>{t(ASSIGN_DIALOG_TITLES[kind])}</AlertDialogDescription>
|
||||
</VisuallyHidden.Root>
|
||||
</AlertDialogHeader>
|
||||
|
||||
<div className="space-y-3">
|
||||
<InfiniteSelect
|
||||
required
|
||||
label={targetLabel}
|
||||
value={targetValue}
|
||||
onChange={(v) => {
|
||||
setTargetValue(v);
|
||||
if (error) setError(undefined);
|
||||
}}
|
||||
options={targetOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
loading={targetLoading}
|
||||
isLoadingMore={targetLoadingMore}
|
||||
hasNextPage={targetHasNextPage}
|
||||
onLoadMore={loadMoreTargets}
|
||||
searchValue={targetSearch}
|
||||
onSearchChange={setTargetSearch}
|
||||
/>
|
||||
|
||||
<InfiniteSelect
|
||||
required
|
||||
label={t(ASSIGN_DIALOG_FIELD_LABELS[kind])}
|
||||
value={resourceValue}
|
||||
onChange={(v) => {
|
||||
setResourceValue(v);
|
||||
if (error) setError(undefined);
|
||||
}}
|
||||
error={error}
|
||||
options={resourceOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
loading={resourceLoading}
|
||||
isLoadingMore={resourceLoadingMore}
|
||||
hasNextPage={resourceHasNextPage}
|
||||
onLoadMore={loadMoreResources}
|
||||
searchValue={resourceSearch}
|
||||
onSearchChange={setResourceSearch}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialogFooter>
|
||||
<Button variant="ghost" size="sm" onClick={onClose} disabled={isPending}>
|
||||
{t("common.cancel", "Yza")}
|
||||
</Button>
|
||||
<Button size="sm" onClick={handleSubmit} disabled={!targetValue || !resourceValue || isPending}>
|
||||
{t("common.save", "Ýatda sakla")}
|
||||
</Button>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,20 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, MultiLangRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { useCardTypeById, useDeleteCardType } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
|
||||
@@ -27,7 +14,6 @@ export function CardTypeViewPage() {
|
||||
|
||||
const { data, isLoading } = useCardTypeById(numericId);
|
||||
const deleteMutation = useDeleteCardType();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -39,23 +25,14 @@ export function CardTypeViewPage() {
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/card/card-types/${numericId}/edit`)}
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
title={t("common.delete", "Öçürmek")}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/card/card-types/${numericId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(numericId).then(() => navigate("/settings/card/card-types"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("common.confirmDelete", "Öçürmegi tassyklaň")}
|
||||
deleteDescription={t("cardTypes.deleteConfirm", "Bu kart görnüşini öçürmek isleýärsiňizmi?")}
|
||||
deleteConfirmLabel={t("common.delete", "Öçürmek")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -92,29 +69,6 @@ export function CardTypeViewPage() {
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">{t("common.noData", "Maglumat ýok")}</p>
|
||||
)}
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("common.confirmDelete", "Öçürmegi tassyklaň")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>{t("cardTypes.deleteConfirm", "Bu kart görnüşini öçürmek isleýärsiňizmi?")}</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
onClick={() =>
|
||||
deleteMutation.mutate(numericId, {
|
||||
onSuccess: () => navigate("/settings/card/card-types"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{deleteMutation.isPending ? t("common.deleting", "Öçürilýär...") : t("common.delete", "Öçürmek")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, MultiLangRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useCardReasonById, useDeleteCardReason } from "@/features/cardReasons/hooks/useCardReasons";
|
||||
|
||||
// ─── CardReasonViewPage ────────────────────────────────────────────────────────
|
||||
@@ -30,7 +17,6 @@ export function CardReasonViewPage() {
|
||||
|
||||
const { data, isLoading } = useCardReasonById(numericId);
|
||||
const deleteMutation = useDeleteCardReason();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -42,23 +28,14 @@ export function CardReasonViewPage() {
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/card/card-reasons/${numericId}/edit`)}
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
title={t("common.delete", "Öçürmek")}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/card/card-reasons/${numericId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(numericId).then(() => navigate("/settings/card/card-reasons"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("common.confirmDelete", "Öçürmegi tassyklaň")}
|
||||
deleteDescription={t("cardReasons.deleteConfirm", "Bu kartyň çykarylmagynyň sebäbini öçürmek isleýärsiňizmi?")}
|
||||
deleteConfirmLabel={t("common.delete", "Öçürmek")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -92,31 +69,6 @@ export function CardReasonViewPage() {
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">{t("common.noData", "Maglumat ýok")}</p>
|
||||
)}
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("common.confirmDelete", "Öçürmegi tassyklaň")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardReasons.deleteConfirm", "Bu kartyň çykarylmagynyň sebäbini öçürmek isleýärsiňizmi?")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
onClick={() =>
|
||||
deleteMutation.mutate(numericId, {
|
||||
onSuccess: () => navigate("/settings/card/card-reasons"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{deleteMutation.isPending ? t("common.deleting", "Öçürilýär...") : t("common.delete", "Öçürmek")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
// pages/LoanTypeViewPage.tsx
|
||||
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Section, InfoRow, MultiLangRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useGetLoanTypeById, useDeleteLoanType } from "@/features/loanTypes/hooks/useLoanTypes";
|
||||
|
||||
// ─── LoanTypeViewPage ─────────────────────────────────────────────────────────
|
||||
@@ -27,8 +15,6 @@ export default function LoanTypeViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const loanTypeId = Number(id);
|
||||
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data, isLoading, isError } = useGetLoanTypeById(loanTypeId);
|
||||
const deleteMutation = useDeleteLoanType();
|
||||
|
||||
@@ -76,24 +62,17 @@ export default function LoanTypeViewPage() {
|
||||
{t("loanTypes.viewTitle", "Karz görnüşi giňişleýin")}: {data.title[lang]}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => setShowDeleteDialog(true)}
|
||||
className="text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors"
|
||||
title={t("common.delete", "Pozmak")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/loan/loan-types/${loanTypeId}/edit`)}
|
||||
className="text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirlemek")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/loan/loan-types/${loanTypeId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("loanTypes.deleteDialog.title", "Pozmak")}
|
||||
deleteDescription={t(
|
||||
"loanTypes.deleteDialog.description",
|
||||
"Bu karz görnüşini pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylyp bilinmez.",
|
||||
)}
|
||||
deleteConfirmLabel={t("common.delete", "Pozmak")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,28 +96,6 @@ export default function LoanTypeViewPage() {
|
||||
{data.active ? <CheckCircle2 size={20} className="text-emerald-500" /> : <XCircle size={20} className="text-muted-foreground" />}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("loanTypes.deleteDialog.title", "Pozmak")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("loanTypes.deleteDialog.description", "Bu karz görnüşini pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylyp bilinmez.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteMutation.isPending}>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Pozmak")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,19 +1,14 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { useGetRequiredDocumentById, useDeleteRequiredDocument } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
export default function RequiredDocumentsViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const docId = Number(id);
|
||||
const { data, isLoading } = useGetRequiredDocumentById(docId);
|
||||
@@ -46,23 +41,13 @@ export default function RequiredDocumentsViewPage() {
|
||||
{t("loanDocuments.viewTitle", "Karz gerekli resminamalary giňişleýin")}: {data.name}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="text-muted-foreground hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/loan/required-documents/${docId}/edit`)}
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/loan/required-documents/${docId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("loanDocuments.deleteConfirm", "Bu resminamany öçürmek isleýärsiňizmi?")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -81,15 +66,6 @@ export default function RequiredDocumentsViewPage() {
|
||||
)}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("loanDocuments.deleteConfirm", "Bu resminamany öçürmek isleýärsiňizmi?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,20 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, MultiLangRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useBranchById, useDeleteBranch } from "@/features/branches/hooks/useBranches";
|
||||
|
||||
export function BranchViewPage() {
|
||||
@@ -26,7 +14,6 @@ export function BranchViewPage() {
|
||||
|
||||
const { data, isLoading } = useBranchById(numericId);
|
||||
const deleteMutation = useDeleteBranch();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const lang = ((i18n.language?.slice(0, 2) === "tk" ? "tm" : i18n.language?.slice(0, 2)) ?? "tm") as "tm" | "ru" | "en";
|
||||
|
||||
@@ -40,23 +27,14 @@ export function BranchViewPage() {
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/location/branches/${numericId}/edit`)}
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
title={t("common.delete", "Öçürmek")}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/location/branches/${numericId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(numericId).then(() => navigate("/settings/location/branches"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("common.confirmDelete", "Öçürmegi tassyklaň")}
|
||||
deleteDescription={t("branches.deleteConfirm", "Bu şahamçany öçürmek isleýärsiňizmi?")}
|
||||
deleteConfirmLabel={t("common.delete", "Öçürmek")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -102,28 +80,6 @@ export function BranchViewPage() {
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">{t("common.noData", "Maglumat ýok")}</p>
|
||||
)}
|
||||
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("common.confirmDelete", "Öçürmegi tassyklaň")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>{t("branches.deleteConfirm", "Bu şahamçany öçürmek isleýärsiňizmi?")}</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
onClick={() =>
|
||||
deleteMutation.mutate(numericId, {
|
||||
onSuccess: () => navigate("/settings/location/branches"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{deleteMutation.isPending ? t("common.deleting", "Öçürilýär...") : t("common.delete", "Öçürmek")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, MultiLangRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useDistrictById, useDeleteDistrict } from "@/features/districts/hooks/useDistricts";
|
||||
|
||||
export function DistrictViewPage() {
|
||||
@@ -26,7 +14,6 @@ export function DistrictViewPage() {
|
||||
|
||||
const { data, isLoading } = useDistrictById(numericId);
|
||||
const deleteMutation = useDeleteDistrict();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const lang = ((i18n.language?.slice(0, 2) === "tk" ? "tm" : i18n.language?.slice(0, 2)) ?? "tm") as "tm" | "ru" | "en";
|
||||
|
||||
@@ -40,23 +27,14 @@ export function DistrictViewPage() {
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/location/districts/${numericId}/edit`)}
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
title={t("common.delete", "Öçürmek")}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/location/districts/${numericId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(numericId).then(() => navigate("/settings/location/districts"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("common.confirmDelete", "Öçürmegi tassyklaň")}
|
||||
deleteDescription={t("districts.deleteConfirm", "Bu etrapy öçürmek isleýärsiňizmi?")}
|
||||
deleteConfirmLabel={t("common.delete", "Öçürmek")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -85,28 +63,6 @@ export function DistrictViewPage() {
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">{t("common.noData", "Maglumat ýok")}</p>
|
||||
)}
|
||||
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("common.confirmDelete", "Öçürmegi tassyklaň")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>{t("districts.deleteConfirm", "Bu etrapy öçürmek isleýärsiňizmi?")}</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
onClick={() =>
|
||||
deleteMutation.mutate(numericId, {
|
||||
onSuccess: () => navigate("/settings/location/districts"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{deleteMutation.isPending ? t("common.deleting", "Öçürilýär...") : t("common.delete", "Öçürmek")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { usePermission, useDeletePermission } from "@/features/permissions/hooks/usePermissions";
|
||||
|
||||
// ─── PermissionViewPage ───────────────────────────────────────────────────────
|
||||
@@ -25,16 +12,12 @@ export default function PermissionViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const permissionId = Number(id);
|
||||
|
||||
const [showDelete, setShowDelete] = useState(false);
|
||||
|
||||
const { data: permission, isLoading, isError } = usePermission(permissionId);
|
||||
const deletePermission = useDeletePermission();
|
||||
|
||||
const handleConfirmDelete = () => {
|
||||
deletePermission.mutate(permissionId, {
|
||||
onSuccess: () => navigate("/settings/users/permissions"),
|
||||
onError: () => setShowDelete(false),
|
||||
});
|
||||
const handleDelete = async () => {
|
||||
await deletePermission.mutateAsync(permissionId);
|
||||
navigate("/settings/users/permissions");
|
||||
};
|
||||
|
||||
// ── Loading skeleton ───────────────────────────────────────────────────────
|
||||
@@ -70,22 +53,14 @@ export default function PermissionViewPage() {
|
||||
{t("permissions.viewTitle", "Rugsat giňişleýin")}: {permission.name}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-destructive hover:border-destructive"
|
||||
onClick={() => setShowDelete(true)}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-blue-500 hover:border-blue-500"
|
||||
onClick={() => navigate(`/settings/users/permissions/${permissionId}/edit`)}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/users/permissions/${permissionId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deletePermission.isPending}
|
||||
deleteTitle={t("permissions.deleteDialog.title", "Rugsaty pozmak")}
|
||||
deleteDescription={t("permissions.deleteDialog.description", "Bu rugsaty pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,24 +71,6 @@ export default function PermissionViewPage() {
|
||||
<InfoRow label={t("permissions.fields.name", "Ady")} value={permission.name} />
|
||||
<InfoRow label={t("permissions.fields.guardName", "Guard name")} value={permission.guardName} />
|
||||
</Section>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={showDelete} onOpenChange={setShowDelete}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("permissions.deleteDialog.title", "Rugsaty pozmak")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("permissions.deleteDialog.description", "Bu rugsaty pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleConfirmDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deletePermission.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,20 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import { Section, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useRole, useDeleteRole } from "@/features/roles/hooks/useRoles";
|
||||
|
||||
// ─── RoleViewPage ─────────────────────────────────────────────────────────────
|
||||
@@ -25,16 +12,12 @@ export default function RoleViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const roleId = Number(id);
|
||||
|
||||
const [showDelete, setShowDelete] = useState(false);
|
||||
|
||||
const { data: role, isLoading, isError } = useRole(roleId);
|
||||
const deleteRole = useDeleteRole();
|
||||
|
||||
const handleConfirmDelete = () => {
|
||||
deleteRole.mutate(roleId, {
|
||||
onSuccess: () => navigate("/settings/users/roles"),
|
||||
onError: () => setShowDelete(false),
|
||||
});
|
||||
const handleDelete = async () => {
|
||||
await deleteRole.mutateAsync(roleId);
|
||||
navigate("/settings/users/roles");
|
||||
};
|
||||
|
||||
// ── Loading skeleton ───────────────────────────────────────────────────────
|
||||
@@ -70,22 +53,14 @@ export default function RoleViewPage() {
|
||||
{t("roles.viewTitle", "Rol giňişleýin")}: {role.name}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-destructive hover:border-destructive"
|
||||
onClick={() => setShowDelete(true)}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-blue-500 hover:border-blue-500"
|
||||
onClick={() => navigate(`/settings/users/roles/${roleId}/edit`)}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/settings/users/roles/${roleId}/edit`}
|
||||
onDelete={handleDelete}
|
||||
deleting={deleteRole.isPending}
|
||||
deleteTitle={t("roles.deleteDialog.title", "Roly pozmak")}
|
||||
deleteDescription={t("roles.deleteDialog.description", "Bu roly pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.")}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,24 +71,6 @@ export default function RoleViewPage() {
|
||||
<InfoRow label={t("roles.fields.name", "Ady")} value={role.name} />
|
||||
<InfoRow label={t("roles.fields.guardName", "Guard name")} value={role.guardName} />
|
||||
</Section>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={showDelete} onOpenChange={setShowDelete}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("roles.deleteDialog.title", "Roly pozmak")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("roles.deleteDialog.description", "Bu roly pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={handleConfirmDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteRole.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, XCircle, CheckCircle2, UserRound, Link2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { XCircle, CheckCircle2, UserRound, Link2 } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useUser, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
||||
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
@@ -25,8 +22,6 @@ export default function UserViewPage() {
|
||||
|
||||
const { data: user, isLoading, isError } = useUser(userId);
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
// ── Loading ───────────────────────────────────────────────────────────────
|
||||
|
||||
if (isLoading) {
|
||||
@@ -63,22 +58,20 @@ export default function UserViewPage() {
|
||||
{t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => navigate(`/all-users/${userId}/edit`)}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/all-users/${userId}/edit`}
|
||||
onDelete={async () => {
|
||||
await deleteUser.mutateAsync(userId);
|
||||
navigate("/all-users");
|
||||
}}
|
||||
deleting={deleteUser.isPending}
|
||||
deleteTitle={t("users.deleteDialog.title", "Ulanyjyny öçürmek")}
|
||||
deleteDescription={t(
|
||||
"users.deleteDialog.description",
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace("{name}", user.username)}
|
||||
deleteConfirmLabel={t("common.delete", "Öçür")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -140,22 +133,6 @@ export default function UserViewPage() {
|
||||
)}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("users.deleteDialog.title", "Ulanyjyny öçürmek")}
|
||||
description={t("users.deleteDialog.description", 'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.').replace(
|
||||
"{name}",
|
||||
user.username,
|
||||
)}
|
||||
confirmLabel={t("common.delete", "Öçür")}
|
||||
onConfirm={async () => {
|
||||
await deleteUser.mutateAsync(userId);
|
||||
navigate("/all-users");
|
||||
}}
|
||||
isLoading={deleteUser.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,20 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, XCircle, CheckCircle2, UserRound } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { XCircle, CheckCircle2, UserRound } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { useClient, useDeleteClient } from "@/features/clients/hooks/useClients";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
|
||||
// ─── Helper: resolve LocalizedText | string ───────────────────────────────────
|
||||
|
||||
function resolveLocalizedName(name: LocalizedText | string | undefined | null, lang = "en"): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
return name[lang as keyof LocalizedText] ?? name.en ?? name.tm ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -20,14 +27,13 @@ function ActiveIndicator({ active }: { active: boolean }) {
|
||||
export default function ClientDetailPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const clientId = Number(id);
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = i18n.language ?? "en";
|
||||
const navigate = useNavigate();
|
||||
const deleteMutation = useDeleteClient();
|
||||
|
||||
const { data: client, isLoading } = useClient(clientId);
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
// ── Loading ───────────────────────────────────────────────────────────────
|
||||
|
||||
if (isLoading) {
|
||||
@@ -53,31 +59,24 @@ export default function ClientDetailPage() {
|
||||
const roles = client.roles ?? [];
|
||||
const permissions = client.permissions ?? [];
|
||||
const branches = client.branches ?? [];
|
||||
const displayName = [client.firstName, client.lastName].filter(Boolean).join(" ") || client.name;
|
||||
|
||||
return (
|
||||
<div className=" flex flex-col gap-6">
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
{t("clients.detailTitle", "Müşderi giňişleýin")}: {client.name}
|
||||
{t("clients.detailTitle", "Müşderi giňişleýin")}: {displayName}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => navigate(`/clients/${clientId}/edit`)}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/clients/${clientId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(clientId).then(() => navigate("/clients"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("clients.deleteTitle", "Müşderini pozmak")}
|
||||
deleteDescription={t("clients.deleteConfirm", "{{name}} müşderisini pozmak isleýärsiňizmi?", { name: client.name })}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,13 +95,16 @@ export default function ClientDetailPage() {
|
||||
<UserRound size={28} className="text-muted-foreground" />
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<p className="text-base font-semibold text-foreground truncate">{client.name}</p>
|
||||
<div className="min-w-0 text-center">
|
||||
<p className="text-base font-semibold text-foreground truncate">{displayName}</p>
|
||||
{client.username && <p className="text-xs text-muted-foreground mt-0.5 truncate">@{client.username}</p>}
|
||||
</div>
|
||||
</div>
|
||||
<InfoRow label={t("common.id", "ID")} value={client.id} />
|
||||
<InfoRow label={t("clients.fields.username", "Ulanyjy ady")} value={client.username} />
|
||||
<InfoRow label={t("clients.fields.name", "Ady")} value={client.name} />
|
||||
<InfoRow label={t("users.fields.firstName", "At ady")} value={client.firstName || "—"} />
|
||||
<InfoRow label={t("users.fields.lastName", "Familiýasy")} value={client.lastName || "—"} />
|
||||
<InfoRow
|
||||
label={t("clients.fields.role", "Roly")}
|
||||
value={roles[0]?.name ?? client.role ?? "—"}
|
||||
@@ -112,6 +114,8 @@ export default function ClientDetailPage() {
|
||||
<InfoRow label={t("clients.fields.isActive", "Işjeň")}>
|
||||
<ActiveIndicator active={client.active} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("users.fields.createdAt", "Döredilen wagty")} value={formatFromApiDate(client.createdAt) || "—"} />
|
||||
<InfoRow label={t("users.fields.updatedAt", "Täzelenen wagty")} value={formatFromApiDate(client.updatedAt) || "—"} />
|
||||
{roles.length > 0 && (
|
||||
<InfoRow label={t("clients.sections.roles", "Rollar")}>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
@@ -140,7 +144,7 @@ export default function ClientDetailPage() {
|
||||
{branches.map((b) => (
|
||||
<span key={b.id} className="text-sm">
|
||||
<Link to={`/settings/location/branches/${b.id}`} className="text-[#2bbae6] font-medium hover:underline">
|
||||
{b.name}
|
||||
{resolveLocalizedName(b.name, lang) || b.uniqueCode || b.id}
|
||||
</Link>
|
||||
{b.region ? (
|
||||
<>
|
||||
@@ -162,16 +166,6 @@ export default function ClientDetailPage() {
|
||||
<InfoRow label={t("clients.fields.email", "E-poçta")} value={client.email ?? "—"} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("clients.deleteTitle", "Müşderini pozmak")}
|
||||
description={t("clients.deleteConfirm", "{{name}} müşderisini pozmak isleýärsiňizmi?", { name: client.name })}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() => deleteMutation.mutate(clientId, { onSuccess: () => navigate("/clients") })}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle, UserRound } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CheckCircle2, XCircle, UserRound } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { useOperator, useDeleteOperator } from "@/features/operators/hooks/useOperators";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
|
||||
// ─── Helper: resolve LocalizedText | string ───────────────────────────────────
|
||||
|
||||
@@ -35,8 +33,6 @@ export default function OperatorDetailPage() {
|
||||
|
||||
const { data: operator, isLoading } = useOperator(operatorId);
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
// ── Loading ───────────────────────────────────────────────────────────────
|
||||
|
||||
if (isLoading) {
|
||||
@@ -62,31 +58,24 @@ export default function OperatorDetailPage() {
|
||||
const roles = operator.roles ?? [];
|
||||
const permissions = operator.permissions ?? [];
|
||||
const branches = operator.branches ?? [];
|
||||
const displayName = [operator.firstName, operator.lastName].filter(Boolean).join(" ") || operator.name;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-foreground">
|
||||
{t("operators.detailTitle", "Operator giňişleýin")}: {operator.name}
|
||||
{t("operators.detailTitle", "Operator giňişleýin")}: {displayName}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => navigate(`/operators/${operatorId}/edit`)}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
<ViewActions
|
||||
editTo={`/operators/${operatorId}/edit`}
|
||||
onDelete={() => deleteMutation.mutateAsync(operatorId).then(() => navigate("/operators"))}
|
||||
deleting={deleteMutation.isPending}
|
||||
deleteTitle={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
deleteDescription={t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", { name: operator.name })}
|
||||
deleteConfirmLabel={t("common.delete", "Poz")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -105,13 +94,16 @@ export default function OperatorDetailPage() {
|
||||
<UserRound size={28} className="text-muted-foreground" />
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<p className="text-base font-semibold text-foreground truncate">{operator.name}</p>
|
||||
<div className="min-w-0 text-center">
|
||||
<p className="text-base font-semibold text-foreground truncate">{displayName}</p>
|
||||
{operator.username && <p className="text-xs text-muted-foreground mt-0.5 truncate">@{operator.username}</p>}
|
||||
</div>
|
||||
</div>
|
||||
<InfoRow label={t("common.id", "ID")} value={operator.id} />
|
||||
<InfoRow label={t("operators.fields.username", "Ulanyjy ady")} value={operator.username} />
|
||||
<InfoRow label={t("operators.fields.name", "Ady")} value={operator.name} />
|
||||
<InfoRow label={t("users.fields.firstName", "At ady")} value={operator.firstName || "—"} />
|
||||
<InfoRow label={t("users.fields.lastName", "Familiýasy")} value={operator.lastName || "—"} />
|
||||
<InfoRow
|
||||
label={t("operators.fields.role", "Roly")}
|
||||
value={roles[0]?.name ?? operator.role ?? "—"}
|
||||
@@ -121,6 +113,8 @@ export default function OperatorDetailPage() {
|
||||
<InfoRow label={t("operators.fields.isActive", "Işjeň")}>
|
||||
<ActiveIndicator active={operator.active} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("users.fields.createdAt", "Döredilen wagty")} value={formatFromApiDate(operator.createdAt) || "—"} />
|
||||
<InfoRow label={t("users.fields.updatedAt", "Täzelenen wagty")} value={formatFromApiDate(operator.updatedAt) || "—"} />
|
||||
{roles.length > 0 && (
|
||||
<InfoRow label={t("operators.sections.roles", "Rollar")}>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
@@ -149,7 +143,7 @@ export default function OperatorDetailPage() {
|
||||
{branches.map((b) => (
|
||||
<span key={b.id} className="text-sm">
|
||||
<Link to={`/settings/location/branches/${b.id}`} className="text-[#2bbae6] font-medium hover:underline">
|
||||
{resolveLocalizedName(b.name, lang)}
|
||||
{resolveLocalizedName(b.name, lang) || b.uniqueCode || b.id}
|
||||
</Link>
|
||||
{b.region ? (
|
||||
<>
|
||||
@@ -171,20 +165,6 @@ export default function OperatorDetailPage() {
|
||||
<InfoRow label={t("operators.fields.email", "E-poçta")} value={operator.email ?? "—"} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
description={t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", { name: operator.name })}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() =>
|
||||
deleteMutation.mutate(operatorId, {
|
||||
onSuccess: () => navigate("/operators"),
|
||||
})
|
||||
}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user