diff --git a/apps/dashboard/modules/inspections/inline-forms/inspection-category-inline-form.tsx b/apps/dashboard/modules/inspections/inline-forms/inspection-category-inline-form.tsx
index 215f0bc..9c6eabb 100644
--- a/apps/dashboard/modules/inspections/inline-forms/inspection-category-inline-form.tsx
+++ b/apps/dashboard/modules/inspections/inline-forms/inspection-category-inline-form.tsx
@@ -27,8 +27,8 @@ export function InspectionCategoryInlineForm({ onSuccess }: InlineCreateFormProp
const handleSubmit = async (values: FormValues) => {
try {
const result = await api.inspections.createCategory({
- inspection_name: values.inspection_name,
- })
+ title: values.inspection_name,
+ } as any)
toast.success("Inspection category created")
form.reset()
const item = (result as any)?.data ?? result
diff --git a/apps/dashboard/modules/inspections/inspection-form.tsx b/apps/dashboard/modules/inspections/inspection-form.tsx
index d32d83a..598c6ef 100644
--- a/apps/dashboard/modules/inspections/inspection-form.tsx
+++ b/apps/dashboard/modules/inspections/inspection-form.tsx
@@ -110,9 +110,9 @@ export function InspectionForm({ resourceId, initialData, onSuccess }: Inspectio
const { mutate, error, isPending } = useFormMutation(form, {
mutationFn: (values: InspectionFormValues) => {
const payload = mapFormToPayload(values)
- const promise = isEditing && resourceId
+ const promise = (isEditing && resourceId
? api.inspections.update(resourceId, payload)
- : api.inspections.create(payload)
+ : api.inspections.create(payload)) as any
toast.promise(promise, {
loading: isEditing ? "Updating inspection..." : "Creating inspection...",
success: isEditing ? "Inspection updated successfully" : "Inspection created successfully",
diff --git a/apps/dashboard/modules/invoices/invoice-document-form.tsx b/apps/dashboard/modules/invoices/invoice-document-form.tsx
index 1649a86..9e73fac 100644
--- a/apps/dashboard/modules/invoices/invoice-document-form.tsx
+++ b/apps/dashboard/modules/invoices/invoice-document-form.tsx
@@ -45,7 +45,7 @@ export function InvoiceDocumentForm({ invoiceId, onSuccess }: InvoiceDocumentFor
show_in_invoice: values.show_in_invoice,
show_in_estimate: values.show_in_estimate,
show_in_statement: values.show_in_statement,
- })
+ } as any)
toast.success("Document created")
form.reset()
onSuccess?.()
diff --git a/apps/dashboard/modules/job-cards/job-card-status-stepper.tsx b/apps/dashboard/modules/job-cards/job-card-status-stepper.tsx
index d3eea12..b8bb4ee 100644
--- a/apps/dashboard/modules/job-cards/job-card-status-stepper.tsx
+++ b/apps/dashboard/modules/job-cards/job-card-status-stepper.tsx
@@ -28,7 +28,7 @@ const STATUS_ICONS: Record
{
- jobCard?.setStatus(status)
+ (jobCard as any)?.setStatus(status)
},
})
diff --git a/apps/dashboard/modules/vehicles/inline-forms/document-type-inline-form.tsx b/apps/dashboard/modules/vehicles/inline-forms/document-type-inline-form.tsx
index cd665c0..1f22404 100644
--- a/apps/dashboard/modules/vehicles/inline-forms/document-type-inline-form.tsx
+++ b/apps/dashboard/modules/vehicles/inline-forms/document-type-inline-form.tsx
@@ -26,7 +26,7 @@ export function DocumentTypeInlineForm({ onSuccess }: InlineCreateFormProps) {
const handleSubmit = async (values: FormValues) => {
try {
- const result = await api.vehicleDocuments.createDocumentType({ title: values.title })
+ const result = await api.vehicleDocuments.createDocumentType({ title: values.title } as any)
toast.success("Document type created")
form.reset()
const item = (result as any)?.data ?? result
diff --git a/apps/dashboard/modules/vehicles/vehicle-form.tsx b/apps/dashboard/modules/vehicles/vehicle-form.tsx
index 36e4806..f90d733 100644
--- a/apps/dashboard/modules/vehicles/vehicle-form.tsx
+++ b/apps/dashboard/modules/vehicles/vehicle-form.tsx
@@ -128,8 +128,8 @@ export function VehicleForm({ resourceId, initialData, onSuccess }: VehicleFormP
mutationFn: (values: VehicleFormValues) => {
const payload = mapToPayload(values)
const promise = isEditing && resourceId
- ? api.vehicles.update(resourceId, payload)
- : api.vehicles.create(payload)
+ ? api.vehicles.update(resourceId, payload as any)
+ : api.vehicles.create(payload as any)
toast.promise(promise, {
loading: isEditing ? "Updating vehicle..." : "Creating vehicle...",
success: isEditing ? "Vehicle updated successfully" : "Vehicle created successfully",
diff --git a/apps/dashboard/shared/data-view/resource-page/resource-page.tsx b/apps/dashboard/shared/data-view/resource-page/resource-page.tsx
index 0103d0a..7d69240 100644
--- a/apps/dashboard/shared/data-view/resource-page/resource-page.tsx
+++ b/apps/dashboard/shared/data-view/resource-page/resource-page.tsx
@@ -27,11 +27,13 @@ type ReactNodeOrRender =
| ((context: ResourcePageContext) => React.ReactNode)
export type ResourcePageProps = Omit, "render"> & {
+ pageTitle?: string
headerProps?: DashboardHeaderProps | ((helpers: ResourcePageHeaderHelpers) => DashboardHeaderProps)
header?: ReactNodeOrRender | null
}
export function ResourcePage({
+ pageTitle,
headerProps: headerPropsProp,
header,
...crudResourceProps
@@ -46,13 +48,16 @@ export function ResourcePage({
invalidateQuery: context.invalidateQuery,
})
: headerPropsProp
+ const mergedHeaderProps = pageTitle
+ ? { title: pageTitle, ...resolvedHeaderProps }
+ : resolvedHeaderProps
const resolvedHeader = typeof header === "function" ? header(context) : header
return (
diff --git a/apps/dashboard/shared/data-view/resource-page/use-resource-page.ts b/apps/dashboard/shared/data-view/resource-page/use-resource-page.ts
index ebe535e..34e4a2e 100644
--- a/apps/dashboard/shared/data-view/resource-page/use-resource-page.ts
+++ b/apps/dashboard/shared/data-view/resource-page/use-resource-page.ts
@@ -15,7 +15,7 @@ type ApiInstance = ReturnType
export type ResourcePageClient = {
list(query?: any): Promise
- destroy(id: string): Promise
+ destroy?(id: string): Promise
}
export type ResourceItem = CrudListItem & BaseCrudItem
@@ -51,6 +51,7 @@ export function useResourcePage({
const { mutateAsync: deleteItem } = useMutation({
mutationFn: (id: string) => {
+ if (!client.destroy) return Promise.reject(new Error("Delete not supported"))
const promise = client.destroy(id)
toast.promise(promise, {
loading: "Deleting...",
diff --git a/packages/api/src/clients/auth.ts b/packages/api/src/clients/auth.ts
index d6542e5..196fc84 100644
--- a/packages/api/src/clients/auth.ts
+++ b/packages/api/src/clients/auth.ts
@@ -21,6 +21,6 @@ export class AuthClient extends ApiClient {
}
async logout() {
- return this.post(AUTH_ROUTES.LOGOUT, undefined)
+ return this.post(AUTH_ROUTES.LOGOUT, {} as never)
}
}
diff --git a/packages/api/src/clients/customers.ts b/packages/api/src/clients/customers.ts
index c7cb2a4..1cd6ae1 100644
--- a/packages/api/src/clients/customers.ts
+++ b/packages/api/src/clients/customers.ts
@@ -9,9 +9,7 @@ export const CUSTOMER_ROUTES = {
EXPORT: "/api/customers/export",
IMPORT: "/api/customers/import",
CUSTOMER_TYPES: "/api/customer-types",
- ADD_NOTE: "/api/customers/{id}/add-note",
- DELETE_NOTE: "/api/customers/{id}/delete-note",
- UPDATE_PERMISSIONS: "/api/customers/{id}/update-permissions",
+ NOTES: "/api/customers/{id}/notes/{note_id}",
} as const satisfies Record
export class CustomersClient extends CrudClient {
@@ -37,14 +35,10 @@ export class CustomersClient extends CrudClient) {
- return this.post(CUSTOMER_ROUTES.UPDATE_PERMISSIONS, payload as never, { params: { id } } as never)
+ return this.delete(CUSTOMER_ROUTES.NOTES, { params: { id: customerId, note_id: String(noteId) } } as never)
}
}
diff --git a/packages/api/src/clients/inspections.ts b/packages/api/src/clients/inspections.ts
index 1dd1ecf..1557436 100644
--- a/packages/api/src/clients/inspections.ts
+++ b/packages/api/src/clients/inspections.ts
@@ -47,7 +47,7 @@ export class InspectionsClient extends CrudClient<
async getById(id: string) {
const res = await super.list({ query: { id } } as never)
- return {...res, data: res.data[0] }
+ return {...res, data: res.data?.[0] }
}
async changeStatus(payload: ApiRequestBody) {
diff --git a/packages/api/src/clients/job-cards.ts b/packages/api/src/clients/job-cards.ts
index 2ef7195..cb5d6ca 100644
--- a/packages/api/src/clients/job-cards.ts
+++ b/packages/api/src/clients/job-cards.ts
@@ -1,7 +1,7 @@
import { CrudClient } from "../infra/crud-client"
import type { ApiClientOptions } from "../infra/client"
import type { ApiOperationResponse, ApiPath, ApiRequestBody, ApiResponse } from "../infra/types"
-import { ApiBaseResponse } from "src/contracts/types"
+import { ApiBaseResponse } from "../contracts/types"
export const JOB_CARD_ROUTES = {
INDEX: "/api/job-cards",