Skip to content

Commit

Permalink
feat: availability use 2 years to call to api
Browse files Browse the repository at this point in the history
  • Loading branch information
IB-AUTEN-rvillalba committed Dec 5, 2023
1 parent 9f87ea6 commit db72fed
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const AvailabilityTable: FC = () => {
const { selectedDate } = useCalendarContext()
const [userAbsences, setUserAbsences] = useState<UserAbsence[]>([])
const [previousDate, setPreviousDate] = useState<Date | null>(null)
const [requiredFiltersChange, setRequiredFiltersChange] = useState<boolean>(false)
const [absenceFilters, setAbsenceFilters] = useState<AbsenceFilters>({
startDate: chrono().format(chrono.DATE_FORMAT),
endDate: chrono().format(chrono.DATE_FORMAT)
Expand Down Expand Up @@ -50,7 +51,7 @@ export const AvailabilityTable: FC = () => {
useEffect(() => {
if (
requiredFiltersAreSelected() &&
previousDate?.getFullYear() !== selectedDate.getFullYear()
(requiredFiltersChange === true || previousDate?.getFullYear() !== selectedDate.getFullYear())
) {
getAbsencesQry({
...absenceFilters,
Expand All @@ -62,6 +63,7 @@ export const AvailabilityTable: FC = () => {
}).then((absences) => {
setUserAbsences(absences)
setPreviousDate(selectedDate)
setRequiredFiltersChange(false)
})
}
}, [absenceFilters, selectedDateInterval, previousDate])

Check warning on line 69 in src/features/binnacle/features/availability/ui/components/availability-table/availability-table.tsx

View workflow job for this annotation

GitHub Actions / Test

React Hook useEffect has missing dependencies: 'getAbsencesQry', 'requiredFiltersAreSelected', 'requiredFiltersChange', and 'selectedDate'. Either include them or remove the dependency array
Expand All @@ -71,6 +73,7 @@ export const AvailabilityTable: FC = () => {

const onFilterChange = (updatedFilter: Partial<AbsenceFilters>) => {
setAbsenceFilters({ ...absenceFilters, ...updatedFilter })
setRequiredFiltersChange(true)
}

useEffect(() => {
Expand Down

0 comments on commit db72fed

Please sign in to comment.