@@ -7,7 +7,7 @@ import { getMenuCourses } from '../lib/menu-course-api';
77import { getCustomerGroups , getCustomerTerritories , getCustomerById } from '../lib/customer-api' ;
88import { DEFAULT_ORDER_TYPE , OrderType } from '../data/order-types' ;
99import { getTableOrder , TableOrder } from '../lib/order-api' ;
10-
10+ import { getPaymentModes } from '../lib/payment-api' ;
1111// Constants
1212const MAX_QUANTITY = 99 ;
1313const MIN_QUANTITY = 0 ;
@@ -269,10 +269,17 @@ export const usePOSStore = create<POSStore>((set, get) => ({
269269
270270 // Set default customer if none selected
271271 if ( ! get ( ) . selectedCustomer && mappings . length > 0 ) {
272- const firstMapping = mappings [ 0 ] ;
273- const defaultCustomer = customerMap [ firstMapping . order_type ] ;
274- if ( defaultCustomer ) {
275- set ( { selectedCustomer : defaultCustomer } ) ;
272+ const currentOrderType = get ( ) . selectedOrderType ;
273+ const mappedCustomer = customerMap [ currentOrderType ] ;
274+
275+ if ( mappedCustomer ) {
276+ set ( { selectedCustomer : mappedCustomer } ) ;
277+ } else {
278+ const firstMapping = mappings [ 0 ] ;
279+ const defaultCustomer = customerMap [ firstMapping . order_type ] ;
280+ if ( defaultCustomer ) {
281+ set ( { selectedCustomer : defaultCustomer } ) ;
282+ }
276283 }
277284 }
278285 } catch ( err ) {
@@ -321,10 +328,17 @@ export const usePOSStore = create<POSStore>((set, get) => ({
321328
322329 // Set default customer if none selected
323330 if ( ! get ( ) . selectedCustomer && mappings . length > 0 ) {
324- const firstMapping = mappings [ 0 ] ;
325- const defaultCustomer = customerMap [ firstMapping . order_type ] ;
326- if ( defaultCustomer ) {
327- set ( { selectedCustomer : defaultCustomer } ) ;
331+ const currentOrderType = get ( ) . selectedOrderType ;
332+ const mappedCustomer = customerMap [ currentOrderType ] ;
333+
334+ if ( mappedCustomer ) {
335+ set ( { selectedCustomer : mappedCustomer } ) ;
336+ } else {
337+ const firstMapping = mappings [ 0 ] ;
338+ const defaultCustomer = customerMap [ firstMapping . order_type ] ;
339+ if ( defaultCustomer ) {
340+ set ( { selectedCustomer : defaultCustomer } ) ;
341+ }
328342 }
329343 }
330344 } catch ( err ) {
0 commit comments