import { createSelector } from '@reduxjs/toolkit' ; import { RootState } from '@store/store' ; import { CartProduct } from '@core' ; export const cartProductsSelector = state => state . cart . products ; export const cartProductsTotalCostSelector = createSelector ( cartProductsSelector , cartProducts => cartProducts . reduce ( ( acc , curr ) => acc + curr . product . price * curr . quantity , 0 ) ) ;