title: How can I add, edit, remove items as specific user from their details?
body: <p>I have currently redux set up in a way where people can add their cars and other things and update them but I would need them to show only to that user that is currently logged in.</p>
  <p>I created following user reducer that has all the information but not sure if structure is correct and what to change here to make it work as intended.</p>
  <p>What I am intending to do here is that it would look something like this so I can filter the data according to who is logged in.</p>
  <pre class="lang-js prettyprint-override"><code>user: [
  {    username: '',
      insurances: [],
      cars: [],
      workplace: {
        employer: '',
        companyNumber: '',
        insuranceCompany: '',
        workHealthcare: '',
        actionGuide: '',
      } },
  ]
  </code></pre>
  <p>userReducer:</p>
  <pre class="lang-js prettyprint-override"><code>const ADD_USER = 'ADD_USER'
  const USER_LOGGED_IN = 'USER_LOGGED_IN'
  const ADD_NEW_INSURANCE = 'ADD_NEW_INSURANCE'
  const DELETE_EXISTING_INSURANCE = 'DELETE_EXISTING_INSURANCE'
  const ADD_NEW_CAR = 'ADD_NEW_CAR'
  const DELETE_EXISTING_CAR = 'DELETE_EXISTING_CAR'
  const UPDATE_WORKPLACE_DETAILS = 'UPDATE_WORKPLACE_DETAILS'
  const UPDATE_EMPLOYEE_DETAILS = 'UPDATE_EMPLOYEE_DETAILS'
  const UPDATE_COMPANYNUMBER_DETAILS = 'UPDATE_COMPANYNUMBER_DETAILS'
  const UPDATE_INSURANCECOMPANY_DETAILS = 'UPDATE_INSURANCECOMPANY_DETAILS'
  const UPDATE_WORKHEALTHCARE_DETAILS = 'UPDATE_WORKHEALTHCARE_DETAILS'
  const UPDATE_ACTIONGUIDE_DETAILS = 'UPDATE_ACTIONGUIDE_DETAILS'
  
  const initialState = {
    users: [
      {
        username: '',
        signedIn: false,
        insurances: [],
        cars: [],
        workplace: {
          employer: '',
          companyNumber: '',
          insuranceCompany: '',
          workHealthcare: '',
          actionGuide: '',
        },
      },
    ],
  }
  
  const userReducer = (state = initialState, action) =&gt; {
    switch (action.type) {
      case ADD_USER:
        return {
          ...state,
          users: [...state.users, { id: state.users.length, ...action.payload }],
        }
      case USER_LOGGED_IN:
        return {
          ...state,
          signedIn: action.payload,
        }
      case ADD_NEW_INSURANCE:
        return {
          ...state,
          insurances: [
            ...state.insurances,
            { id: state.insurances.length, ...action.payload },
          ],
        }
      case DELETE_EXISTING_INSURANCE:
        return {
          insurances: [
            ...state.insurances.filter(
              (insurance) =&gt; insurance !== action.payload
            ),
          ],
        }
      case ADD_NEW_CAR:
        return {
          ...state,
          cars: [...state.cars, { id: state.cars.length, ...action.payload }],
        }
      case DELETE_EXISTING_CAR:
        return {
          cars: [...state.cars.filter((car) =&gt; car !== action.payload)],
        }
      case UPDATE_EMPLOYEE_DETAILS:
        return {
          ...state,
          employer: action.payload.employer,
        }
      case UPDATE_WORKPLACE_DETAILS:
        return {
          ...state,
          employee: action.payload.employee,
        }
      case UPDATE_COMPANYNUMBER_DETAILS:
        return {
          ...state,
          companyNumber: action.payload.companyNumber,
        }
      case UPDATE_INSURANCECOMPANY_DETAILS:
        return {
          ...state,
          insuranceCompany: action.payload.insuranceCompany,
        }
      case UPDATE_WORKHEALTHCARE_DETAILS:
        return {
          ...state,
          workHealthcare: action.payload.workHealthcare,
        }
      case UPDATE_ACTIONGUIDE_DETAILS:
        return {
          ...state,
          actionGuide: action.payload.actionGuide,
        }
      default:
        return state
    }
  }
  
  export default userReducer
  
  </code></pre>
  <p>Here is my action files currently:</p>
  <pre class="lang-js prettyprint-override"><code>const ADD_NEW_CAR = 'ADD_NEW_CAR'
  const DELETE_EXISTING_CAR = 'DELETE_EXISTING_CAR'
  
  export const addNewCar = (text) =&gt; ({
      type: ADD_NEW_CAR,
      payload: text
  })
  
  export const deleteExistingCar = (car) =&gt; ({
      type: DELETE_EXISTING_CAR,
      payload: car
  })
  
  const ADD_NEW_INSURANCE = 'ADD_NEW_INSURANCE'
  const DELETE_EXISTING_INSURANCE = 'DELETE_EXISTING_INSURANCE'
  
  export const addInsurance = (text) =&gt; ({
      type: ADD_NEW_INSURANCE,
      payload: text
  })
  
  export const deleteExistingInsurance = (insurance) =&gt; ({
      type: DELETE_EXISTING_INSURANCE,
      payload: insurance
  })
  
  const UPDATE_EMPLOYEE_DETAILS = 'UPDATE_EMPLOYEE_DETAILS'
  const UPDATE_COMPANYNUMBER_DETAILS = 'UPDATE_COMPANYNUMBER_DETAILS'
  const UPDATE_INSURANCECOMPANY_DETAILS = 'UPDATE_INSURANCECOMPANY_DETAILS'
  const UPDATE_WORKHEALTHCARE_DETAILS = 'UPDATE_WORKHEALTHCARE_DETAILS'
  const UPDATE_ACTIONGUIDE_DETAILS = 'UPDATE_ACTIONGUIDE_DETAILS'
  
  export const employeeEditAction = (text) =&gt; ({
    type: UPDATE_EMPLOYEE_DETAILS,
    payload: { employee: text },
  })
  
  export const companyNumberEditAction = (text) =&gt; ({
    type: UPDATE_COMPANYNUMBER_DETAILS,
    payload: { companyNumber: text },
  })
  
  export const insuranceCompanyEditAction = (text) =&gt; ({
    type: UPDATE_INSURANCECOMPANY_DETAILS,
    payload: { insuranceCompany: text },
  })
  
  export const workHealthcareEditAction = (text) =&gt; ({
    type: UPDATE_WORKHEALTHCARE_DETAILS,
    payload: { workHealthcare: text },
  })
  
  export const actionGuideEditAction = (text) =&gt; ({
    type: UPDATE_ACTIONGUIDE_DETAILS,
    payload: { actionGuide: text },
  })
  
  const USER_LOGGED_IN = 'USER_LOGGED_IN'
  
  export const authAction = (trueFalse) =&gt; ({
      type: USER_LOGGED_IN,
      payload: trueFalse,
    });
  </code></pre>
  <p>and this is my auth reducer:</p>
  <pre class="lang-js prettyprint-override"><code>const USER_LOGGED_IN = 'USER_LOGGED_IN'
  
  const initialState = {
    signedIn: false,
  }
  
  const authsReducer = (state = initialState, action) =&gt; {
    switch (action.type) {
      case USER_LOGGED_IN:
        return {
          ...state,
          signedIn: action.payload,
        }
      default:
        return state
    }
  }
  export default authsReducer
  </code></pre>