From 7ced279ad53ebdae923ad9e3ba9d3fce759b7c84 Mon Sep 17 00:00:00 2001 From: DeepnaPooja Date: Fri, 18 Sep 2026 11:56:11 +0530 Subject: [PATCH] Add toggle controls and payment API fields --- .../components/ui/toggle-group.tsx | 89 +++++++++++++++++++ distribution_fe/components/ui/toggle.tsx | 44 +++++++++ distribution_fe/lib/api/sales.ts | 4 + distribution_fe/types/api.ts | 7 +- 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 distribution_fe/components/ui/toggle-group.tsx create mode 100644 distribution_fe/components/ui/toggle.tsx diff --git a/distribution_fe/components/ui/toggle-group.tsx b/distribution_fe/components/ui/toggle-group.tsx new file mode 100644 index 0000000..b85eb1a --- /dev/null +++ b/distribution_fe/components/ui/toggle-group.tsx @@ -0,0 +1,89 @@ +"use client" + +import * as React from "react" +import { Toggle as TogglePrimitive } from "@base-ui/react/toggle" +import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group" +import { type VariantProps } from "class-variance-authority" +import { cn } from "cn" + +import { toggleVariants } from "@/components/ui/toggle" + +const ToggleGroupContext = React.createContext< + VariantProps & { + spacing?: number + orientation?: "horizontal" | "vertical" + } +>({ + size: "default", + variant: "default", + spacing: 2, + orientation: "horizontal", +}) + +function ToggleGroup({ + className, + variant, + size, + spacing = 2, + orientation = "horizontal", + children, + ...props +}: ToggleGroupPrimitive.Props & + VariantProps & { + spacing?: number + orientation?: "horizontal" | "vertical" + }) { + return ( + + + {children} + + + ) +} + +function ToggleGroupItem({ + className, + children, + variant = "default", + size = "default", + ...props +}: TogglePrimitive.Props & VariantProps) { + const context = React.useContext(ToggleGroupContext) + + return ( + + {children} + + ) +} + +export { ToggleGroup, ToggleGroupItem } diff --git a/distribution_fe/components/ui/toggle.tsx b/distribution_fe/components/ui/toggle.tsx new file mode 100644 index 0000000..d6f4977 --- /dev/null +++ b/distribution_fe/components/ui/toggle.tsx @@ -0,0 +1,44 @@ +"use client" + +import { Toggle as TogglePrimitive } from "@base-ui/react/toggle" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "cn" + +const toggleVariants = cva( + "group/toggle inline-flex items-center justify-center gap-1 rounded-2xl text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", + { + variants: { + variant: { + default: "bg-transparent", + outline: "border border-input bg-transparent hover:bg-muted", + }, + size: { + default: + "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2", + sm: "h-7 min-w-7 px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5", + lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +function Toggle({ + className, + variant = "default", + size = "default", + ...props +}: TogglePrimitive.Props & VariantProps) { + return ( + + ) +} + +export { Toggle, toggleVariants } diff --git a/distribution_fe/lib/api/sales.ts b/distribution_fe/lib/api/sales.ts index 7d0c280..ea1232d 100644 --- a/distribution_fe/lib/api/sales.ts +++ b/distribution_fe/lib/api/sales.ts @@ -6,6 +6,7 @@ import type { InvoiceStatus, PaymentResponse, PaymentMethod, + EntryMode, ShopPOStatus, } from '@/types/api' @@ -87,6 +88,9 @@ export const invoices = { export interface PaymentBody { amount: number method: PaymentMethod + entryMode?: EntryMode + chequeNumber?: string | null + chequeDate?: string | null collectedByUserId?: string | null } diff --git a/distribution_fe/types/api.ts b/distribution_fe/types/api.ts index d8f799a..0fb545b 100644 --- a/distribution_fe/types/api.ts +++ b/distribution_fe/types/api.ts @@ -15,7 +15,8 @@ export type ShopPOStatus = 'Pending' | 'PartiallyFulfilled' | 'Fulfilled' | 'Can export type InvoiceStatus = 'Draft' | 'Printed' | 'Finalized' export type InvoiceCreationMode = 'ModeA' | 'ModeB' export type PaymentStatus = 'Pending' | 'PartiallyPaid' | 'Paid' -export type PaymentMethod = 'Cash' | 'Credit' +export type PaymentMethod = 'Cash' | 'Cheque' | 'Credit' +export type EntryMode = 'RealTime' | 'DayEndManual' export type DeliveryTaskStatus = 'Pending' | 'Delivered' | 'PartiallyDelivered' | 'Failed' export type VehicleType = 'Car' | 'Truck' | 'Van' | 'Motorcycle' | 'Bicycle' export type WarehouseType = @@ -666,8 +667,12 @@ export interface PaymentResponse { invoiceId: string amount: number method: PaymentMethod + entryMode: EntryMode + chequeNumber: string | null + chequeDate: string | null collectedAt: string collectedBy: string + recordedBy: string | null createdAt: string }