import { StoreState } from '.'; export type StoreSelector = (state: StoreState) => T; export const selectBill: StoreSelector = state => state.bill; export const selectPercentage: StoreSelector = state => state.percentage; export const selectSplit: StoreSelector = state => state.split; export const selectTotal: StoreSelector = state => { const total = state.bill + state.bill * (state.percentage / 100); return total.toFixed(2); }; export const selectTip: StoreSelector = state => { const tip = state.bill * (state.percentage / 100); return tip.toFixed(2); }; export const selectPerPerson: StoreSelector = state => { const perPerson = (state.bill + state.bill * (state.percentage / 100)) / state.split; return perPerson.toFixed(2); };