source: src/schemas/customer.ts@ 057453c

main
Last change on this file since 057453c was 057453c, checked in by Naum Shapkarovski <naumshapkarovski@…>, 5 weeks ago

feat: implement employees

  • Property mode set to 100644
File size: 1.5 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 name: z.string(),
35 email: z.string(),
36 address: addressSchema,
37 logoUrl: z.string().optional(),
38 phoneNumber: z.string().optional(),
39 vatNumber: z.string().optional(),
40 companyNumber: z.string().optional(),
41 representative: z.string(),
42 status: customerStatusSchema.optional(),
43});
44
45export const tenantSchema = customerSchema
46 .omit({
47 companyId: true,
48 status: true,
49 })
50 .extend({
51 lastInvoiceNumber: z.string(),
52 });
53
54export const newCustomerSchema = z.object({
55 name: z.string(),
56 email: z.string(),
57 address: addressSchema,
58 logoUrl: z.any().nullable().optional(),
59 phoneNumber: z.string().optional(),
60 vatNumber: z.string().optional(),
61 companyNumber: z.string().optional(),
62 representative: z.string(),
63 status: customerStatusSchema,
64});
Note: See TracBrowser for help on using the repository browser.