fixed some ui, upgrade functionalitym added permission to operator

This commit is contained in:
Jelaletdin12 committed 2026-09-03 20:31:34 +05:00
1 parent 25c104ad8c
commit 5ed4c9a8ec
46 files changed
+1058 -1401

No files matched your search

+45 -26
View File
@@ -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>
)
);
}