fixed some ui, upgrade functionalitym added permission to operator
This commit is contained in:
@@ -1,23 +1,29 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { cn } from '@/lib/utils'
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface FormActionsProps {
|
||||
isPending?: boolean
|
||||
onSubmit?: () => void
|
||||
onCancel?: () => void
|
||||
submitLabel?: ReactNode
|
||||
cancelLabel?: ReactNode
|
||||
loadingLabel?: ReactNode
|
||||
cancelVariant?: 'outline' | 'ghost'
|
||||
className?: string
|
||||
onNext?: () => void
|
||||
onPrev?: () => void
|
||||
nextLabel?: ReactNode
|
||||
prevLabel?: ReactNode
|
||||
showSubmit?: boolean
|
||||
isPending?: boolean;
|
||||
onSubmit?: () => void;
|
||||
onCancel?: () => void;
|
||||
submitLabel?: ReactNode;
|
||||
cancelLabel?: ReactNode;
|
||||
loadingLabel?: ReactNode;
|
||||
cancelVariant?: "outline" | "ghost";
|
||||
className?: string;
|
||||
onNext?: () => void;
|
||||
onPrev?: () => void;
|
||||
nextLabel?: ReactNode;
|
||||
prevLabel?: ReactNode;
|
||||
showSubmit?: boolean;
|
||||
/**
|
||||
* When true and not on the last step, render an extra "Save" button so an
|
||||
* edit can be persisted without navigating through every step. Suppressed
|
||||
* on the last step to avoid a duplicate submit button.
|
||||
*/
|
||||
saveOnEveryStep?: boolean;
|
||||
}
|
||||
|
||||
export function FormActions({
|
||||
@@ -27,23 +33,24 @@ export function FormActions({
|
||||
submitLabel,
|
||||
cancelLabel,
|
||||
loadingLabel,
|
||||
cancelVariant = 'outline',
|
||||
cancelVariant = "outline",
|
||||
className,
|
||||
onNext,
|
||||
onPrev,
|
||||
nextLabel,
|
||||
prevLabel,
|
||||
showSubmit = true,
|
||||
saveOnEveryStep = false,
|
||||
}: FormActionsProps) {
|
||||
const { t } = useTranslation()
|
||||
const { t } = useTranslation();
|
||||
|
||||
const cancelText = cancelLabel ?? t('common.cancel', 'Ýatyr')
|
||||
const loadingText = loadingLabel ?? t('common.saving', 'Saklanýar...')
|
||||
const prevText = prevLabel ?? t('common.prev', 'Yza')
|
||||
const nextText = nextLabel ?? t('common.next', 'Indiki')
|
||||
const cancelText = cancelLabel ?? t("common.cancel", "Ýatyr");
|
||||
const loadingText = loadingLabel ?? t("common.saving", "Saklanýar...");
|
||||
const prevText = prevLabel ?? t("common.prev", "Yza");
|
||||
const nextText = nextLabel ?? t("common.next", "Indiki");
|
||||
|
||||
return (
|
||||
<div className={cn('flex items-center justify-end gap-3', className)}>
|
||||
<div className={cn("flex items-center justify-end gap-3", className)}>
|
||||
{onCancel && (
|
||||
<Button type="button" variant={cancelVariant} onClick={onCancel} disabled={isPending}>
|
||||
{cancelText}
|
||||
@@ -59,6 +66,18 @@ export function FormActions({
|
||||
{nextText}
|
||||
</Button>
|
||||
)}
|
||||
{saveOnEveryStep && onSubmit && !showSubmit && (
|
||||
<Button type="button" onClick={onSubmit} disabled={isPending}>
|
||||
{isPending ? (
|
||||
<span className="flex items-center gap-2">
|
||||
<Loader2 size={14} className="animate-spin" />
|
||||
{loadingText}
|
||||
</span>
|
||||
) : (
|
||||
submitLabel
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
{showSubmit && onSubmit && (
|
||||
<Button type="button" onClick={onSubmit} disabled={isPending}>
|
||||
{isPending ? (
|
||||
@@ -72,5 +91,5 @@ export function FormActions({
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
||||
import { Check, ChevronsUpDown, Search, X, Eye, EyeOff, Upload, Hash } from "lucide-react";
|
||||
import { Check, ChevronsUpDown, Search, X, Eye, EyeOff, Upload, Hash, CreditCard } from "lucide-react";
|
||||
|
||||
import { cn, cleanPhoneNumber } from "@/lib/utils";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -29,7 +29,11 @@ export type FormInputType =
|
||||
| "select"
|
||||
| "searchable-select"
|
||||
| "file"
|
||||
| "textarea";
|
||||
| "textarea"
|
||||
| "card-number"
|
||||
| "card-name"
|
||||
| "passport-id"
|
||||
| "digits";
|
||||
|
||||
export interface SelectOption {
|
||||
value: string;
|
||||
@@ -54,6 +58,7 @@ export interface FormInputProps {
|
||||
rows?: number;
|
||||
name?: string;
|
||||
readOnly?: boolean;
|
||||
maxLength?: number;
|
||||
}
|
||||
|
||||
// ─── FieldLabel ───────────────────────────────────────────────────────────────
|
||||
@@ -277,6 +282,189 @@ function PhoneInput({
|
||||
);
|
||||
}
|
||||
|
||||
// ─── formatCardNumber helper ──────────────────────────────────────────────────
|
||||
|
||||
export function formatCardNumber(value?: string | null): string {
|
||||
if (!value) return "";
|
||||
const digits = value.replace(/\D/g, "").slice(0, 16);
|
||||
return digits.replace(/(\d{4})(?=\d)/g, "$1 ");
|
||||
}
|
||||
|
||||
// ─── CardNumberInput ──────────────────────────────────────────────────────────
|
||||
|
||||
export function CardNumberInput({
|
||||
value = "",
|
||||
onChange,
|
||||
placeholder = "9999 9999 9999 9999",
|
||||
error,
|
||||
disabled,
|
||||
required,
|
||||
label,
|
||||
className,
|
||||
name,
|
||||
readOnly,
|
||||
}: FormInputProps) {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const formatted = formatCardNumber(e.target.value);
|
||||
onChange?.(formatted);
|
||||
};
|
||||
|
||||
const display = formatCardNumber(value);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<FieldLabel label={label} required={required} />
|
||||
<div className="relative">
|
||||
<Input
|
||||
name={name}
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
value={display}
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
maxLength={19}
|
||||
className={cn("pr-10 font-mono tracking-wider", withError(error))}
|
||||
/>
|
||||
<CreditCard size={15} className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" />
|
||||
</div>
|
||||
<ErrorMsg error={error} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── CardNameInput ────────────────────────────────────────────────────────────
|
||||
|
||||
export function CardNameInput({
|
||||
value = "",
|
||||
onChange,
|
||||
placeholder,
|
||||
error,
|
||||
disabled,
|
||||
required,
|
||||
label,
|
||||
className,
|
||||
name,
|
||||
readOnly,
|
||||
}: FormInputProps) {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
// Only characters (letters in any alphabet) and spaces
|
||||
const sanitized = e.target.value.replace(/[^\p{L}\s]/gu, "");
|
||||
onChange?.(sanitized);
|
||||
};
|
||||
|
||||
const display = (value || "").replace(/[^\p{L}\s]/gu, "");
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<FieldLabel label={label} required={required} />
|
||||
<div className="relative">
|
||||
<Input
|
||||
name={name}
|
||||
type="text"
|
||||
value={display}
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
className={cn(withError(error))}
|
||||
/>
|
||||
</div>
|
||||
<ErrorMsg error={error} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── PassportIdInput ──────────────────────────────────────────────────────────
|
||||
|
||||
export function PassportIdInput({
|
||||
value = "",
|
||||
onChange,
|
||||
placeholder = "999999",
|
||||
error,
|
||||
disabled,
|
||||
required,
|
||||
label,
|
||||
className,
|
||||
name,
|
||||
readOnly,
|
||||
}: FormInputProps) {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const digits = e.target.value.replace(/\D/g, "").slice(0, 6);
|
||||
onChange?.(digits);
|
||||
};
|
||||
|
||||
const display = (value || "").replace(/\D/g, "").slice(0, 6);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<FieldLabel label={label} required={required} />
|
||||
<div className="relative">
|
||||
<Input
|
||||
name={name}
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
value={display}
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
maxLength={6}
|
||||
className={cn("font-mono tracking-wider", withError(error))}
|
||||
/>
|
||||
</div>
|
||||
<ErrorMsg error={error} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── DigitsInput ──────────────────────────────────────────────────────────────
|
||||
|
||||
export function DigitsInput({
|
||||
value = "",
|
||||
onChange,
|
||||
placeholder,
|
||||
error,
|
||||
disabled,
|
||||
required,
|
||||
label,
|
||||
className,
|
||||
name,
|
||||
readOnly,
|
||||
maxLength,
|
||||
}: FormInputProps) {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const raw = e.target.value.replace(/\D/g, "");
|
||||
const digits = maxLength ? raw.slice(0, maxLength) : raw;
|
||||
onChange?.(digits);
|
||||
};
|
||||
|
||||
const rawDisplay = (value || "").replace(/\D/g, "");
|
||||
const display = maxLength ? rawDisplay.slice(0, maxLength) : rawDisplay;
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<FieldLabel label={label} required={required} />
|
||||
<div className="relative">
|
||||
<Input
|
||||
name={name}
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
value={display}
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
maxLength={maxLength}
|
||||
className={cn(withError(error))}
|
||||
/>
|
||||
</div>
|
||||
<ErrorMsg error={error} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── DateInput (shadcn Popover + Calendar) ───────────────────────────────────
|
||||
|
||||
function DateInput({ value = "", onChange, error, disabled, required, label, className, placeholder = "Sene saýlaň" }: FormInputProps) {
|
||||
@@ -726,6 +914,10 @@ export function FormInput(props: FormInputProps) {
|
||||
|
||||
if (type === "number") return <NumberInput {...props} />;
|
||||
if (type === "phone") return <PhoneInput {...props} />;
|
||||
if (type === "card-number") return <CardNumberInput {...props} />;
|
||||
if (type === "card-name") return <CardNameInput {...props} />;
|
||||
if (type === "passport-id") return <PassportIdInput {...props} />;
|
||||
if (type === "digits") return <DigitsInput {...props} />;
|
||||
if (type === "date") return <DateInput {...props} />;
|
||||
if (type === "select") return <SelectInput {...props} />;
|
||||
if (type === "searchable-select") return <SearchableSelect {...props} />;
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Download, Eye, ChevronDown, Inbox } from "lucide-react";
|
||||
import { Download, Eye, ChevronDown, Inbox, Pencil, Trash2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
@@ -320,6 +331,87 @@ export function EmptyState({ label }: EmptyStateProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// ─── ViewActions ──────────────────────────────────────────────────────────────
|
||||
// Standard edit (→ `/edit` route) + delete (with confirmation AlertDialog)
|
||||
// action buttons rendered in a view page header. Delete validation and the
|
||||
// destructive mutation itself live in the caller's `onDelete`; this component
|
||||
// only handles the dialog flow (open → confirm → close).
|
||||
|
||||
export interface ViewActionsProps {
|
||||
editTo?: string;
|
||||
onDelete?: () => void | Promise<void>;
|
||||
deleteTitle?: string;
|
||||
deleteDescription?: string;
|
||||
deleting?: boolean;
|
||||
deleteConfirmLabel?: string;
|
||||
editDisabled?: boolean;
|
||||
deleteDisabled?: boolean;
|
||||
}
|
||||
|
||||
export function ViewActions({
|
||||
editTo,
|
||||
onDelete,
|
||||
deleteTitle,
|
||||
deleteDescription,
|
||||
deleting,
|
||||
deleteConfirmLabel,
|
||||
editDisabled,
|
||||
deleteDisabled,
|
||||
}: ViewActionsProps) {
|
||||
const { t } = useTranslation();
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
await onDelete?.();
|
||||
setDeleteOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{editTo && (
|
||||
<Button variant="outline" size="sm" asChild disabled={editDisabled}>
|
||||
<Link to={editTo}>
|
||||
<Pencil size={14} />
|
||||
</Link>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{onDelete && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={deleteDisabled}
|
||||
className="text-destructive border-destructive/30 hover:bg-destructive/10"
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{deleteTitle ?? t("Are you sure?", "Eminsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{deleteDescription ?? t("This action cannot be undone.", "Bu amal yzyna gaýtarylmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("Cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleConfirm}
|
||||
disabled={deleting}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleting ? t("Deleting...", "Öçürilýär...") : (deleteConfirmLabel ?? t("Delete", "Öçür"))}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── AuditLog ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export function AuditLog({ logs, currentPage, totalPages, totalCount, onPageChange, isLoading, onView }: AuditLogProps) {
|
||||
|
||||
@@ -72,8 +72,10 @@ export const usersApi = {
|
||||
/** GET /users — backend filters by `username` */
|
||||
getUsers: async (params: UsersListParams = {}, signal?: AbortSignal): Promise<UsersListResponse> => {
|
||||
const { page, limit, search, isActive } = params;
|
||||
const queryParams: Record<string, string | number | undefined> = { page, limit, isActive };
|
||||
if (search) queryParams.username = search;
|
||||
const { data } = await apiClient.get<UsersListResponse>("/users", {
|
||||
params: { page, limit, username: search, isActive },
|
||||
params: queryParams,
|
||||
signal,
|
||||
});
|
||||
return data;
|
||||
|
||||
@@ -151,13 +151,13 @@ export function CardBalanceForm({ mode, initialData }: CardBalanceFormProps) {
|
||||
label={t("Passport number", "Pasport belgisi")}
|
||||
value={form.passportNumber}
|
||||
onChange={setString("passportNumber")}
|
||||
placeholder={t("Passport number", "Pasport belgisi")}
|
||||
placeholder="999999"
|
||||
error={errMsg(errors.passportNumber)}
|
||||
required
|
||||
/>
|
||||
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number", "Kart belgisi")}
|
||||
value={form.cardNumber}
|
||||
onChange={setString("cardNumber")}
|
||||
|
||||
@@ -138,12 +138,12 @@ function StepCard({ form, errors, set, t, cardTypeOptions, branchOptions, distri
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("cardPin.field.cardNumber", "Kart belgisi")}
|
||||
required
|
||||
value={form.cardNumber}
|
||||
onChange={(v) => set("cardNumber", v)}
|
||||
placeholder={t("cardPin.field.cardNumber", "Kart belgisi")}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.cardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
@@ -317,12 +317,12 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
error={errors.passportSerie}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("cardPin.field.passportId", "Pasport belgisi")}
|
||||
required
|
||||
value={form.passportId}
|
||||
onChange={(v) => set("passportId", v)}
|
||||
placeholder={t("cardPin.field.passportId", "Pasport belgisi")}
|
||||
placeholder="999999"
|
||||
error={errors.passportId}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -258,7 +258,7 @@ function StepCard({ form, errors, set, t, initialData, userLocked, selfUserId, u
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("cardRequisiteForm.labels.cardNumber") || "Kart belgisi"}
|
||||
value={form.cardNumber}
|
||||
onChange={(v) => set("cardNumber", v)}
|
||||
@@ -439,12 +439,12 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
required
|
||||
value={form.passportId}
|
||||
onChange={(v) => set("passportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.passportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -683,7 +683,8 @@ export function CardRequisiteForm({ mode, initialData }: CardRequisiteFormProps)
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
nextLabel={t("Next", "Indiki")}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? handleSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={handleSubmit}
|
||||
submitLabel={
|
||||
mode === "create"
|
||||
? t("Create card requisite order", "Kart rekwiziti üçin sargyt dörediň")
|
||||
|
||||
@@ -27,6 +27,8 @@ interface CardTransactionFormProps {
|
||||
|
||||
type FlatErrors = Partial<Record<keyof CardTransactionFormData, string>>;
|
||||
|
||||
type CardiacTransactionLoose = Partial<Record<keyof CardTransactionFormData, string>>;
|
||||
|
||||
function flattenErrors(errors: Record<string, { message?: string } | undefined>): FlatErrors {
|
||||
const result: FlatErrors = {};
|
||||
for (const key of Object.keys(errors)) {
|
||||
@@ -92,18 +94,43 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
||||
defaultValues: initialData
|
||||
? {
|
||||
...DEFAULT_FORM_VALUES,
|
||||
number: initialData.number,
|
||||
name: initialData.name,
|
||||
type: initialData.type,
|
||||
month: initialData.month,
|
||||
year: initialData.year,
|
||||
number: initialData.number ?? "",
|
||||
name: initialData.name ?? "",
|
||||
type: initialData.type ?? "",
|
||||
month: initialData.month ?? "",
|
||||
year: initialData.year ?? "",
|
||||
userId: userLocked ? selfUserId : String(initialData.user?.id ?? ""),
|
||||
}
|
||||
: { ...DEFAULT_FORM_VALUES, userId: selfUserId },
|
||||
});
|
||||
|
||||
const form = watch();
|
||||
const errors = useMemo(() => flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>), [rhfErrors]);
|
||||
|
||||
// Live schema errors, only surfaced once the user attempts to submit, so
|
||||
// required-field warnings reliably show under fields (avoids RHF setError
|
||||
// snapshot timing; mirrors the step-based forms' submitted validation).
|
||||
const [submitAttempted, setSubmitAttempted] = useState(false);
|
||||
|
||||
const liveErrors = useMemo<FlatErrors>(() => {
|
||||
if (!submitAttempted) return {};
|
||||
const normalized: CardiacTransactionLoose = { ...DEFAULT_FORM_VALUES, ...form };
|
||||
for (const key of Object.keys(DEFAULT_FORM_VALUES) as (keyof CardTransactionFormData)[]) {
|
||||
if (normalized[key] == null) normalized[key] = "";
|
||||
}
|
||||
const parsed = cardTransactionFormSchema.safeParse(normalized);
|
||||
if (parsed.success) return {};
|
||||
const result: FlatErrors = {};
|
||||
for (const issue of parsed.error.issues) {
|
||||
const key = issue.path[0] as keyof CardTransactionFormData;
|
||||
result[key] = issue.message;
|
||||
}
|
||||
return result;
|
||||
}, [submitAttempted, form]);
|
||||
|
||||
const errors = useMemo(() => {
|
||||
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>);
|
||||
return { ...fromRHF, ...liveErrors };
|
||||
}, [rhfErrors, liveErrors]);
|
||||
|
||||
const createMutation = useCreateCardTransaction();
|
||||
const updateMutation = useUpdateCardTransaction(initialData?.id ?? 0);
|
||||
@@ -118,8 +145,13 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
||||
const errMsg = (msg: string | undefined) => (!msg ? undefined : msg.startsWith("validation.") ? t(msg, msg) : msg);
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const result = cardTransactionFormSchema.safeParse(getValues());
|
||||
const raw: CardiacTransactionLoose = { ...DEFAULT_FORM_VALUES, ...getValues() };
|
||||
for (const key of Object.keys(DEFAULT_FORM_VALUES) as (keyof CardTransactionFormData)[]) {
|
||||
if (raw[key] == null) raw[key] = "";
|
||||
}
|
||||
const result = cardTransactionFormSchema.safeParse(raw);
|
||||
if (!result.success) {
|
||||
setSubmitAttempted(true);
|
||||
for (const issue of result.error.issues) {
|
||||
const key = issue.path[0] as keyof CardTransactionFormData;
|
||||
setError(key, { message: issue.message });
|
||||
@@ -154,7 +186,7 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{/* Name */}
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Card name", "Kartyň ady")}
|
||||
value={form.name}
|
||||
onChange={setField("name")}
|
||||
@@ -177,11 +209,11 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
||||
|
||||
{/* Card Number */}
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number", "Kart belgisi")}
|
||||
value={form.number}
|
||||
onChange={setField("number")}
|
||||
placeholder={t("Card number", "Kart belgisi")}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errMsg(errors.number)}
|
||||
required
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import apiClient from "@/lib/api/client";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -49,7 +50,7 @@ export interface ClientPermission {
|
||||
|
||||
export interface ClientBranch {
|
||||
id: number;
|
||||
name: string;
|
||||
name: LocalizedText | string;
|
||||
region: string;
|
||||
district: string;
|
||||
uniqueCode: string;
|
||||
|
||||
@@ -483,16 +483,16 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number") || "Kart belgisi"}
|
||||
required
|
||||
value={form.cardNumber}
|
||||
onChange={(v) => set("cardNumber", v)}
|
||||
placeholder={t("Card number") || "Kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.cardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Name on card") || "Kartdaky ady"}
|
||||
required
|
||||
value={form.cardName}
|
||||
@@ -546,12 +546,12 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
required
|
||||
value={form.passportId}
|
||||
onChange={(v) => set("passportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.passportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -675,11 +675,11 @@ function StepContact({ form, errors, set, t }: StepContentProps) {
|
||||
error={errors.phoneAdditional}
|
||||
/>
|
||||
<FormInput
|
||||
type="phone"
|
||||
type="digits"
|
||||
label={t("Home phone") || "Öý telefony"}
|
||||
value={form.phoneHome}
|
||||
onChange={(v) => set("phoneHome", v)}
|
||||
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
||||
placeholder={t("Home phone") || "Öý telefony"}
|
||||
error={errors.phoneHome}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -842,12 +842,12 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
required
|
||||
value={form.guarantorPassportId}
|
||||
onChange={(v) => set("guarantorPassportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.guarantorPassportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -856,16 +856,16 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number") || "Kart belgisi"}
|
||||
required
|
||||
value={form.guarantorCardNumber}
|
||||
onChange={(v) => set("guarantorCardNumber", v)}
|
||||
placeholder={t("Card number") || "Kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.guarantorCardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Name on card") || "Kartdaky ady"}
|
||||
required
|
||||
value={form.guarantorCardName}
|
||||
@@ -951,11 +951,11 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
value={form.guarantor2PassportId}
|
||||
onChange={(v) => set("guarantor2PassportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.guarantor2PassportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -964,15 +964,15 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number") || "Kart belgisi"}
|
||||
value={form.guarantor2CardNumber}
|
||||
onChange={(v) => set("guarantor2CardNumber", v)}
|
||||
placeholder={t("Card number") || "Kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.guarantor2CardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Name on card") || "Kartdaky ady"}
|
||||
value={form.guarantor2CardName}
|
||||
onChange={(v) => set("guarantor2CardName", v)}
|
||||
@@ -1198,7 +1198,8 @@ export function LoanOrderMobileForm({ initialData, mode }: LoanOrderMobileFormPr
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={mode === "create" ? t("loanOrders.create") || "Karz sargyt döredüň" : t("common.save") || "Ýatda sakla"}
|
||||
loadingLabel={t("common.loading") || "Ýüklenilýär..."}
|
||||
cancelLabel={t("common.cancel") || "Ýatyr"}
|
||||
@@ -1236,7 +1237,7 @@ function mapInitial(order: LoanOrderMobile): Partial<LoanOrderMobileFormData> {
|
||||
email: order.email ?? "",
|
||||
phone: formatFromApiPhone(order.phone),
|
||||
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
||||
phoneHome: formatFromApiPhone(order.phoneHome),
|
||||
phoneHome: (order.phoneHome ?? order.homePhone ?? "").replace(/\D/g, ""),
|
||||
workCompany: order.workCompany ?? "",
|
||||
workCompanyAccountantNumber: formatFromApiPhone(order.workCompanyAccountantNumber),
|
||||
workRegion: order.workRegion ?? "AG",
|
||||
|
||||
@@ -279,14 +279,14 @@ function StepLoan({ form, errors, set, t, initialData }: StepContentProps & { in
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.loanCardInfo") || "Karz karty maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Loan card number") || "Karz kart belgisi"}
|
||||
value={form.loanCardNumber}
|
||||
onChange={(v) => set("loanCardNumber", v)}
|
||||
placeholder={t("Loan card number") || "Karz kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Loan card name") || "Karz kartdaky ady"}
|
||||
value={form.loanCardName}
|
||||
onChange={(v) => set("loanCardName", v)}
|
||||
@@ -538,16 +538,16 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number") || "Kart belgisi"}
|
||||
required
|
||||
value={form.cardNumber}
|
||||
onChange={(v) => set("cardNumber", v)}
|
||||
placeholder={t("Card number") || "Kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.cardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Name on card") || "Kartdaky ady"}
|
||||
required
|
||||
value={form.cardName}
|
||||
@@ -601,12 +601,12 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
required
|
||||
value={form.passportId}
|
||||
onChange={(v) => set("passportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.passportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -721,11 +721,11 @@ function StepContact({ form, errors, set, t }: StepContentProps) {
|
||||
error={errors.phoneAdditional}
|
||||
/>
|
||||
<FormInput
|
||||
type="phone"
|
||||
type="digits"
|
||||
label={t("Home phone") || "Öý telefony"}
|
||||
value={form.phoneHome}
|
||||
onChange={(v) => set("phoneHome", v)}
|
||||
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
||||
placeholder={t("Home phone") || "Öý telefony"}
|
||||
error={errors.phoneHome}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -890,12 +890,12 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
required
|
||||
value={form.guarantorPassportId}
|
||||
onChange={(v) => set("guarantorPassportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.guarantorPassportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -904,16 +904,16 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number") || "Kart belgisi"}
|
||||
required
|
||||
value={form.guarantorCardNumber}
|
||||
onChange={(v) => set("guarantorCardNumber", v)}
|
||||
placeholder={t("Card number") || "Kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.guarantorCardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Name on card") || "Kartdaky ady"}
|
||||
required
|
||||
value={form.guarantorCardName}
|
||||
@@ -1009,11 +1009,11 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
||||
</BentoCard>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("Passport id") || "Pasport belgisi"}
|
||||
value={form.guarantor2PassportId}
|
||||
onChange={(v) => set("guarantor2PassportId", v)}
|
||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||
placeholder="999999"
|
||||
error={errors.guarantor2PassportId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -1022,15 +1022,15 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-number"
|
||||
label={t("Card number") || "Kart belgisi"}
|
||||
value={form.guarantor2CardNumber}
|
||||
onChange={(v) => set("guarantor2CardNumber", v)}
|
||||
placeholder={t("Card number") || "Kart belgisi"}
|
||||
placeholder="9999 9999 9999 9999"
|
||||
error={errors.guarantor2CardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="card-name"
|
||||
label={t("Name on card") || "Kartdaky ady"}
|
||||
value={form.guarantor2CardName}
|
||||
onChange={(v) => set("guarantor2CardName", v)}
|
||||
@@ -1270,7 +1270,8 @@ export function LoanOrderForm({ mode, initialData }: LoanOrderFormProps) {
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={mode === "create" ? t("loanOrders.create") || "Karz sargyt döredüň" : t("common.save") || "Ýatda sakla"}
|
||||
loadingLabel={t("common.loading") || "Ýüklenilýär..."}
|
||||
cancelLabel={t("common.cancel") || "Ýatyr"}
|
||||
@@ -1325,7 +1326,7 @@ function mapInitial(order: LoanOrder): Partial<LoanOrderFormData> {
|
||||
passportFour: order.passportFour ?? order.passportPage32Url ?? "",
|
||||
phone: formatFromApiPhone(order.phone),
|
||||
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
||||
phoneHome: formatFromApiPhone(order.phoneHome ?? order.homePhone),
|
||||
phoneHome: (order.phoneHome ?? order.homePhone ?? "").replace(/\D/g, ""),
|
||||
email: order.email ?? "",
|
||||
workCompany: order.workCompany ?? "",
|
||||
workCompanyAccountantNumber: formatFromApiPhone(order.workCompanyAccountantNumber ?? order.workHrPhone),
|
||||
|
||||
@@ -68,11 +68,8 @@ export const loanOrderFormSchema = z.object({
|
||||
.optional(),
|
||||
phoneHome: z
|
||||
.string()
|
||||
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || val.replace(/\D/g, "").length === 8, {
|
||||
message: "validation.invalidPhone",
|
||||
})
|
||||
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2)), {
|
||||
message: "validation.invalidPhonePrefix",
|
||||
.refine((val) => !val || /^\d+$/.test(val.replace(/\s/g, "")), {
|
||||
message: "validation.invalidNumber",
|
||||
})
|
||||
.optional(),
|
||||
email: z.string().optional(),
|
||||
|
||||
@@ -182,11 +182,11 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("loanPaidOffLetters.fields.passportId", "Pasport belgisi")}
|
||||
value={form.passportId}
|
||||
onChange={set("passportId")}
|
||||
placeholder="101010"
|
||||
placeholder="999999"
|
||||
error={errors.passportId}
|
||||
required
|
||||
/>
|
||||
@@ -427,7 +427,21 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
|
||||
});
|
||||
|
||||
const form = watch();
|
||||
const errors = useMemo(() => flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>), [rhfErrors]);
|
||||
|
||||
// Live-recomputed validation errors for submitted steps, so required-field
|
||||
// warnings stay visible under fields (mirrors loanOrderForm behavior).
|
||||
const allSubmittedErrors = useMemo(() => {
|
||||
const result: FlatErrors = {};
|
||||
for (const stepIdx of submittedSteps) {
|
||||
Object.assign(result, STEPS[stepIdx].validate(form));
|
||||
}
|
||||
return result;
|
||||
}, [form, submittedSteps]);
|
||||
|
||||
const errors = useMemo(() => {
|
||||
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>);
|
||||
return { ...fromRHF, ...allSubmittedErrors };
|
||||
}, [rhfErrors, allSubmittedErrors]);
|
||||
|
||||
const set = useCallback(
|
||||
<K extends keyof LoanPaidOffLetterFormData>(key: K) =>
|
||||
@@ -586,7 +600,8 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={mode === "create" ? t("common.create", "Döret") : t("common.save", "Ýatda sakla")}
|
||||
loadingLabel={t("common.loading", "Ýüklenilýär...")}
|
||||
cancelLabel={t("common.cancel", "Ýatyr")}
|
||||
|
||||
@@ -8,9 +8,13 @@ import { FormInput } from "@/components/formInput";
|
||||
import { InfiniteSelect, type InfiniteSelectOption, type InfiniteSelectProps } from "@/components/infiniteSelect";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { KeyRound } from "lucide-react";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { AvatarUpload } from "@/components/avatarUpload";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
import { AssignDialog, type AssignDialogKind } from "@/features/shared/components/assignDialog";
|
||||
import { useCreateOperator, useUpdateOperator, operatorKeys } from "../hooks/useOperators";
|
||||
import { useInfiniteRoles } from "@/features/roles/hooks/useRoles";
|
||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||
@@ -62,6 +66,9 @@ export function OperatorForm({ mode, initialData }: OperatorFormProps) {
|
||||
|
||||
const isPending = createOperator.isPending || updateOperator.isPending;
|
||||
|
||||
const [assignDialog, setAssignDialog] = useState<AssignDialogKind | null>(null);
|
||||
const operatorPermissions = (initialData as OperatorDetail | undefined)?.permissions ?? [];
|
||||
|
||||
const schema = useMemo(() => operatorFormSchema(mode, t), [mode, t, i18n.language]);
|
||||
|
||||
// ── Role infinite-scroll select ──
|
||||
@@ -210,9 +217,17 @@ export function OperatorForm({ mode, initialData }: OperatorFormProps) {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{mode === "create" ? t("operators.createTitle", "Operator dörediň") : t("operators.editTitle", "Operator üýtgetmek")}
|
||||
</h1>
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{mode === "create" ? t("operators.createTitle", "Operator dörediň") : t("operators.editTitle", "Operator üýtgetmek")}
|
||||
</h1>
|
||||
{mode === "edit" && (
|
||||
<Button type="button" variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("permission")}>
|
||||
<KeyRound size={14} />
|
||||
{t("profile.actions.assignPermission", "Rugsat birikdiriň")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<BentoGrid cols={2}>
|
||||
{/* ── Identity ── */}
|
||||
<BentoCard title={t("users.sections.identity", "Şahsy maglumat")}>
|
||||
@@ -358,6 +373,29 @@ export function OperatorForm({ mode, initialData }: OperatorFormProps) {
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
|
||||
{/* ── Permissions (Edit mode only) ── */}
|
||||
{mode === "edit" && (
|
||||
<BentoCard title={t("users.sections.permissions", "Rugsatlar")} span="full">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-2">
|
||||
<div className="flex flex-wrap gap-1.5 items-center">
|
||||
{operatorPermissions.length > 0 ? (
|
||||
operatorPermissions.map((p) => (
|
||||
<Badge key={p.id} variant="secondary">
|
||||
{p.name}
|
||||
</Badge>
|
||||
))
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">{t("common.noData", "Rugsat ýok")}</span>
|
||||
)}
|
||||
</div>
|
||||
<Button type="button" variant="outline" size="sm" className="gap-1.5 shrink-0" onClick={() => setAssignDialog("permission")}>
|
||||
<KeyRound size={14} />
|
||||
{t("profile.actions.assignPermission", "Rugsat birikdiriň")}
|
||||
</Button>
|
||||
</div>
|
||||
</BentoCard>
|
||||
)}
|
||||
</BentoGrid>
|
||||
|
||||
<FormActions
|
||||
@@ -366,6 +404,21 @@ export function OperatorForm({ mode, initialData }: OperatorFormProps) {
|
||||
onCancel={() => navigate(-1)}
|
||||
submitLabel={mode === "create" ? t("users.actions.create", "Ulanyjy dörediň") : t("users.actions.save", "Ýatda sakla")}
|
||||
/>
|
||||
|
||||
{/* ── Assign dialog (edit mode only) ── */}
|
||||
{mode === "edit" && assignDialog && initialData?.id && (
|
||||
<AssignDialog
|
||||
kind={assignDialog}
|
||||
targetUserId={initialData.id}
|
||||
targetUserName={
|
||||
[initialData.firstName, initialData.lastName].filter(Boolean).join(" ") || initialData.name || initialData.username
|
||||
}
|
||||
onAssigned={() => {
|
||||
queryClient.invalidateQueries({ queryKey: operatorKeys.detail(initialData.id) });
|
||||
}}
|
||||
onClose={() => setAssignDialog(null)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -335,12 +335,12 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps) {
|
||||
error={errors.passportSerie}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="passport-id"
|
||||
label={t("cardOrder.field.passportId", "Pasport belgisi")}
|
||||
required
|
||||
value={form.passportId}
|
||||
onChange={(v) => set("passportId", v)}
|
||||
placeholder={t("cardOrder.field.passportId", "Pasport belgisi")}
|
||||
placeholder="999999"
|
||||
error={errors.passportId}
|
||||
/>
|
||||
<FormInput
|
||||
|
||||
@@ -18,7 +18,11 @@ export interface AddPermissionRolePayload {
|
||||
roleId: number;
|
||||
}
|
||||
|
||||
export type AddPermissionUserPayload = AddPermissionRolePayload;
|
||||
export interface AddPermissionUserPayload {
|
||||
permissionId: number;
|
||||
userId: number;
|
||||
effect?: string;
|
||||
}
|
||||
|
||||
// Re-export so shared hooks can import from one place
|
||||
export type { BranchListParams, BranchListResponse };
|
||||
@@ -76,7 +80,17 @@ export async function postPermissionRole(payload: AddPermissionRolePayload): Pro
|
||||
await apiClient.post("/permission-roles", payload);
|
||||
}
|
||||
|
||||
export const postPermissionUser = postPermissionRole;
|
||||
/**
|
||||
* POST /permission-users
|
||||
* Assigns a permission to a user.
|
||||
*/
|
||||
export async function postPermissionUser(payload: AddPermissionUserPayload): Promise<void> {
|
||||
await apiClient.post("/permission-users", {
|
||||
permissionId: payload.permissionId,
|
||||
userId: payload.userId,
|
||||
effect: payload.effect ?? "allow",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy for branch list fetching — kept here so shared hooks
|
||||
|
||||
214
src/features/shared/components/assignDialog.tsx
Normal file
214
src/features/shared/components/assignDialog.tsx
Normal file
@@ -0,0 +1,214 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { InfiniteSelect, type InfiniteSelectOption } from "@/components/infiniteSelect";
|
||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||
import { useInfiniteRoles } from "@/features/roles/hooks/useRoles";
|
||||
import { useInfinitePermissions } from "@/features/permissions/hooks/usePermissions";
|
||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||
import { useAssignRoleToUser, useAssignPermissionToUser, useAssignBranchToUser } from "@/features/shared/hooks/useSharedUserAssignments";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
export type AssignDialogKind = "role" | "permission" | "branch";
|
||||
|
||||
export interface AssignDialogProps {
|
||||
kind: AssignDialogKind;
|
||||
onClose: () => void;
|
||||
targetUserId?: number;
|
||||
targetUserName?: string;
|
||||
onAssigned?: () => void;
|
||||
}
|
||||
|
||||
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, permission, or branch to a user (staff).
|
||||
* Permissions are assigned directly to users via POST /permission-users.
|
||||
*/
|
||||
export function AssignDialog({ kind, onClose, targetUserId, targetUserName, onAssigned }: AssignDialogProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as keyof LocalizedText;
|
||||
|
||||
const [targetSearch, setTargetSearch] = useState("");
|
||||
const [targetValue, setTargetValue] = useState<string>(() => (targetUserId ? String(targetUserId) : ""));
|
||||
const [resourceSearch, setResourceSearch] = useState("");
|
||||
const [resourceValue, setResourceValue] = useState("");
|
||||
const [error, setError] = useState<string | undefined>();
|
||||
|
||||
// Target query: admin users list (GET /users)
|
||||
const staffQuery = useInfiniteUsers(targetSearch);
|
||||
|
||||
// Resource queries
|
||||
const rolesQuery = useInfiniteRoles(resourceSearch, kind === "role");
|
||||
const permissionsQuery = useInfinitePermissions(resourceSearch, kind === "permission");
|
||||
const branchesQuery = useInfiniteBranches(resourceSearch, kind === "branch");
|
||||
|
||||
const roleMutation = useAssignRoleToUser();
|
||||
const permissionMutation = useAssignPermissionToUser();
|
||||
const branchMutation = useAssignBranchToUser();
|
||||
const isPending = roleMutation.isPending || permissionMutation.isPending || branchMutation.isPending;
|
||||
|
||||
const targetOptions: InfiniteSelectOption[] = useMemo(() => {
|
||||
const opts: InfiniteSelectOption[] = (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),
|
||||
}));
|
||||
|
||||
if (targetUserId) {
|
||||
const valStr = String(targetUserId);
|
||||
if (!opts.some((o) => o.value === valStr)) {
|
||||
opts.unshift({ value: valStr, label: targetUserName || valStr });
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
}, [staffQuery.data, targetUserId, targetUserName]);
|
||||
|
||||
const targetLabel = t("profile.assign.userLabel", "Ulanyjy");
|
||||
const targetLoading = staffQuery.isLoading;
|
||||
const targetLoadingMore = staffQuery.isFetchingNextPage;
|
||||
const targetHasNextPage = !!staffQuery.hasNextPage;
|
||||
const loadMoreTargets = () => 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 userId = Number(targetValue);
|
||||
const secondId = Number(resourceValue);
|
||||
const onSuccess = () => {
|
||||
setResourceValue("");
|
||||
onAssigned?.();
|
||||
onClose();
|
||||
};
|
||||
|
||||
if (kind === "role") {
|
||||
roleMutation.mutate({ userId, roleId: secondId }, { onSuccess });
|
||||
} else if (kind === "permission") {
|
||||
permissionMutation.mutate({ userId, permissionId: secondId, effect: "allow" }, { onSuccess });
|
||||
} else {
|
||||
branchMutation.mutate({ userId, 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);
|
||||
}}
|
||||
disabled={!!targetUserId || isPending}
|
||||
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}
|
||||
disabled={isPending}
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -5,9 +5,11 @@ import {
|
||||
postBranchUser,
|
||||
postRoleUser,
|
||||
postPermissionRole,
|
||||
postPermissionUser,
|
||||
type AddBranchUserPayload,
|
||||
type AddRoleUserPayload,
|
||||
type AddPermissionRolePayload,
|
||||
type AddPermissionUserPayload,
|
||||
} from "../api/sharedApi";
|
||||
|
||||
// ─── Query Keys ───────────────────────────────────────────────────────────────
|
||||
@@ -21,7 +23,11 @@ export const userProfileKeys = {
|
||||
*/
|
||||
function useInvalidateProfile() {
|
||||
const queryClient = useQueryClient();
|
||||
return () => queryClient.invalidateQueries({ queryKey: userProfileKeys.profile });
|
||||
return () => {
|
||||
queryClient.invalidateQueries({ queryKey: userProfileKeys.profile });
|
||||
queryClient.invalidateQueries({ queryKey: ["operators"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||
};
|
||||
}
|
||||
|
||||
// ─── useAssignRoleToUser ──────────────────────────────────────────────────────
|
||||
@@ -61,7 +67,23 @@ export function useAssignPermissionToRole() {
|
||||
});
|
||||
}
|
||||
|
||||
export const useAssignPermissionToUser = useAssignPermissionToRole;
|
||||
// ─── useAssignPermissionToUser ────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* POST /permission-users — assigns a permission to the given staff user and refreshes the caches.
|
||||
*/
|
||||
export function useAssignPermissionToUser() {
|
||||
const { t } = useTranslation();
|
||||
const invalidateProfile = useInvalidateProfile();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (payload: AddPermissionUserPayload) => postPermissionUser(payload),
|
||||
onSuccess: () => {
|
||||
invalidateProfile();
|
||||
toast.success(t("profile.assign.success", "Üstünlikli birikdirildi"));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ─── useAssignBranchToUser ────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -1565,5 +1565,5 @@
|
||||
"profile.sections.org": "Organization details",
|
||||
"profile.actions.assignBranch": "Assign branch",
|
||||
"profile.assign.success": "Assigned successfully",
|
||||
"profile.assign.userLabel": "User (staff)"
|
||||
"profile.assign.userLabel": "User"
|
||||
}
|
||||
|
||||
@@ -1566,5 +1566,5 @@
|
||||
"profile.sections.org": "Организационные данные",
|
||||
"profile.actions.assignBranch": "Назначить филиал",
|
||||
"profile.assign.success": "Успешно назначено",
|
||||
"profile.assign.userLabel": "Пользователь (staff)"
|
||||
"profile.assign.userLabel": "Пользователь"
|
||||
}
|
||||
|
||||
@@ -1457,7 +1457,7 @@
|
||||
"users.fields.passwordHint": "Iň az 6 harp",
|
||||
"users.fields.phoneVerified": "Telefon tassyklanan",
|
||||
"users.fields.phoneVerifiedHint": "SMS arkaly tassyklandy",
|
||||
"users.fields.avatar": "Awatar",
|
||||
"users.fields.avatar": "Avatar",
|
||||
"users.fields.avatarUpload": "Surat saýlaň",
|
||||
"users.fields.avatarUploading": "Ýüklenýär...",
|
||||
"users.fields.avatarRemove": "Aýyr",
|
||||
@@ -1564,5 +1564,5 @@
|
||||
"profile.sections.org": "Guramaçylyk maglumatlary",
|
||||
"profile.actions.assignBranch": "Şahamça birikdiriň",
|
||||
"profile.assign.success": "Üstünlikli birikdirildi",
|
||||
"profile.assign.userLabel": "Ulanyjy (staff)"
|
||||
"profile.assign.userLabel": "Ulanyjy"
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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