humam kerdiah 4f0a2f790f feat: add logo field to settings schema and update settings client to handle file uploads
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
2026-05-19 17:56:39 +04:00

65 lines
2.4 KiB
TypeScript

import { z } from "zod"
import { FirstDayOfWork } from "@garage/api"
export const relationFieldSchema = z
.object({ value: z.string(), label: z.string() })
.nullable()
const optionalLatitude = z
.string()
.optional()
.refine(
(v) => v == null || v === "" || (!Number.isNaN(Number(v)) && Number(v) >= -90 && Number(v) <= 90),
"Latitude must be between -90 and 90",
)
const optionalLongitude = z
.string()
.optional()
.refine(
(v) => v == null || v === "" || (!Number.isNaN(Number(v)) && Number(v) >= -180 && Number(v) <= 180),
"Longitude must be between -180 and 180",
)
const optionalUrl = z
.string()
.max(255, "Website cannot exceed 255 characters")
.optional()
.refine(
(v) => v == null || v === "" || z.string().url().safeParse(v).success,
"Enter a valid website URL",
)
export const settingsFormSchema = z.object({
name: z.string().min(1, "Name is required").max(100, "Name cannot exceed 100 characters"),
email: z.union([z.string().email("Invalid email address"), z.literal("")]).optional(),
phone: z.string().max(30, "Phone cannot exceed 30 characters").optional(),
alternative_phone: z.string().max(30, "Phone cannot exceed 30 characters").optional(),
website: optionalUrl,
time_zone: z.string().max(100, "Time zone cannot exceed 100 characters").optional(),
upi_id: z.string().max(100, "UPI cannot exceed 100 characters").optional(),
first_day_of_work: z.union([z.enum(FirstDayOfWork), z.literal("")]).optional(),
latitude: optionalLatitude,
longitude: optionalLongitude,
bank_details: z.string().optional(),
first_address_line: z.string().max(255, "Address cannot exceed 255 characters").optional(),
second_address_line: z.string().max(255, "Address cannot exceed 255 characters").optional(),
country: relationFieldSchema,
state: relationFieldSchema,
city: z.string().max(100, "City cannot exceed 100 characters").optional(),
zip_code: z.string().max(20, "Zip code cannot exceed 20 characters").optional(),
description: z.string().optional(),
security: z.string().optional(),
privacy_policy: z.string().optional(),
logo: z
.any()
.nullable()
.optional()
.refine(
(v) => v == null || v instanceof File,
"Logo must be an image file",
),
})
export type SettingsFormValues = z.infer<typeof settingsFormSchema>