-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
160 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Album from 'Album/Album'; | ||
import AppSectionState, { | ||
AppSectionFilterState, | ||
} from 'App/State/AppSectionState'; | ||
|
||
interface CalendarAppState | ||
extends AppSectionState<Album>, | ||
AppSectionFilterState<Album> {} | ||
|
||
export default CalendarAppState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { useCallback } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { createSelector } from 'reselect'; | ||
import AppState from 'App/State/AppState'; | ||
import FilterModal from 'Components/Filter/FilterModal'; | ||
import { setCalendarFilter } from 'Store/Actions/calendarActions'; | ||
|
||
function createCalendarSelector() { | ||
return createSelector( | ||
(state: AppState) => state.calendar.items, | ||
(calendar) => { | ||
return calendar; | ||
} | ||
); | ||
} | ||
|
||
function createFilterBuilderPropsSelector() { | ||
return createSelector( | ||
(state: AppState) => state.calendar.filterBuilderProps, | ||
(filterBuilderProps) => { | ||
return filterBuilderProps; | ||
} | ||
); | ||
} | ||
|
||
interface CalendarFilterModalProps { | ||
isOpen: boolean; | ||
} | ||
|
||
export default function CalendarFilterModal(props: CalendarFilterModalProps) { | ||
const sectionItems = useSelector(createCalendarSelector()); | ||
const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); | ||
const customFilterType = 'calendar'; | ||
|
||
const dispatch = useDispatch(); | ||
|
||
const dispatchSetFilter = useCallback( | ||
(payload: unknown) => { | ||
dispatch(setCalendarFilter(payload)); | ||
}, | ||
[dispatch] | ||
); | ||
|
||
return ( | ||
<FilterModal | ||
// TODO: Don't spread all the props | ||
{...props} | ||
sectionItems={sectionItems} | ||
filterBuilderProps={filterBuilderProps} | ||
customFilterType={customFilterType} | ||
dispatchSetFilter={dispatchSetFilter} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters