feat: implement pending link and submit button components for improved UX

- Added PendingLink component to provide loading feedback on navigation links.
- Introduced PendingSubmitButton component for forms to indicate submission status.
- Updated dashboard, projects, tasks, and clients pages to utilize new components for better user experience during navigation and form submissions.
- Enhanced task and project actions with optimistic updates and loading states.
- Improved overall performance and user feedback during data fetching and action processing.
This commit is contained in:
Poyraz
2026-06-16 16:38:37 +03:00
parent 96eabeb48e
commit e03f315f3f
9 changed files with 773 additions and 82 deletions
+43
View File
@@ -0,0 +1,43 @@
"use client";
import { Loader2 } from "lucide-react";
import { Button } from "poyraz-ui/atoms";
import type { ComponentProps, ReactNode } from "react";
import { useFormStatus } from "react-dom";
import { cn } from "@/lib/utils";
type PendingSubmitButtonProps = ComponentProps<typeof Button> & {
idleIcon?: ReactNode;
pendingIcon?: ReactNode;
pendingChildren?: ReactNode;
};
export function PendingSubmitButton({
children,
className,
disabled,
idleIcon,
pendingChildren,
pendingIcon,
type = "submit",
...props
}: PendingSubmitButtonProps) {
const { pending } = useFormStatus();
const icon = pending
? pendingIcon ?? <Loader2 className="h-4 w-4 animate-spin" />
: idleIcon;
return (
<Button
{...props}
type={type}
disabled={disabled || pending}
aria-busy={pending}
className={cn(className)}
>
{icon}
{pending ? pendingChildren ?? children : children}
</Button>
);
}