updates
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"use client"
|
||||
|
||||
import { SettingsForm } from "@/modules/settings/company/settings-form"
|
||||
|
||||
export default function CompanySettingsPage() {
|
||||
return (
|
||||
<div className="mx-auto max-w-3xl space-y-6 p-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">Company Settings</h1>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Manage your workshop profile, contact details, and preferences.
|
||||
</p>
|
||||
</div>
|
||||
<SettingsForm />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { GeneralPreferencesForm } from "@/modules/settings/configurations/general-preferences-form"
|
||||
|
||||
export default function GeneralPreferencesPage() {
|
||||
return <GeneralPreferencesForm />
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
"use client"
|
||||
|
||||
import Link from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { cn } from "@/shared/lib/utils"
|
||||
import DashboardPage from "@/base/components/layout/dashboard/dashboard-page"
|
||||
|
||||
const TABS = [
|
||||
{ label: "Sales", href: "/settings/configurations/preferences/sales" },
|
||||
{ label: "Purchases", href: "/settings/configurations/preferences/purchases" },
|
||||
{ label: "General", href: "/settings/configurations/preferences/general" },
|
||||
]
|
||||
|
||||
export default function ConfigurationsLayout({ children }: { children: React.ReactNode }) {
|
||||
const pathname = usePathname()
|
||||
|
||||
return (
|
||||
<DashboardPage headerProps={{ title: "Configurations" }}>
|
||||
<div className="space-y-6">
|
||||
<nav className="flex gap-1 border-b">
|
||||
{TABS.map((tab) => (
|
||||
<Link
|
||||
key={tab.href}
|
||||
href={tab.href}
|
||||
className={cn(
|
||||
"px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",
|
||||
pathname === tab.href
|
||||
? "border-primary text-primary"
|
||||
: "border-transparent text-muted-foreground hover:text-foreground"
|
||||
)}
|
||||
>
|
||||
{tab.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<div className="max-w-xl">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</DashboardPage>
|
||||
)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { PurchaseConfigForm } from "@/modules/settings/configurations/purchase-config-form"
|
||||
|
||||
export default function PurchasesConfigPage() {
|
||||
return <PurchaseConfigForm />
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { SalesConfigForm } from "@/modules/settings/configurations/sales-config-form"
|
||||
|
||||
export default function SalesConfigPage() {
|
||||
return <SalesConfigForm />
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
"use client"
|
||||
|
||||
import { DepartmentForm } from "@/modules/settings/departments/department-form"
|
||||
import { ResourcePage } from "@/shared/data-view/resource-page"
|
||||
import { ColumnHeader } from "@/shared/data-view/table-view"
|
||||
import FormDialog from "@/shared/components/form-dialog"
|
||||
import { DEPARTMENT_ROUTES } from "@garage/api"
|
||||
import type { DepartmentsClient } from "@garage/api"
|
||||
|
||||
export default function DepartmentsPage() {
|
||||
return (
|
||||
<ResourcePage<DepartmentsClient>
|
||||
pageTitle="Departments"
|
||||
routeKey={DEPARTMENT_ROUTES.INDEX}
|
||||
getClient={(api) => api.departments}
|
||||
headerProps={({ selectedItem, invalidateQuery }) => ({
|
||||
actions: (
|
||||
<FormDialog title="Department">
|
||||
{(resourceId) => (
|
||||
<DepartmentForm
|
||||
resourceId={resourceId}
|
||||
initialData={selectedItem}
|
||||
onSuccess={invalidateQuery}
|
||||
/>
|
||||
)}
|
||||
</FormDialog>
|
||||
),
|
||||
})}
|
||||
columns={({ actionsColumn }) => [
|
||||
{
|
||||
accessorKey: "name",
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Name" />,
|
||||
},
|
||||
{
|
||||
accessorKey: "assignment_type",
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Assignment Type" />,
|
||||
cell: ({ row }) => (row.original as any).assignment_type ?? "none",
|
||||
},
|
||||
actionsColumn(),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
"use client"
|
||||
|
||||
import { InsuranceTypeForm } from "@/modules/settings/insurance-types/insurance-type-form"
|
||||
import { ResourcePage } from "@/shared/data-view/resource-page"
|
||||
import { ColumnHeader } from "@/shared/data-view/table-view"
|
||||
import FormDialog from "@/shared/components/form-dialog"
|
||||
import { INSURANCE_TYPE_ROUTES } from "@garage/api"
|
||||
import type { InsuranceTypesClient } from "@garage/api"
|
||||
|
||||
export default function InsuranceTypesPage() {
|
||||
return (
|
||||
<ResourcePage<InsuranceTypesClient>
|
||||
pageTitle="Insurance Types"
|
||||
routeKey={INSURANCE_TYPE_ROUTES.INDEX}
|
||||
getClient={(api) => api.insuranceTypes}
|
||||
headerProps={({ selectedItem, invalidateQuery }) => ({
|
||||
actions: (
|
||||
<FormDialog title="Insurance Type">
|
||||
{(resourceId) => (
|
||||
<InsuranceTypeForm
|
||||
resourceId={resourceId}
|
||||
initialData={selectedItem}
|
||||
onSuccess={invalidateQuery}
|
||||
/>
|
||||
)}
|
||||
</FormDialog>
|
||||
),
|
||||
})}
|
||||
columns={({ actionsColumn }) => [
|
||||
{
|
||||
accessorKey: "title",
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Title" />,
|
||||
cell: ({ row }) => (row.original as any).title ?? (row.original as any).name ?? "—",
|
||||
},
|
||||
actionsColumn(),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +1,54 @@
|
||||
"use client"
|
||||
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { toast } from "sonner"
|
||||
import { CheckIcon, StarIcon, StarOffIcon, XIcon } from "lucide-react"
|
||||
|
||||
import { TaxForm } from "@/modules/settings/tax-rates/tax-form"
|
||||
import { ResourcePage } from "@/shared/data-view/resource-page"
|
||||
import { ColumnHeader } from "@/shared/data-view/table-view"
|
||||
import FormDialog from "@/shared/components/form-dialog"
|
||||
import { TAX_ROUTES } from "@garage/api"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { useAuthApi } from "@/shared/useApi"
|
||||
import { TAX_ROUTES } from "@garage/api"
|
||||
import type { TaxesClient } from "@garage/api"
|
||||
import { CheckIcon, XIcon } from "lucide-react"
|
||||
|
||||
function TaxDefaultCell({ row }: { row: any }) {
|
||||
const api = useAuthApi()
|
||||
const queryClient = useQueryClient()
|
||||
const isDefault: boolean = row.is_default ?? false
|
||||
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: () => {
|
||||
const promise = isDefault
|
||||
? api.taxes.removeDefault({ id: row.id })
|
||||
: api.taxes.setDefault({ id: row.id })
|
||||
toast.promise(promise, {
|
||||
loading: isDefault ? "Removing default..." : "Setting as default...",
|
||||
success: isDefault ? "Default removed" : "Set as default",
|
||||
error: isDefault ? "Failed to remove default" : "Failed to set as default",
|
||||
})
|
||||
return promise
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: [TAX_ROUTES.INDEX] })
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
disabled={isPending}
|
||||
onClick={() => mutate()}
|
||||
title={isDefault ? "Remove default" : "Set as default"}
|
||||
>
|
||||
{isDefault
|
||||
? <StarIcon className="h-4 w-4 text-yellow-500 fill-yellow-400" />
|
||||
: <StarOffIcon className="h-4 w-4 text-muted-foreground" />}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export default function TaxesPage() {
|
||||
return (
|
||||
@@ -49,10 +91,15 @@ export default function TaxesPage() {
|
||||
{
|
||||
accessorKey: "is_default",
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Default" />,
|
||||
cell: ({ row }) =>
|
||||
(row.original as any).is_default
|
||||
? <CheckIcon className="h-4 w-4 text-green-600" />
|
||||
: <XIcon className="h-4 w-4 text-muted-foreground" />,
|
||||
cell: ({ row }) => (row.original as any).is_default
|
||||
? <CheckIcon className="h-4 w-4 text-green-600" />
|
||||
: <XIcon className="h-4 w-4 text-muted-foreground" />,
|
||||
},
|
||||
{
|
||||
id: "set_default",
|
||||
header: () => <span className="sr-only">Set Default</span>,
|
||||
enableSorting: false,
|
||||
cell: ({ row }) => <TaxDefaultCell row={row.original} />,
|
||||
},
|
||||
actionsColumn(),
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user