1
1
import { type TypeOf , z } from "zod" ;
2
- import { t } from "../util/i18n" ;
3
2
4
3
import type { APPLICATION_STATUS , USER_TYPES } from "../constants" ;
5
4
import { isDateAfterCurrentDate } from "../util" ;
6
5
import { emailSchema } from "./auth" ;
7
6
8
7
export const introSchema = z . object ( {
9
8
accept_terms_and_conditions : z . boolean ( ) . refine ( ( value ) => value === true , {
10
- message : t ( "You need to check this option to Access the Scheme" ) ,
9
+ message : "You need to check this option to Access the Scheme" ,
11
10
} ) ,
12
11
} ) ;
13
12
14
13
export type IntroInput = TypeOf < typeof introSchema > ;
15
14
16
15
export const submitSchema = z . object ( {
17
16
agree_topass_info_to_banking_partner : z . boolean ( ) . refine ( ( value ) => value === true , {
18
- message : t ( "You need to check this option to submit the application" ) ,
17
+ message : "You need to check this option to submit the application" ,
19
18
} ) ,
20
19
} ) ;
21
20
@@ -29,14 +28,16 @@ export const applicationBaseSchema = z.object({
29
28
30
29
export type ApplicationBaseInput = TypeOf < typeof applicationBaseSchema > ;
31
30
32
- export const declineApplicationSchema = z . object ( {
33
- decline_this : z . boolean ( ) ,
34
- decline_all : z . boolean ( ) ,
35
- uuid : UUIDType ,
36
- } ) . refine ( ( data ) => data . decline_this || data . decline_all , {
37
- path : [ "decline_all" ] ,
38
- message : t ( "You need to check at least one option to Decline the Scheme" ) ,
39
- } ) ;
31
+ export const declineApplicationSchema = z
32
+ . object ( {
33
+ decline_this : z . boolean ( ) ,
34
+ decline_all : z . boolean ( ) ,
35
+ uuid : UUIDType ,
36
+ } )
37
+ . refine ( ( data ) => data . decline_this || data . decline_all , {
38
+ path : [ "decline_all" ] ,
39
+ message : "You need to check at least one option to Decline the Scheme" ,
40
+ } ) ;
40
41
41
42
export type DeclineApplicationInput = TypeOf < typeof declineApplicationSchema > ;
42
43
@@ -50,14 +51,13 @@ export enum DECLINE_FEEDBACK {
50
51
}
51
52
52
53
export const DECLINE_FEEDBACK_NAMES : { [ key : string ] : string } = {
53
- [ DECLINE_FEEDBACK . dont_need_access_credit ] : t ( "Don't need access credit" ) ,
54
- [ DECLINE_FEEDBACK . already_have_acredit ] : t ( "Already have acredit" ) ,
55
- [ DECLINE_FEEDBACK . preffer_to_go_to_bank ] : t ( "Preffer to go to bank" ) ,
56
- [ DECLINE_FEEDBACK . dont_want_access_credit ] : t ( "Don't want access credit" ) ,
57
- [ DECLINE_FEEDBACK . suspicious_email ] : t (
54
+ [ DECLINE_FEEDBACK . dont_need_access_credit ] : "Don't need access credit" ,
55
+ [ DECLINE_FEEDBACK . already_have_acredit ] : "Already have acredit" ,
56
+ [ DECLINE_FEEDBACK . preffer_to_go_to_bank ] : "Preffer to go to bank" ,
57
+ [ DECLINE_FEEDBACK . dont_want_access_credit ] : "Don't want access credit" ,
58
+ [ DECLINE_FEEDBACK . suspicious_email ] :
58
59
"I perceive the email as suspicious or I do not trust that the credit proposal is true" ,
59
- ) ,
60
- [ DECLINE_FEEDBACK . other ] : t ( "Other" ) ,
60
+ [ DECLINE_FEEDBACK . other ] : "Other" ,
61
61
} ;
62
62
63
63
export const declineFeedbackSchema = z . object ( {
@@ -74,10 +74,10 @@ export const declineFeedbackSchema = z.object({
74
74
export type DeclineFeedbackInput = TypeOf < typeof declineFeedbackSchema > ;
75
75
76
76
export const creditOptionsSchema = z . object ( {
77
- borrower_size : z . string ( ) . min ( 1 , t ( "Borrower size is required" ) ) ,
78
- sector : z . string ( ) . min ( 1 , t ( "Sector is required" ) ) ,
77
+ borrower_size : z . string ( ) . min ( 1 , "Borrower size is required" ) ,
78
+ sector : z . string ( ) . min ( 1 , "Sector is required" ) ,
79
79
annual_revenue : z . coerce . number ( ) . optional ( ) . nullable ( ) ,
80
- amount_requested : z . coerce . number ( ) . min ( 1 , t ( "Amount requested must be greater than 0" ) ) ,
80
+ amount_requested : z . coerce . number ( ) . min ( 1 , "Amount requested must be greater than 0" ) ,
81
81
uuid : UUIDType ,
82
82
} ) ;
83
83
@@ -88,15 +88,16 @@ export type GetCreditProductsOptionsInput = Omit<CreditOptionsInput, "sector" |
88
88
export const repaymentTermsSchema = z . object ( {
89
89
repayment_years : z . coerce
90
90
. number ( {
91
- required_error : t ( "Years is required" ) ,
92
- invalid_type_error : t ( "Years must be a number" ) ,
91
+ required_error : "Years is required" ,
92
+ invalid_type_error : "Years must be a number" ,
93
93
} )
94
- . gte ( 0 , t ( "Years must be greater or equal than " ) ) ,
95
- repayment_months : z . coerce . number ( ) . min ( 1 , t ( "Months must be greater or equal than 1" ) ) ,
96
- payment_start_date : z . string ( )
97
- . min ( 1 , t ( "Payment start date is required" ) )
94
+ . gte ( 0 , "Years must be greater or equal than " ) ,
95
+ repayment_months : z . coerce . number ( ) . min ( 1 , "Months must be greater or equal than 1" ) ,
96
+ payment_start_date : z
97
+ . string ( )
98
+ . min ( 1 , "Payment start date is required" )
98
99
. refine ( ( value ) => isDateAfterCurrentDate ( value ) , {
99
- message : t ( "Payment start date must be after current date" ) ,
100
+ message : "Payment start date must be after current date" ,
100
101
} ) ,
101
102
} ) ;
102
103
@@ -336,7 +337,7 @@ export interface ILenderListResponse {
336
337
}
337
338
338
339
export const formEmailSchema = z . object ( {
339
- message : z . string ( ) . min ( 1 , t ( "A message is required" ) ) ,
340
+ message : z . string ( ) . min ( 1 , "A message is required" ) ,
340
341
} ) ;
341
342
342
343
export type FormEmailInput = TypeOf < typeof formEmailSchema > ;
@@ -348,10 +349,10 @@ export const approveSchema = z.object({
348
349
compliant_checks_passed : z . boolean ( ) ,
349
350
disbursed_final_amount : z . coerce
350
351
. number ( {
351
- required_error : t ( "Disbursed final amount is required" ) ,
352
- invalid_type_error : t ( "Disbursed final amount must be a number" ) ,
352
+ required_error : "Disbursed final amount is required" ,
353
+ invalid_type_error : "Disbursed final amount must be a number" ,
353
354
} )
354
- . gt ( 0 , t ( "Disbursed final amount must be greater than 0" ) ) ,
355
+ . gt ( 0 , "Disbursed final amount must be greater than 0" ) ,
355
356
} ) ;
356
357
357
358
export type FormApprovedInput = TypeOf < typeof approveSchema > ;
0 commit comments