From 9e19ee7592e58fb66b8675dd02cb67b9b482bc8c Mon Sep 17 00:00:00 2001 From: dhinesh-m24 Date: Thu, 29 Jan 2026 16:26:08 +0530 Subject: [PATCH] feat: implement staff directory list view with search and filters --- apps/web/index.html | 3 +- apps/web/src/common/components/ui/badge.tsx | 35 ++ apps/web/src/common/components/ui/button.tsx | 89 ++- apps/web/src/common/components/ui/card.tsx | 80 +++ .../web/src/common/components/ui/checkbox.tsx | 21 + apps/web/src/common/components/ui/input.tsx | 53 +- apps/web/src/common/components/ui/select.tsx | 86 +++ .../web/src/common/components/ui/textarea.tsx | 20 + apps/web/src/features/layouts/Sidebar.tsx | 6 +- .../features/workforce/directory/AddStaff.tsx | 47 ++ .../workforce/directory/EditStaff.tsx | 85 +++ .../workforce/directory/StaffList.tsx | 435 +++++++++++++++ .../directory/components/EmployeeCard.tsx | 193 +++++++ .../directory/components/FilterBar.tsx | 75 +++ .../directory/components/StaffForm.tsx | 516 ++++++++++++++++++ .../directory/components/TabContent.tsx | 45 ++ apps/web/src/features/workforce/type.ts | 71 +++ apps/web/src/routes.tsx | 7 + apps/web/src/services/workforceService.ts | 437 +++++++++++++++ apps/web/tailwind.config.ts | 101 ++++ apps/web/tsconfig.app.json | 6 + apps/web/vite.config.ts | 7 + 22 files changed, 2379 insertions(+), 39 deletions(-) create mode 100644 apps/web/src/common/components/ui/badge.tsx create mode 100644 apps/web/src/common/components/ui/card.tsx create mode 100644 apps/web/src/common/components/ui/checkbox.tsx create mode 100644 apps/web/src/common/components/ui/select.tsx create mode 100644 apps/web/src/common/components/ui/textarea.tsx create mode 100644 apps/web/src/features/workforce/directory/AddStaff.tsx create mode 100644 apps/web/src/features/workforce/directory/EditStaff.tsx create mode 100644 apps/web/src/features/workforce/directory/StaffList.tsx create mode 100644 apps/web/src/features/workforce/directory/components/EmployeeCard.tsx create mode 100644 apps/web/src/features/workforce/directory/components/FilterBar.tsx create mode 100644 apps/web/src/features/workforce/directory/components/StaffForm.tsx create mode 100644 apps/web/src/features/workforce/directory/components/TabContent.tsx create mode 100644 apps/web/src/features/workforce/type.ts create mode 100644 apps/web/src/services/workforceService.ts create mode 100644 apps/web/tailwind.config.ts diff --git a/apps/web/index.html b/apps/web/index.html index af88f031..fd0a4be2 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -2,9 +2,8 @@ - - web + Krow-web
diff --git a/apps/web/src/common/components/ui/badge.tsx b/apps/web/src/common/components/ui/badge.tsx new file mode 100644 index 00000000..fd33e2e7 --- /dev/null +++ b/apps/web/src/common/components/ui/badge.tsx @@ -0,0 +1,35 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "../../../lib/utils" + +const badgeVariants = cva( + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", + secondary: + "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", + destructive: + "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", + outline: "text-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/apps/web/src/common/components/ui/button.tsx b/apps/web/src/common/components/ui/button.tsx index c8373194..a61355ad 100644 --- a/apps/web/src/common/components/ui/button.tsx +++ b/apps/web/src/common/components/ui/button.tsx @@ -1,40 +1,83 @@ import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const buttonVariants = cva( + "inline-flex items-center justify-center transition-premium gap-2 whitespace-nowrap rounded-xl text-base font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 active:scale-[0.98]", + { + variants: { + variant: { + default: + "bg-primary text-primary-foreground hover:opacity-90", + destructive: + "bg-destructive text-destructive-foreground hover:opacity-90", + outline: + "border border-primary text-primary bg-transparent hover:bg-primary/5 hover:text-primary/90 hover:border-primary/90", + secondary: + "bg-secondary text-secondary-foreground hover:bg-secondary/80", + ghost: "hover:bg-accent hover:text-accent-foreground", + link: "text-primary underline-offset-4 hover:underline", + }, + size: { + default: "h-10 px-5 py-6", + sm: "h-9 rounded-md px-3 text-xs", + lg: "h-11 rounded-lg px-8 text-base", + icon: "h-10 w-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) export interface ButtonProps - extends React.ButtonHTMLAttributes { - variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" - size?: "default" | "sm" | "lg" | "icon" + extends React.ButtonHTMLAttributes, + VariantProps { + asChild?: boolean + leadingIcon?: React.ReactNode + trailingIcon?: React.ReactNode } +/** + * Button component based on Shadcn UI. + * Supports variants (default, destructive, outline, secondary, ghost, link) + * and sizes (default, sm, lg, icon). + * Now supports leadingIcon and trailingIcon props. + */ const Button = React.forwardRef( - ({ className, variant = "default", size = "default", ...props }, ref) => { - const baseStyles = "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" - - const variants = { - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90", - outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground", - secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80", - ghost: "hover:bg-accent hover:text-accent-foreground", - link: "text-primary underline-offset-4 hover:underline", - } + ({ className, variant, size, asChild = false, leadingIcon, trailingIcon, children, ...props }, ref) => { + const Comp = asChild ? Slot : "button" - const sizes = { - default: "h-10 px-4 py-2", - sm: "h-9 rounded-md px-3 text-xs", - lg: "h-11 rounded-md px-8", - icon: "h-10 w-10", + // If asChild is true, we just render children as per standard Slot behavior + if (asChild) { + return ( + + {children} + + ) } return ( - + ) +} + +export const SelectValue = ({ placeholder }: any) => { + const { value } = React.useContext(SelectContext); + return {value || placeholder} +} + +export const SelectContent = ({ children, className }: any) => { + const { open } = React.useContext(SelectContext); + if (!open) return null; + return ( +
+
{children}
+
+ ) +} + +export const SelectItem = ({ value, children, className }: any) => { + const { onValueChange, setOpen } = React.useContext(SelectContext); + return ( +
{ onValueChange(value); setOpen(false); }} + className={cn("relative capitalize flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-2 text-sm outline-none hover:bg-slate-100 cursor-pointer", className)} + > + {children} +
+ ) +} diff --git a/apps/web/src/common/components/ui/textarea.tsx b/apps/web/src/common/components/ui/textarea.tsx new file mode 100644 index 00000000..6eaff0d5 --- /dev/null +++ b/apps/web/src/common/components/ui/textarea.tsx @@ -0,0 +1,20 @@ +import * as React from "react" +import { cn } from "@/lib/utils" + +const Textarea = React.forwardRef>( + ({ className, ...props }, ref) => { + return ( +