File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,18 @@ const AddGroup = (props) => {
123123 </ FormErrorMessage >
124124 </ FormControl >
125125
126-
126+ < FormControl marginTop = "2" isInvalid = { errors . days } >
127+ < FormLabel htmlFor = "days" > Days</ FormLabel >
128+ < Input
129+ type = "number"
130+ name = "days"
131+ placeholder = "Number of days of the trip"
132+ { ...register ( "days" ) }
133+ />
134+ < FormErrorMessage >
135+ { errors . days && errors . days . message }
136+ </ FormErrorMessage >
137+ </ FormControl >
127138
128139 < FormControl mt = "2" isInvalid = { errors . involved } >
129140 < FormLabel htmlFor = "involved" > Add members to the group</ FormLabel >
Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ const Home = () => {
4848useEffect ( ( ) => {
4949 let total = 0 , negative = 0 , positive = 0 ;
5050 transactions . forEach ( ( transaction ) => {
51- console . log ( transaction ) ;
5251 const amt = transaction . data . amount / transaction . data . involved . length
5352 if ( transaction . data . paidBy === user . uid ) {
5453 positive += amt
Original file line number Diff line number Diff line change @@ -42,6 +42,23 @@ const addGroupSchema = Joi.object({
4242 } ) ;
4343 return errors ;
4444 } ) ,
45+ days : Joi . number ( )
46+ . positive ( )
47+ . integer ( )
48+ . required ( )
49+ . error ( ( errors ) => {
50+ errors . forEach ( ( err ) => {
51+ if ( err . code === "number.positive" ) {
52+ err . message = "Days must be positive"
53+ }
54+ else if ( err . code === "number.base" ) {
55+ err . message = "Days must be an integer"
56+ }
57+ else if ( err . code === "number.empty" ) {
58+ err . message = "Days is required"
59+ }
60+ } )
61+ } ) ,
4562 mails : Joi . array ( )
4663 . items ( Joi . string ( ) )
4764 . unique ( )
You can’t perform that action at this time.
0 commit comments