Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import {
|
||||
@@ -114,15 +115,14 @@ const navItems: {
|
||||
icon: ReceiptText,
|
||||
chevron: true,
|
||||
children: [
|
||||
{ title: "Invoices", code: "sales.invoices", href: "/dashboard/sales/invoices", icon: FileText },
|
||||
{ title: "Slips", code: "sales.slips", href: "/dashboard/sales/slips", icon: ShoppingCart },
|
||||
{ title: "Sales", code: "sales.invoices", href: "/dashboard/sales/invoices", icon: FileText },
|
||||
{ title: "Bundle Sales", code: "sales.bundle-sales", href: "/dashboard/sales/bundles", icon: Boxes },
|
||||
{ title: "Free Issues", code: "sales.free-issues", href: "/dashboard/sales/free-issues", icon: PackageX },
|
||||
// { title: "Reports", code: "sales.reports", href: "/dashboard/sales/reports", icon: FileBarChart },
|
||||
],
|
||||
},
|
||||
{ title: "Sales Returns", code: "sales-returns", href: "/dashboard/sales/sales-returns", icon: Undo2 },
|
||||
{ title: "Receiving", code: "receiving", href: "/dashboard/receiving/grn", icon: PackageCheck, chevron: true },
|
||||
{ title: "GRN", code: "receiving", href: "/dashboard/receiving/grn", icon: PackageCheck, chevron: true },
|
||||
{
|
||||
title: "Stock",
|
||||
code: "stock",
|
||||
@@ -144,7 +144,6 @@ const navItems: {
|
||||
],
|
||||
},
|
||||
{ title: "Warehouses", code: "warehouses", href: "/dashboard/warehouse", icon: Building2, chevron: true },
|
||||
{ title: "Orders", code: "orders", href: "/dashboard/orders", icon: ShoppingCart, chevron: true },
|
||||
{
|
||||
title: "Production",
|
||||
code: "production",
|
||||
@@ -275,13 +274,14 @@ function SidebarContent({
|
||||
)}
|
||||
>
|
||||
<Link href="/dashboard" className="flex items-center gap-2.5" onClick={onClose}>
|
||||
<div className="flex size-8 shrink-0 items-center justify-center rounded-xl bg-primary/10">
|
||||
<svg viewBox="0 0 48 32" className="h-3.5 w-5 fill-primary">
|
||||
<path d="M24 16c-3-8-11-12-16-8s-3 14 6 14c5 0 8.5-2.5 10-6 1.5 3.5 5 6 10 6 9 0 11-10 6-14s-13 0-16 8Z" />
|
||||
</svg>
|
||||
</div>
|
||||
{!iconOnly && (
|
||||
<span className="text-lg font-bold tracking-tight text-foreground">Hexa ERP</span>
|
||||
{iconOnly ? (
|
||||
<div className="flex size-8 shrink-0 items-center justify-center rounded-xl bg-primary/10">
|
||||
<svg viewBox="0 0 48 32" className="h-3.5 w-5 fill-primary">
|
||||
<path d="M24 16c-3-8-11-12-16-8s-3 14 6 14c5 0 8.5-2.5 10-6 1.5 3.5 5 6 10 6 9 0 11-10 6-14s-13 0-16 8Z" />
|
||||
</svg>
|
||||
</div>
|
||||
) : (
|
||||
<Image src="/images/hexa-erp-logo.png" alt="Hexa ERP" width={165} height={40} className="h-10 w-auto" priority />
|
||||
)}
|
||||
</Link>
|
||||
|
||||
@@ -407,13 +407,11 @@ function SidebarContent({
|
||||
})}
|
||||
</ul>
|
||||
|
||||
<div className="flex items-center justify-center pt-6">
|
||||
<div className="flex size-12 items-center justify-center rounded-2xl bg-muted ring-1 ring-foreground/10">
|
||||
<svg viewBox="0 0 48 32" className="h-4 w-6 fill-muted-foreground">
|
||||
<path d="M24 16c-3-8-11-12-16-8s-3 14 6 14c5 0 8.5-2.5 10-6 1.5 3.5 5 6 10 6 9 0 11-10 6-14s-13 0-16 8Z" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
{!iconOnly && (
|
||||
<p className="pt-6 text-center text-xs text-muted-foreground">
|
||||
© {new Date().getFullYear()} Hexa ERP
|
||||
</p>
|
||||
)}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ const SEGMENT_LABELS: Record<string, string> = {
|
||||
production: "Production",
|
||||
templates: "Templates",
|
||||
runs: "Runs",
|
||||
invoices: "Sales",
|
||||
}
|
||||
|
||||
function labelFor(segment: string): string {
|
||||
|
||||
@@ -79,6 +79,9 @@ const STOCK_TITLES: Record<string, string> = {
|
||||
}
|
||||
|
||||
function titleFromPath(pathname: string) {
|
||||
if (pathname === "/dashboard/sales/invoices") return "Sales"
|
||||
if (pathname === "/dashboard/sales/invoices/new") return "New Sale"
|
||||
|
||||
if (pathname === "/dashboard/receiving/grn") return "Goods Receipt Notes"
|
||||
if (pathname === "/dashboard/receiving/grn/new") return "Create Goods Receipt Note"
|
||||
if (/^\/dashboard\/receiving\/grn\/[^/]+$/.test(pathname)) return "Goods Receipt Note"
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import Link from "next/link"
|
||||
|
||||
import { buttonVariants } from "@/components/ui/button"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { SalesSlipSummary } from "@/types/sales"
|
||||
|
||||
export function FreeIssueSuggestions({ rows }: { rows: SalesSlipSummary[] }) {
|
||||
if (rows.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="rounded-2xl border p-4">
|
||||
<div className="mb-3 flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold text-foreground">Free issue suggestions</h2>
|
||||
<p className="text-sm text-muted-foreground">Recent free-issue slips created from the free-issues page.</p>
|
||||
</div>
|
||||
<Link href="/dashboard/sales/free-issues" className={cn(buttonVariants({ variant: "outline", size: "sm" }))}>
|
||||
Open free issues
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3 md:grid-cols-2 xl:grid-cols-3">
|
||||
{rows.map((row) => (
|
||||
<Link
|
||||
key={row.salesSlipId}
|
||||
href={`/dashboard/sales/free-issues/${row.salesSlipId}`}
|
||||
className="rounded-xl border bg-muted/20 p-3 transition-colors hover:bg-muted/40"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="font-medium text-foreground">{row.slipNo}</div>
|
||||
<div className="text-xs uppercase tracking-wide text-muted-foreground">{row.status}</div>
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-muted-foreground">{row.customerSnapshotName}</div>
|
||||
<div className="mt-2 text-sm text-foreground">Free qty total: {row.totals.freeQtyTotal.toFixed(2)}</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user