import React from 'react'
import LabelField from './fields/LabelField'
import CheckboxField from './fields/CheckboxField'
import { useDispatch, useSelector } from 'react-redux'
import { updateCountOnlyWorkingDays } from '../reducers/holiday-settings'

const WorkingDays = () => {
  const dispatch = useDispatch()
  const countOnlyWorkingDays = useSelector(state => {
    return state.holidaySettings.countOnlyWorkingDays
  })
  const handleChange = e => {
     dispatch(updateCountOnlyWorkingDays(e.target.checked))
  }
  return (
    <div className="dreamfox-holidays__row dreamfox-flex">
      <LabelField>Count Only Working Days</LabelField>
      <CheckboxField options={{
        checked: countOnlyWorkingDays,
        onChange: handleChange,
      }}></CheckboxField>
    </div>
  )
}

export default WorkingDays
