import { createSelector } from '@reduxjs/toolkit' import { ActionState } from '../actions/actions.slice' import { RootState } from '../store' const selectSelf = (state: RootState) => state export const selectActionsCost = () => createSelector(selectSelf, (state: RootState) => state.actions.reduce( (acc, { metadata }: ActionState) => acc + (metadata.cost || 0), 0 ) ) export const selectActionsTime = () => createSelector(selectSelf, (state: RootState) => state.actions.reduce( (acc, { metadata }: ActionState) => acc + (metadata.time || 0), 1 ) )