source: src/schemas/customer.ts

main
Last change on this file was 299af01, checked in by Naum Shapkarovski <naumshapkarovski@…>, 6 weeks ago

chore

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import { z } from 'zod';
2
3export const customerTableFilterValueSchema = z.union([z.string(), z.array(z.string())]);
4
5export const customerTableFiltersSchema = z.object({
6 name: z.string(),
7 role: z.array(z.string()),
8 status: z.string(),
9});
10
11export const addressSchema = z.object({
12 street: z.string(),
13 city: z.string().optional(),
14 country: z.string(),
15 state: z.string().optional(),
16 zip: z.string(),
17});
18
19export const bankAccountSchema = z.object({
20 accountNumber: z.string().optional(),
21 bicSwift: z.string().optional(),
22 iban: z.string().optional(),
23 routingNumber: z.string().optional(),
24});
25
26export const customerStatusSchema = z.union([
27 z.literal('active'),
28 z.literal('banned'),
29 z.literal('inactive'),
30]);
31
32export const customerSchema = z.object({
33 id: z.string().optional(),
34 tenantId: z.string(),
35 name: z.string(),
36 email: z.string(),
37 address: addressSchema,
38 logoUrl: z.string().optional(),
39 phoneNumber: z.string().optional(),
40 vatNumber: z.string().optional(),
41 companyNumber: z.string().optional(),
42 representative: z.string(),
43 status: customerStatusSchema.optional(),
44});
45
46export const tenantSchema = customerSchema
47 .omit({
48 tenantId: true,
49 status: true,
50 })
51 .extend({
52 lastInvoiceNumber: z.string(),
53 });
54
55export const newCustomerSchema = z.object({
56 tenantId: z.string().optional(),
57 name: z.string(),
58 email: z.string(),
59 address: addressSchema,
60 logoUrl: z.any().nullable().optional(),
61 phoneNumber: z.string().optional(),
62 vatNumber: z.string().optional(),
63 companyNumber: z.string().optional(),
64 representative: z.string(),
65 status: customerStatusSchema,
66});
67
68export const updateCustomerSchema = newCustomerSchema.omit({
69 tenantId: true,
70 status: true,
71});
Note: See TracBrowser for help on using the repository browser.