@@ -10,7 +10,6 @@ import CsaCatalogPresentation from './containers/CsaCatalogPresentation';
1010import CsaCatalogSubscription from './containers/CsaCatalogSubscription' ;
1111import MediumActionIcon from './containers/MediumActionIcon' ;
1212import {
13- useRestCheckSubscriptionDefaultOrderPost ,
1413 useRestSubscriptionPost ,
1514 useRestUpdateSubscriptionDefaultOrderPost ,
1615 useRestUpdateSubscriptionOrdersPost ,
@@ -55,8 +54,6 @@ const CsaCatalogRouter = ({ userId }: CsaCatalogRouterProps) => {
5554 updateSubscriptionDefaultOrder ,
5655 { data : updatedDefaultOrderData , error : updateDefaultOrderError } ,
5756 ] = useRestUpdateSubscriptionDefaultOrderPost ( ) ;
58- const [ checkSubscriptionDefaultOrder , { error : checkDefaultOrderError } ] =
59- useRestCheckSubscriptionDefaultOrderPost ( catalogId ) ;
6057
6158 React . useEffect ( ( ) => {
6259 if (
@@ -111,20 +108,23 @@ const CsaCatalogRouter = ({ userId }: CsaCatalogRouterProps) => {
111108 quantity : defaultOrder [ parseInt ( productId , 10 ) ] ,
112109 } ) ) ,
113110 absentDistribIds : absenceDistributionsIds ,
114- initialOrders : Object . keys ( updatedOrders ) . map ( ( distributionId ) => ( {
115- id : parseInt ( distributionId , 10 ) ,
116- orders : Object . keys ( updatedOrders [ parseInt ( distributionId , 10 ) ] ) . map ( ( productId ) => ( {
117- productId : parseInt ( productId , 10 ) ,
118- qty : updatedOrders [ parseInt ( distributionId , 10 ) ] [ parseInt ( productId , 10 ) ] ,
119- } ) ) ,
111+ initialOrders : Object . keys ( updatedOrders )
112+ . filter ( ( distributionId ) => ! absenceDistributionsIds ?. includes ( parseInt ( distributionId , 10 ) ) )
113+ . map ( ( distributionId ) => ( {
114+ id : parseInt ( distributionId , 10 ) ,
115+ orders : Object . keys ( updatedOrders [ parseInt ( distributionId , 10 ) ] ) . map ( ( productId ) => ( {
116+ productId : parseInt ( productId , 10 ) ,
117+ qty : updatedOrders [ parseInt ( distributionId , 10 ) ] [ parseInt ( productId , 10 ) ] ,
118+ } ) ) ,
120119 } ) )
121120 } ) ;
122121
123- if ( ! subscriptionSucceeded ) return ;
122+ if ( ! subscriptionSucceeded ) return false ;
124123
125124 window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
126125
127126 setStep ( 'review' ) ;
127+ return true ;
128128 } ;
129129
130130 React . useEffect ( ( ) => {
@@ -179,8 +179,7 @@ const CsaCatalogRouter = ({ userId }: CsaCatalogRouterProps) => {
179179 updatedSubscriptionError ||
180180 postSubscriptionError ||
181181 contextError ||
182- updateDefaultOrderError ||
183- checkDefaultOrderError ;
182+ updateDefaultOrderError ;
184183
185184 if ( ! catalog ) return < CircularProgressBox /> ;
186185
@@ -204,7 +203,7 @@ const CsaCatalogRouter = ({ userId }: CsaCatalogRouterProps) => {
204203 { step === 'presentation' && (
205204 < CsaCatalogPresentation onNext = { gotoAbsences } />
206205 ) }
207- { step === 'absences' && < CsaCatalogAbsences onNext = { gotoDefaultOrder } adminMode = { adminMode } /> }
206+ { step === 'absences' && < CsaCatalogAbsences onNext = { async ( ) => gotoDefaultOrder ( ) } adminMode = { adminMode } /> }
208207 { step === 'requiredOrders' && (
209208 < Box
210209 width = { '100%' }
0 commit comments