added confirm dialog, some translations
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
} from '@/features/orderNewCard/hooks/useOrderNewCard'
|
||||
import type { CardOrderListItem, CardOrderStatus } from '@/features/orderNewCard/api/orderNewCardApi'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
@@ -80,6 +81,7 @@ export default function CardOrdersPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
@@ -130,13 +132,15 @@ export default function CardOrdersPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: string) => {
|
||||
if (!window.confirm(t('cardOrder.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t]
|
||||
)
|
||||
const handleDelete = useCallback((id: string) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (!deleteId) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<CardOrderListItem>[]>(
|
||||
@@ -318,6 +322,15 @@ export default function CardOrdersPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('cardOrder.deleteConfirm', 'Bu sargyt pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,21 +7,12 @@ import { Eye, Pencil, Trash2 } from "lucide-react";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
useGetCurrencyRates,
|
||||
useDeleteCurrencyRate,
|
||||
} from "@/features/currencyRates/hooks/useCurrencyRates";
|
||||
import type { CurrencyRate } from "@/features/currencyRates/api/currencyRatesApi";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Column visibility defaults ───────────────────────────────────────────────
|
||||
|
||||
@@ -197,39 +188,15 @@ export default function CurrencyRatesPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete Confirmation Dialog */}
|
||||
<AlertDialog
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeleteId(null);
|
||||
}}
|
||||
>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("currencyRates.deleteDialog.title", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
"currencyRates.deleteDialog.description",
|
||||
"Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.",
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
disabled={deleteMutation.isPending}
|
||||
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>
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
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,22 +1,13 @@
|
||||
// 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 { useState } from 'react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetCurrencyRateById, useDeleteCurrencyRate } from '@/features/currencyRates/hooks/useCurrencyRates'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── CurrencyRateDetailPage ───────────────────────────────────────────────────
|
||||
|
||||
@@ -104,34 +95,15 @@ export default function CurrencyRateDetailPage() {
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* Delete Dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t('currencyRates.deleteDialog.title', 'Pozmak isleýärsiňizmi?')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'currencyRates.deleteDialog.description',
|
||||
'Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.'
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
disabled={deleteMutation.isPending}
|
||||
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>
|
||||
<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>
|
||||
)
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { InfoRow, AuditLog, type AuditRowProps } from '@/components/viewPageComp
|
||||
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 ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -137,12 +138,12 @@ 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()
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!window.confirm('Bu tolegi pozmak isleyanizmi?')) return
|
||||
await deleteMutation.mutateAsync(id!)
|
||||
navigate('/sber-payments')
|
||||
}
|
||||
@@ -179,7 +180,7 @@ export default function SberPaymentViewPage() {
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
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="Poz"
|
||||
@@ -301,6 +302,14 @@ export default function SberPaymentViewPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title="Bu tölegi pozmak isleýärsiňizmi?"
|
||||
confirmLabel="Poz"
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -8,16 +8,7 @@ import { useIntlPayments, useDeleteIntlPayment } from '@/features/visaMasterPaym
|
||||
import type { IntlPaymentItem, IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Eye, Pencil, Trash2, ChevronDown } from 'lucide-react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
@@ -265,30 +256,19 @@ export default function IntlPaymentsPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialog open={!!deleteTarget} onOpenChange={(o) => !o && setDeleteTarget(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} {deleteTarget?.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() => {
|
||||
if (deleteTarget) {
|
||||
deletePayment(deleteTarget.id, { onSuccess: () => setDeleteTarget(null) })
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={deleteTarget !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}
|
||||
description={`${t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} ${deleteTarget?.id ?? ''}`}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deletePayment(deleteTarget.id, { onSuccess: () => setDeleteTarget(null) })
|
||||
}
|
||||
}}
|
||||
isLoading={isDeleting}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,17 +2,7 @@ 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 {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { InfoRow } from '@/components/viewPageComponents'
|
||||
@@ -138,10 +128,15 @@ 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('/intl-payments/visa-master') })
|
||||
}
|
||||
|
||||
if (isLoading) return <IntlPaymentViewSkeleton />
|
||||
|
||||
if (isError || !data) {
|
||||
@@ -182,34 +177,13 @@ export default function IntlPaymentViewPage() {
|
||||
{t('intlPayment.viewTitle', 'Halkara töleg')}: {data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<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')}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} {data.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() => deletePayment(data.id, { onSuccess: () => navigate('/intl-payments/visa-master') })}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<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`)}
|
||||
@@ -316,6 +290,15 @@ export default function IntlPaymentViewPage() {
|
||||
</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>
|
||||
)
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
useDeleteLoanOrderMobile,
|
||||
} from '@/features/loanOrderMobiles/hooks/useLoanOrderMobiles'
|
||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +56,7 @@ export default function LoanOrderMobilesPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanOrderMobile()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
@@ -97,13 +99,15 @@ export default function LoanOrderMobilesPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: string) => {
|
||||
if (!window.confirm(t('loanOrderMobiles.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t],
|
||||
)
|
||||
const handleDelete = useCallback((id: string) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (!deleteId) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<LoanOrderMobile>[]>(
|
||||
@@ -309,6 +313,15 @@ export default function LoanOrderMobilesPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanOrderMobiles.deleteConfirm', 'Bu sargyt pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
} from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { toast } from "sonner";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import {
|
||||
StatusBadge,
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -105,19 +106,17 @@ 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 = () => {
|
||||
if (!window.confirm(t("loanOrderMobiles.deleteConfirm", "Bu sargyt pozulsynmy?"))) return
|
||||
setShowDeleteDialog(true)
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("loanOrderMobiles.deleteSuccess", "Sargyt pozuldy"))
|
||||
navigate("/loan-order-mobiles")
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t("loanOrderMobiles.deleteError", "Pozma wagty ýalňyşlyk ýüze çykdy"))
|
||||
},
|
||||
onSuccess: () => navigate("/loan-order-mobiles"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -436,6 +435,14 @@ 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,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
@@ -6,7 +7,6 @@ import {
|
||||
useDeleteLoanOrder,
|
||||
} from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -102,19 +103,17 @@ 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 = () => {
|
||||
if (!window.confirm(t("loanOrders.deleteConfirm", "Bu sargyt pozulsynmy?"))) return
|
||||
setShowDeleteDialog(true)
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("loanOrders.deleteSuccess", "Sargyt pozuldy"))
|
||||
navigate("/loan-orders")
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t("loanOrders.deleteError", "Pozma wagty ýalňyşlyk ýüze çykdy"))
|
||||
},
|
||||
onSuccess: () => navigate("/loan-orders"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -352,6 +351,14 @@ 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>
|
||||
)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from '@/compone
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { useLoanOrders, useDeleteLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
|
||||
import type { LoanOrder, LoanOrderStatus } from '@/features/loanOrders/api/loanOrdersApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
@@ -56,6 +57,7 @@ export default function LoanOrdersPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanOrder()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
const [search, setSearch] = useState('')
|
||||
const [page, setPage] = useState(1)
|
||||
@@ -95,13 +97,15 @@ export default function LoanOrdersPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: string) => {
|
||||
if (!window.confirm(t('loanOrders.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t]
|
||||
)
|
||||
const handleDelete = useCallback((id: string) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (!deleteId) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
const columns = useMemo<ColumnDef<LoanOrder>[]>(
|
||||
() => [
|
||||
@@ -300,6 +304,15 @@ export default function LoanOrdersPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanOrders.deleteConfirm', 'Bu sargyt pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
useDeleteLoanPaidOffLetter,
|
||||
} from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -60,6 +61,7 @@ function EmptyState({ onCreate }: { onCreate: () => void }) {
|
||||
export default function LoanPaidOffLettersPage() {
|
||||
const { t } = useTranslation();
|
||||
const deleteMutation = useDeleteLoanPaidOffLetter();
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null);
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState("");
|
||||
@@ -92,18 +94,15 @@ export default function LoanPaidOffLettersPage() {
|
||||
setPage(1);
|
||||
}, []);
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: number) => {
|
||||
if (
|
||||
!window.confirm(
|
||||
t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?"),
|
||||
)
|
||||
)
|
||||
return;
|
||||
deleteMutation.mutate(id);
|
||||
},
|
||||
[deleteMutation, t],
|
||||
);
|
||||
const handleDelete = useCallback((id: number) => {
|
||||
setDeleteId(id);
|
||||
}, []);
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (deleteId === null) return;
|
||||
deleteMutation.mutate(deleteId);
|
||||
setDeleteId(null);
|
||||
}, [deleteId, deleteMutation]);
|
||||
|
||||
const handleCreate = useCallback(() => {
|
||||
// navigate to create page or open modal
|
||||
@@ -288,6 +287,15 @@ export default function LoanPaidOffLettersPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { DataTable } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from '@/components/dataTableToolbar'
|
||||
import { useLoanRemaining, useDeleteLoanRemaining } from '@/features/loanRemaining/hooks/useLoanRemaining'
|
||||
import type { LoanRemaining } from '@/features/loanRemaining/api/loanRemainingApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -19,6 +20,7 @@ export default function LoanRemainingPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanRemaining()
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null)
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
@@ -48,13 +50,15 @@ export default function LoanRemainingPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: number) => {
|
||||
if (!window.confirm(t('loanRemaining.deleteConfirm', 'Bu ýazgy pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t],
|
||||
)
|
||||
const handleDelete = useCallback((id: number) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (deleteId === null) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<LoanRemaining>[]>(
|
||||
@@ -188,6 +192,15 @@ export default function LoanRemainingPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanRemaining.deleteConfirm', 'Bu ýazgy pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
@@ -6,8 +7,8 @@ import {
|
||||
useDeleteLoanRemaining,
|
||||
} from "@/features/loanRemaining/hooks/useLoanRemaining";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { toast } from "sonner";
|
||||
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -31,29 +32,17 @@ 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 = () => {
|
||||
if (
|
||||
!window.confirm(t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?"))
|
||||
)
|
||||
return;
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(Number(id!), {
|
||||
onSuccess: () => {
|
||||
toast.success(
|
||||
t("loanRemaining.deleteSuccess", "Ýazgy üstünlikli pozuldy"),
|
||||
);
|
||||
navigate("/loan-remaining");
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(
|
||||
t(
|
||||
"loanRemaining.deleteError",
|
||||
"Pozmak başartmady, gaýtadan synanyşyň",
|
||||
),
|
||||
);
|
||||
},
|
||||
onSuccess: () => navigate("/loan-remaining"),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -110,6 +99,15 @@ export default function LoanRemainingViewPage() {
|
||||
value={record.loanAccount}
|
||||
/>
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,20 +105,12 @@ export default function AuthPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
loginMutation.mutate({ email: username, password }, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("Success login", "Login successful"));
|
||||
},
|
||||
onError: (error: any) => {
|
||||
const message = error?.response?.data?.message || t("Server Error", "An error occurred during login");
|
||||
toast.error(message);
|
||||
}
|
||||
});
|
||||
loginMutation.mutate({ email: username, password });
|
||||
};
|
||||
|
||||
// Mock submit for other views
|
||||
const handleOtherSubmit = async () => {
|
||||
toast.info(t("Not Implemented", "This feature is not implemented yet"));
|
||||
toast.info(t("featureNotImplemented", "This feature is not implemented yet"));
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -170,7 +162,7 @@ export default function AuthPage() {
|
||||
|
||||
<div className="text-center mt-8">
|
||||
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
|
||||
Privacy Policy
|
||||
{t("Privacy Policy")}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
@@ -218,7 +210,7 @@ export default function AuthPage() {
|
||||
|
||||
<div className="text-center mt-8">
|
||||
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
|
||||
Privacy Policy
|
||||
{t("Privacy Policy")}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
@@ -248,7 +240,7 @@ export default function AuthPage() {
|
||||
|
||||
<div className="text-center mt-8">
|
||||
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
|
||||
Privacy Policy
|
||||
{t("Privacy Policy")}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -15,10 +15,10 @@ export default function NotFoundPage() {
|
||||
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-2xl font-bold tracking-tight sm:text-3xl">
|
||||
{t("errors.pageNotFoundTitle")}
|
||||
{t("errors.pageNotFoundTitle", "Sahypa tapylmady")}
|
||||
</h2>
|
||||
<p className="text-muted-foreground">
|
||||
{t("errors.pageNotFoundDescription")}
|
||||
{t("errors.pageNotFoundDescription", "Gözleýän sahypaňyz ýok ýa-da başga ýere geçirilen bolup biler.")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -27,13 +27,13 @@ export default function NotFoundPage() {
|
||||
variant="outline"
|
||||
onClick={() => navigate(-1)}
|
||||
>
|
||||
{t("common.goBack")}
|
||||
{t("common.goBack", "Yza gaýt")}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => navigate("/")}
|
||||
>
|
||||
{t("common.backToHome")}
|
||||
{t("common.backToHome", "Baş sahypa")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import { useGetRequiredDocuments, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import type { LoanDocument } from '@/features/requiredDocuments/api/requiredDocumentsApi'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Column visibility defaults ───────────────────────────────────────────────
|
||||
|
||||
@@ -27,11 +28,16 @@ export default function RequiredDocumentsListPage() {
|
||||
// ── Data ────────────────────────────────────────────────────────────────────
|
||||
const { data, isLoading } = useGetRequiredDocuments({ page, perPage, search })
|
||||
const deleteMutation = useDeleteRequiredDocument()
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null)
|
||||
|
||||
const handleDelete = (id: number) => {
|
||||
if (window.confirm(t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?'))) {
|
||||
deleteMutation.mutate(id)
|
||||
}
|
||||
setDeleteId(id)
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
if (deleteId === null) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}
|
||||
|
||||
// ── Columns ─────────────────────────────────────────────────────────────────
|
||||
@@ -134,6 +140,15 @@ export default function RequiredDocumentsListPage() {
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
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 { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
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)
|
||||
const deleteMutation = useDeleteRequiredDocument()
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (window.confirm(t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?'))) {
|
||||
await deleteMutation.mutateAsync(docId)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
}
|
||||
await deleteMutation.mutateAsync(docId)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
@@ -50,7 +51,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleDelete}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="text-muted-foreground hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
@@ -112,6 +113,15 @@ export default function RequiredDocumentsViewPage() {
|
||||
</div>
|
||||
</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>
|
||||
)
|
||||
}
|
||||
@@ -6,20 +6,11 @@ import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ActiveFilter } from '@/components/dataTableToolbar'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
|
||||
import { useUsers, useDeleteUser } from '@/features/allUsers/hooks/useAllUsers'
|
||||
import type { UserListItem } from '@/features/allUsers/api/allUsersApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -245,31 +236,18 @@ export default function UsersListPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete confirm dialog */}
|
||||
<AlertDialog open={!!deleteTarget} onOpenChange={(o) => !o && setDeleteTarget(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'users.deleteDialog.description',
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace('{name}', deleteTarget?.username ?? '')}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýok')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{t('common.delete', 'Öçür')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
|
||||
description={t(
|
||||
'users.deleteDialog.description',
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace('{name}', deleteTarget?.username ?? '')}
|
||||
confirmLabel={t('common.delete', 'Öçür')}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
isLoading={deleteUser.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -2,16 +2,7 @@ import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
@@ -189,33 +180,22 @@ export default function ClientsPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialog open={!!deleteTarget} onOpenChange={(open) => !open && setDeleteTarget(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('clients.deleteTitle', 'Müşderini pozmak')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.', {
|
||||
name: deleteTarget?.name ?? '',
|
||||
})}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id, {
|
||||
onSuccess: () => setDeleteTarget(null),
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('clients.deleteTitle', 'Müşderini pozmak')}
|
||||
description={t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.', {
|
||||
name: deleteTarget?.name ?? '',
|
||||
})}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id)
|
||||
setDeleteTarget(null)
|
||||
}
|
||||
}}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, ChevronDown } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
@@ -448,26 +439,15 @@ export default function ClientDetailPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
{/* ── Delete dialog ────────────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('clients.deleteTitle', 'Müşderini pozmak')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi?', { name: client.name })}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => deleteMutation.mutate(clientId, { onSuccess: () => navigate('/clients') })}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<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>
|
||||
)
|
||||
|
||||
@@ -2,16 +2,7 @@ import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -226,40 +217,20 @@ export default function OperatorsPage() {
|
||||
</div>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(open) => !open && setDeleteTarget(null)}
|
||||
>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("operators.deleteTitle", "Operatory pozmak")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
"operators.deleteConfirm",
|
||||
"{{name}} operatoryny pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.",
|
||||
{ name: deleteTarget?.name ?? "" },
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id, {
|
||||
onSuccess: () => setDeleteTarget(null),
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
description={t("operators.deleteDescription", 'Siz "{name}" operatoryny pozjakmy?').replace("{name}", deleteTarget?.name ?? "")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id)
|
||||
setDeleteTarget(null)
|
||||
}
|
||||
}}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,16 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, ChevronDown } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { InfoRow, AuditLog } from "@/components/viewPageComponents";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -427,32 +418,15 @@ export default function OperatorDetailPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
{/* ── Delete dialog ────────────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("operators.deleteTitle", "Operatory pozmak")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", {
|
||||
name: operator.name,
|
||||
})}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() =>
|
||||
deleteMutation.mutate(operatorId, {
|
||||
onSuccess: () => navigate("/operators"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<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