feat: integrate dialog close context in vendor select field and CRUD dialog components feat: enhance vendor general info to format status using utility function feat: implement form dialog context for managing dialog close actions feat: add async select field dialog close context for better form handling fix: update form mutation hook to close dialog on successful submission feat: extend document print types to include expense and credit note feat: add settings update payload type to include logo and other fields feat: create employee attendance and work history pages with resource management feat: implement payment made and received detail pages with actions feat: add quick shortcuts component for easy navigation in the dashboard feat: create actions for payment made and received with print and delete options feat: implement dialog close context for better dialog management feat: add error parsing utility for improved error handling in API responses
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { ApiClient, type ApiClientOptions } from "../infra/client"
|
|
import type { ApiPath } from "../infra/types"
|
|
|
|
export const SETTINGS_ROUTES = {
|
|
INDEX: "/api/settings",
|
|
} as const satisfies Record<string, ApiPath>
|
|
|
|
export type SettingsUpdatePayload = {
|
|
name?: string
|
|
email?: string
|
|
phone?: string
|
|
alternative_phone?: string
|
|
website?: string
|
|
time_zone?: string
|
|
upi_id?: string
|
|
first_day_of_work?: string
|
|
latitude?: string | number
|
|
longitude?: string | number
|
|
bank_details?: string
|
|
first_address_line?: string
|
|
second_address_line?: string
|
|
country_id?: number | string
|
|
state_id?: number | string
|
|
city?: string
|
|
zip_code?: string
|
|
description?: string
|
|
security?: string
|
|
privacy_policy?: string
|
|
logo?: File | null
|
|
}
|
|
|
|
export class SettingsClient extends ApiClient {
|
|
constructor(baseUrl?: string, defaultOptions?: ApiClientOptions) {
|
|
super(baseUrl, defaultOptions)
|
|
}
|
|
|
|
async fetch() {
|
|
return this.get(SETTINGS_ROUTES.INDEX)
|
|
}
|
|
|
|
async update(payload: SettingsUpdatePayload) {
|
|
const hasFile = payload && (payload as any).logo instanceof File
|
|
if (!hasFile) {
|
|
const { logo: _logo, ...rest } = (payload ?? {}) as Record<string, unknown>
|
|
return this.put(SETTINGS_ROUTES.INDEX, rest as any)
|
|
}
|
|
|
|
const fd = new FormData()
|
|
for (const [key, value] of Object.entries(payload as Record<string, unknown>)) {
|
|
if (value === undefined || value === null) continue
|
|
if (value instanceof File) {
|
|
fd.append(key, value)
|
|
} else {
|
|
fd.append(key, String(value))
|
|
}
|
|
}
|
|
fd.append("_method", "PUT")
|
|
return this.postFormData(SETTINGS_ROUTES.INDEX, fd)
|
|
}
|
|
}
|