@@ -25,7 +25,7 @@ const createOutBatchSchema = z.object({
2525 . string ( )
2626 . date ( )
2727 . default ( ( ) => new Date ( ) . toLocaleDateString ( "se-SE" ) ) ,
28- nrBottles : z . number ( ) . nonnegative ( ) ,
28+ nrBottles : z . number ( ) . nonnegative ( ) . default ( 0 ) ,
2929} ) ;
3030
3131const createInBatchSchema = z . object ( {
@@ -35,7 +35,7 @@ const createInBatchSchema = z.object({
3535 . string ( )
3636 . date ( )
3737 . default ( ( ) => new Date ( ) . toLocaleDateString ( "se-SE" ) ) ,
38- nrBottles : z . number ( ) . nonnegative ( ) ,
38+ nrBottles : z . number ( ) . nonnegative ( ) . default ( 0 ) ,
3939} ) ;
4040
4141export const actions : Actions = {
@@ -53,7 +53,6 @@ export const actions: Actions = {
5353 data : {
5454 drinkItemId : form . data . drinkItemId ,
5555 quantityDelta : form . data . quantityDelta ,
56- nrBottles : form . data . nrBottles ,
5756 date : dayjs ( form . data . date ) . toDate ( ) ,
5857 user : user . studentId ! ,
5958 } ,
@@ -65,6 +64,9 @@ export const actions: Actions = {
6564 quantityAvailable : {
6665 increment : form . data . quantityDelta ,
6766 } ,
67+ nrBottles : {
68+ increment : form . data . nrBottles ,
69+ } ,
6870 } ,
6971 } ) ;
7072 return message ( form , { message : "Antal inskrivet" } ) ;
@@ -89,6 +91,9 @@ export const actions: Actions = {
8991 quantityAvailable : {
9092 decrement : form . data . quantityDelta ,
9193 } ,
94+ nrBottles : {
95+ decrement : form . data . nrBottles ,
96+ } ,
9297 } ,
9398 } ) ;
9499
@@ -100,7 +105,6 @@ export const actions: Actions = {
100105 data : {
101106 drinkItemId : form . data . drinkItemId ,
102107 quantityDelta : - form . data . quantityDelta ,
103- nrBottles : form . data . nrBottles ,
104108 date : dayjs ( form . data . date ) . toDate ( ) ,
105109 user : user . studentId ! ,
106110 } ,
0 commit comments